error handeling in _normalize_lang to skip livechat and ignore missing

This commit is contained in:
simon 2022-02-05 22:51:38 +07:00
parent f5f46349b2
commit 2bf9e9683b
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

View File

@ -71,10 +71,15 @@ class YoutubeSubtitle:
def _normalize_lang(self): def _normalize_lang(self):
"""normalize country specific language keys""" """normalize country specific language keys"""
all_subtitles = self.youtube_meta.get("subtitles") all_subtitles = self.youtube_meta.get("subtitles")
if not all_subtitles:
return False
all_keys = list(all_subtitles.keys()) all_keys = list(all_subtitles.keys())
for key in all_keys: for key in all_keys:
lang = key.split("-")[0] lang = key.split("-")[0]
old = all_subtitles.pop(key) old = all_subtitles.pop(key)
if lang == "live_chat":
continue
all_subtitles[lang] = old all_subtitles[lang] = old
return all_subtitles return all_subtitles