diff options
author | Yen Chi Hsuan <yan12125@gmail.com> | 2016-06-11 23:00:44 +0800 |
---|---|---|
committer | Yen Chi Hsuan <yan12125@gmail.com> | 2016-06-11 23:00:44 +0800 |
commit | 6d28c408cfb0ce42f591cc6e2bb67522c0812c72 (patch) | |
tree | 0ae50c25fe4148c3e9d67fcc4927d07f4e5387b7 | |
parent | c83b35d4aa4cec98ac171cca94ec515500076926 (diff) |
[viki] Do not use a fallback language for title in the first try
In test_Viki_3, 'titles' gives a Hebrew title.
-rw-r--r-- | youtube_dl/extractor/viki.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/youtube_dl/extractor/viki.py b/youtube_dl/extractor/viki.py index 70ce5de0e..efa15e0b6 100644 --- a/youtube_dl/extractor/viki.py +++ b/youtube_dl/extractor/viki.py @@ -101,10 +101,13 @@ class VikiBaseIE(InfoExtractor): self.report_warning('Unable to get session token, login has probably failed') @staticmethod - def dict_selection(dict_obj, preferred_key): + def dict_selection(dict_obj, preferred_key, allow_fallback=True): if preferred_key in dict_obj: return dict_obj.get(preferred_key) + if not allow_fallback: + return + filtered_dict = list(filter(None, [dict_obj.get(k) for k in dict_obj.keys()])) return filtered_dict[0] if filtered_dict else None @@ -218,7 +221,7 @@ class VikiIE(VikiBaseIE): self._check_errors(video) - title = self.dict_selection(video.get('titles', {}), 'en') + title = self.dict_selection(video.get('titles', {}), 'en', allow_fallback=False) if not title: title = 'Episode %d' % video.get('number') if video.get('type') == 'episode' else video.get('id') or video_id container_titles = video.get('container', {}).get('titles', {}) |