diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f976f28..dd8a3dd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,11 @@ Changelog ********* +v3.2 (2020-12-22) +======================================== + +- release to fix breaking changes and other minor bugs + v3.1 (2020-07-24) ======================================== diff --git a/mopidy_youtube/apis/youtube_bs4api.py b/mopidy_youtube/apis/youtube_bs4api.py index 1e40543..f20208c 100644 --- a/mopidy_youtube/apis/youtube_bs4api.py +++ b/mopidy_youtube/apis/youtube_bs4api.py @@ -22,7 +22,7 @@ class bs4API(scrAPI): ytdata_regex = ( r'window\["ytInitialData"] = ({.*?});', - r'ytInitialData = ({.*});' + r"ytInitialData = ({.*});", ) @classmethod @@ -37,7 +37,6 @@ def _find_yt_data(cls, text): logger.error("No data found on page") raise Exception("No data found on page") - @classmethod def run_search(cls, query): @@ -76,14 +75,16 @@ def run_search(cls, query): logger.info("nothing in the soup, trying japi") yt_data = cls._find_yt_data(result.text) - extracted_json = yt_data["contents"]\ - ["twoColumnSearchResultsRenderer"]["primaryContents"]\ - ["sectionListRenderer"]["contents"][0]\ - ["itemSectionRenderer"]["contents"] + extracted_json = yt_data["contents"][ + "twoColumnSearchResultsRenderer" + ]["primaryContents"]["sectionListRenderer"]["contents"][0][ + "itemSectionRenderer" + ][ + "contents" + ] return jAPI.json_to_items(cls, extracted_json) - @classmethod def soup_to_items(cls, results): items = [] @@ -237,11 +238,23 @@ def list_playlistitems(cls, id, page, max_results): ) yt_data = cls._find_yt_data(result.text) - extracted_json = yt_data["contents"]\ - ["twoColumnBrowseResultsRenderer"]["tabs"][0]\ - ["tabRenderer"]["content"]["sectionListRenderer"]\ - ["contents"][0]["itemSectionRenderer"]["contents"]\ - [0]["playlistVideoListRenderer"]["contents"] + extracted_json = yt_data["contents"][ + "twoColumnBrowseResultsRenderer" + ]["tabs"][0]["tabRenderer"]["content"]["sectionListRenderer"][ + "contents" + ][ + 0 + ][ + "itemSectionRenderer" + ][ + "contents" + ][ + 0 + ][ + "playlistVideoListRenderer" + ][ + "contents" + ] items = jAPI.json_to_items(cls, extracted_json) else: @@ -265,7 +278,8 @@ def plsoup_to_items(cls, videos): "duration": "PT" + cls.format_duration( re.match( - cls.time_regex, video.find(class_="timestamp").text, + cls.time_regex, + video.find(class_="timestamp").text, ) ), }, @@ -372,9 +386,11 @@ def list_related_videos(cls, video_id): logger.info("nothing in the soup, trying japi related videos") yt_data = cls._find_yt_data(result.text) - extracted_json = yt_data["contents"]\ - ["twoColumnWatchNextResults"]["secondaryResults"]\ - ["secondaryResults"]["results"] # noqa: E501 + extracted_json = yt_data["contents"][ + "twoColumnWatchNextResults" + ]["secondaryResults"]["secondaryResults"][ + "results" + ] # noqa: E501 items = jAPI.json_to_items(cls, extracted_json) diff --git a/mopidy_youtube/backend.py b/mopidy_youtube/backend.py index 4e77e69..4270e05 100644 --- a/mopidy_youtube/backend.py +++ b/mopidy_youtube/backend.py @@ -243,7 +243,9 @@ def lookup(self, uri): comment=video.id, length=video.length.get() * 1000, artists=[Artist(name=video.channel.get())], - album=Album(name="YouTube Video",), + album=Album( + name="YouTube Video", + ), uri="youtube:video/%s.%s" % (safe_url(video.title.get()), video.id), ) diff --git a/setup.cfg b/setup.cfg index d0eb1d7..a7bb33f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = Mopidy-YouTube -version = 3.1 +version = 3.2 url = https://github.com/natumbri/mopidy-youtube author = nik tumbri author_email = natumbri@gmail.com @@ -27,11 +27,11 @@ python_requires = >= 3.7 install_requires = beautifulsoup4 cachetools - Mopidy >= 3.0 + Mopidy >= 3.1 Pykka >= 2.0.1 requests setuptools - youtube_dl >= 2020.5.3 + youtube_dl >= 2020.12.22 [options.extras_require] lint =