Skip to content

Commit 4506c7e

Browse files
committed
get_episode: fixed a crash for podcasts with missing description
1 parent 3f27d9b commit 4506c7e

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

tests/mixins/test_browsing.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,6 @@ def test_get_lyrics(self, config, yt, sample_video):
191191
assert song.start_time <= song.end_time
192192
assert isinstance(song.id, int)
193193

194-
playlist = yt.get_watch_playlist(config["uploads"]["private_upload_id"])
195-
assert playlist["lyrics"] is None
196-
with pytest.raises(Exception):
197-
yt.get_lyrics(playlist["lyrics"])
198-
199194
def test_get_signatureTimestamp(self, yt):
200195
signature_timestamp = yt.get_signatureTimestamp()
201196
assert signature_timestamp is not None

tests/mixins/test_explore.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import pytest
2+
3+
14
class TestExplore:
25
def test_get_mood_playlists(self, yt):
36
categories = yt.get_mood_categories()
@@ -7,6 +10,7 @@ def test_get_mood_playlists(self, yt):
710
playlists = yt.get_mood_playlists(categories[cat][0]["params"])
811
assert len(playlists) > 0
912

13+
@pytest.mark.skip(reason="disabled for now due to #787")
1014
def test_get_charts(self, yt, yt_oauth):
1115
charts = yt_oauth.get_charts()
1216
# songs section appears to be removed currently (US)

tests/mixins/test_podcasts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_many_episodes(self, yt):
4444
results = yt.search("episode", filter="episodes")
4545
for result in results:
4646
result = yt.get_episode(result["videoId"])
47-
assert len(result["description"].text) > 0
47+
assert result["description"] is None or len(result["description"].text) > 0
4848

4949
def test_get_episodes_playlist(self, yt_brand):
5050
playlist = yt_brand.get_episodes_playlist()

ytmusicapi/mixins/podcasts.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,14 @@ def get_episode(self, videoId: str) -> JsonDict:
224224
header = nav(two_columns, [*TAB_CONTENT, *SECTION_LIST_ITEM, *RESPONSIVE_HEADER])
225225
episode = parse_episode_header(header)
226226

227+
episode["description"] = None
227228
description_runs = nav(
228-
two_columns, ["secondaryContents", *SECTION_LIST_ITEM, *DESCRIPTION_SHELF, "description", "runs"]
229+
two_columns,
230+
["secondaryContents", *SECTION_LIST_ITEM, *DESCRIPTION_SHELF, "description", "runs"],
231+
True,
229232
)
230-
episode["description"] = Description.from_runs(description_runs)
233+
if description_runs:
234+
episode["description"] = Description.from_runs(description_runs)
231235

232236
return episode
233237

0 commit comments

Comments
 (0)