Skip to content

Commit 5db07df

Browse files
committed
Fix --download-archive (Fixes ytdl-org#1826)
1 parent ea36cba commit 5db07df

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

youtube_dl/YoutubeDL.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -836,20 +836,26 @@ def post_process(self, filename, ie_info):
836836
except (IOError, OSError):
837837
self.report_warning(u'Unable to remove downloaded video file')
838838

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')
844843
if extractor is None:
845844
if 'id' in info_dict:
846845
extractor = info_dict.get('ie_key') # key in a playlist
847846
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:
848857
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+
853859
try:
854860
with locked_file(fn, 'r', encoding='utf-8') as archive_file:
855861
for line in archive_file:
@@ -864,7 +870,8 @@ def record_download_archive(self, info_dict):
864870
fn = self.params.get('download_archive')
865871
if fn is None:
866872
return
867-
vid_id = info_dict['extractor'] + u' ' + info_dict['id']
873+
vid_id = self._make_archive_id(info_dict)
874+
assert vid_id
868875
with locked_file(fn, 'a', encoding='utf-8') as archive_file:
869876
archive_file.write(vid_id + u'\n')
870877

0 commit comments

Comments
 (0)