Skip to content

Commit

Permalink
fix: don't crash if playlists / history file has invalid youtube id f…
Browse files Browse the repository at this point in the history
…ixed #24
  • Loading branch information
iamtalhaasghar committed Feb 19, 2022
1 parent 16abec6 commit 323d5d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 0 additions & 2 deletions mps_youtube/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ def load():
if not os.path.isfile(g.HISTFILE):
g.userhist = {}
save()
except ValueError as ex:
dbg(c.r + str(ex) + c.w)


def save():
Expand Down
10 changes: 6 additions & 4 deletions mps_youtube/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ def read_m3u(m3u):
duration, title = line.replace('#EXTINF:', '').strip().split(',', 1)
expect_ytid = True
elif not line.startswith('\n') and not line.startswith('#') and expect_ytid:
ytid = pafy.extract_video_id(line).strip()
songs.append(Video(ytid, title, int(duration)))
expect_ytid = False

try:
expect_ytid = False
ytid = pafy.extract_video_id(line).strip()
songs.append(Video(ytid, title, int(duration)))
except ValueError as ex:
util.dbg(c.r + str(ex) + c.w)
# Handles a simple m3u file which should just be a list of urls
else:
plf.seek(0)
Expand Down

0 comments on commit 323d5d8

Please sign in to comment.