@@ -836,20 +836,26 @@ def post_process(self, filename, ie_info):
836
836
except (IOError , OSError ):
837
837
self .report_warning (u'Unable to remove downloaded video file' )
838
838
839
- def in_download_archive (self , info_dict ):
840
- fn = self .params .get ('download_archive' )
841
- if fn is None :
842
- return False
843
- extractor = info_dict .get ('extractor_id' )
839
+ def _make_archive_id (self , info_dict ):
840
+ # Future-proof against any change in case
841
+ # and backwards compatibility with prior versions
842
+ extractor = info_dict .get ('extractor' )
844
843
if extractor is None :
845
844
if 'id' in info_dict :
846
845
extractor = info_dict .get ('ie_key' ) # key in a playlist
847
846
if extractor is None :
847
+ return None # Incomplete video information
848
+ return extractor .lower () + u' ' + info_dict ['id' ]
849
+
850
+ def in_download_archive (self , info_dict ):
851
+ fn = self .params .get ('download_archive' )
852
+ if fn is None :
853
+ return False
854
+
855
+ vid_id = self ._make_archive_id (info_dict )
856
+ if vid_id is None :
848
857
return False # Incomplete video information
849
- # Future-proof against any change in case
850
- # and backwards compatibility with prior versions
851
- extractor = extractor .lower ()
852
- vid_id = extractor + u' ' + info_dict ['id' ]
858
+
853
859
try :
854
860
with locked_file (fn , 'r' , encoding = 'utf-8' ) as archive_file :
855
861
for line in archive_file :
@@ -864,7 +870,8 @@ def record_download_archive(self, info_dict):
864
870
fn = self .params .get ('download_archive' )
865
871
if fn is None :
866
872
return
867
- vid_id = info_dict ['extractor' ] + u' ' + info_dict ['id' ]
873
+ vid_id = self ._make_archive_id (info_dict )
874
+ assert vid_id
868
875
with locked_file (fn , 'a' , encoding = 'utf-8' ) as archive_file :
869
876
archive_file .write (vid_id + u'\n ' )
870
877
0 commit comments