Add BitChute to URL pre-check; generalize code a bit

pull/178/head
Jody Bruchon 5 years ago
parent a7c901cbbe
commit 4e95d845f7

@ -2204,15 +2204,28 @@ class YoutubeDL(object):
self.archive.add(vid_id) self.archive.add(vid_id)
def url_archive_precheck(self, url): def url_archive_precheck(self, url):
# Check YouTube single video downloads in archive before any web page access # Check single video downloads in archive (if possible) before any web page access
if re.match("^https://[a-zA-Z.]*youtube.com/", url): ie_key = None
if re.match("^https://[0-9a-zA-Z.]*bitchute.com/video/", url):
temp_id = url.split("/video/")
if len(temp_id) == 2:
ie_key = "bitchute"
temp_id = temp_id[1].split("&")[0]
temp_id = temp_id.split("/")[0]
temp_id = temp_id.split("?")[0]
elif re.match("^https://[0-9a-zA-Z.]*youtube.com/", url):
temp_id = url.split("?v=") temp_id = url.split("?v=")
if len(temp_id) == 1:
temp_id = url.split("&v=")
if len(temp_id) == 2: if len(temp_id) == 2:
ie_key = "youtube"
temp_id = temp_id[1].split("&")[0] temp_id = temp_id[1].split("&")[0]
temp_info_dict = {'id': temp_id, 'ie_key': "youtube"} # ie_key should only be set if an archive check should be done
if self.in_download_archive(temp_info_dict): if ie_key is not None:
reason = "[download] [youtube] ID %s has already been recorded in archive" % temp_id temp_info_dict = {'id': temp_id, 'ie_key': ie_key}
return reason if self.in_download_archive(temp_info_dict):
reason = "[download] [%s] ID %s has already been recorded in archive" % (ie_key, temp_id)
return reason
return None return None
@staticmethod @staticmethod

Loading…
Cancel
Save