diff options
Diffstat (limited to 'addon.py')
| -rw-r--r-- | addon.py | 36 |
1 files changed, 35 insertions, 1 deletions
@@ -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() |