fix: don't crash if playlists / history file has invalid youtube id fixed #24

Esse commit está contido em:
Talha Asghar
2022-02-19 10:29:53 +05:00
commit 323d5d822c
2 arquivos alterados com 6 adições e 6 exclusões
-2
Ver Arquivo
@@ -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():
+6 -4
Ver Arquivo
@@ -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)