##// END OF EJS Templates
Do not run validation on files while performing sync
neko259 -
r1833:3c5ca02b default
parent child Browse files
Show More
@@ -30,15 +30,15 b' class Downloader:'
30 return True
30 return True
31
31
32 @staticmethod
32 @staticmethod
33 def download(url: str):
33 def download(url: str, validate):
34 # Verify content headers
34 # Verify content headers
35 response_head = requests.head(url, verify=False)
35 response_head = requests.head(url, verify=False)
36 content_type = response_head.headers[HEADER_CONTENT_TYPE].split(';')[0]
36 content_type = response_head.headers[HEADER_CONTENT_TYPE].split(';')[0]
37 if content_type in TYPE_URL_ONLY:
37 if validate and content_type in TYPE_URL_ONLY:
38 return None
38 return None
39
39
40 length_header = response_head.headers.get(HEADER_CONTENT_LENGTH)
40 length_header = response_head.headers.get(HEADER_CONTENT_LENGTH)
41 if length_header:
41 if validate and length_header:
42 length = int(length_header)
42 length = int(length_header)
43 validate_file_size(length)
43 validate_file_size(length)
44 # Get the actual content into memory
44 # Get the actual content into memory
@@ -63,7 +63,7 b' class Downloader:'
63
63
64 class YouTubeDownloader(Downloader):
64 class YouTubeDownloader(Downloader):
65 @staticmethod
65 @staticmethod
66 def download(url: str):
66 def download(url: str, validate):
67 yt = YouTube()
67 yt = YouTube()
68 yt.from_url(url)
68 yt.from_url(url)
69 videos = yt.filter(YOUTUBE_VIDEO_FORMAT)
69 videos = yt.filter(YOUTUBE_VIDEO_FORMAT)
@@ -82,7 +82,7 b' class NothingDownloader(Downloader):'
82 return REGEX_MAGNET.match(url)
82 return REGEX_MAGNET.match(url)
83
83
84 @staticmethod
84 @staticmethod
85 def download(url: str):
85 def download(url: str, validate):
86 return None
86 return None
87
87
88
88
@@ -93,9 +93,9 b' DOWNLOADERS = ('
93 )
93 )
94
94
95
95
96 def download(url):
96 def download(url, validate=True):
97 for downloader in DOWNLOADERS:
97 for downloader in DOWNLOADERS:
98 if downloader.handles(url):
98 if downloader.handles(url):
99 return downloader.download(url)
99 return downloader.download(url, validate=validate)
100 raise Exception('No downloader supports this URL.')
100 raise Exception('No downloader supports this URL.')
101
101
@@ -236,7 +236,7 b' class SyncManager:'
236 tag_ref = tag_refs.find("{}[@ref='{}']".format(
236 tag_ref = tag_refs.find("{}[@ref='{}']".format(
237 TAG_ATTACHMENT_REF, attachment.text))
237 TAG_ATTACHMENT_REF, attachment.text))
238 url = tag_ref.get(ATTR_URL)
238 url = tag_ref.get(ATTR_URL)
239 attached_file = download(hostname + url)
239 attached_file = download(hostname + url, validate=False)
240 if attached_file is None:
240 if attached_file is None:
241 raise SyncException(EXCEPTION_DOWNLOAD)
241 raise SyncException(EXCEPTION_DOWNLOAD)
242
242
General Comments 0
You need to be logged in to leave comments. Login now