summaryrefslogtreecommitdiff
path: root/addon.py
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.org>2024-06-19 15:45:44 -0400
committerJakob L. Kreuze <zerodaysfordays@sdf.org>2024-06-19 15:48:08 -0400
commitd7602cc3fd904a95b096687076bc9d45752d10ed (patch)
treef66e4f519368bd3d2727508f8d2597e07c12824a /addon.py
parent39602bc6c10397e1d36e6c50af21009822eb1b31 (diff)
Add support for the "Your Feed" page
Diffstat (limited to 'addon.py')
-rw-r--r--addon.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/addon.py b/addon.py
index 1d89740..f8400d3 100644
--- a/addon.py
+++ b/addon.py
@@ -106,6 +106,21 @@ def get_collections(official=True, sort_by="date", offset=1):
return fetch_visual_links(visual_links)
+def get_feed_videos():
+ """
+ Return a list of video URLs from the "Your Feed" page
+
+ :return: list of video URLs
+ :rtype: list
+ """
+ html = requests.get(
+ "https://www.newgrounds.com/social/feeds/show/favorite-artists-movies",
+ cookies=get_session()
+ ).text
+ soup = BeautifulSoup(html, "html.parser")
+ return [tag["href"] for tag in soup.find_all("a", "item-portalsubmission")]
+
+
def get_series_videos(url):
"""
Return videos in a series on Newgrounds
@@ -204,6 +219,16 @@ def list_top_level():
is_folder = True
xbmcplugin.addDirectoryItem(HANDLE, url, list_item, is_folder)
+ # Add a dialog for displaying the user's feed
+ if authentication_specified():
+ list_item = xbmcgui.ListItem(label="Your Feed")
+ info_tag = list_item.getVideoInfoTag()
+ info_tag.setMediaType("video")
+ info_tag.setTitle("Your Feed")
+ url = get_url(action="listing_feed")
+ is_folder = True
+ xbmcplugin.addDirectoryItem(HANDLE, url, list_item, is_folder)
+
for name in genres:
list_item = xbmcgui.ListItem(label=name)
@@ -294,7 +319,6 @@ def get_addon_video_info(url):
html = requests.get(url, cookies=get_session()).text
soup = BeautifulSoup(html, "html.parser")
- xbmc.log("Getting {}...".format(url), 2)
title = soup.find("div", id="embed_header").h2.string
thumbnail = soup.find("meta", property="og:image")
if thumbnail is not None:
@@ -604,6 +628,9 @@ def router(paramstring):
cards = get_series_videos(params["url"])
video_urls = [card["url"] for card in cards]
list_videos(video_urls)
+ elif params["action"] == "listing_feed":
+ video_urls = get_feed_videos()
+ list_videos(video_urls)
elif params["action"] == "search":
term = params["term"]
offset = int(params.get("offset", 1))
@@ -628,6 +655,13 @@ def test_logged_in(session):
)
+def authentication_specified():
+ addon = Addon()
+ username = addon.getSetting("newgrounds.username")
+ password = addon.getSetting("newgrounds.password")
+ return username != "" and password != ""
+
+
def get_session():
addon = Addon()