improve extractor.get_downloader()
This commit is contained in:
@@ -267,15 +267,16 @@ class DownloadJob(Job):
|
|||||||
|
|
||||||
def get_downloader(self, url):
|
def get_downloader(self, url):
|
||||||
"""Return, and possibly construct, a downloader suitable for 'url'"""
|
"""Return, and possibly construct, a downloader suitable for 'url'"""
|
||||||
pos = url.find(":")
|
scheme = url.partition(":")[0]
|
||||||
scheme = url[:pos] if pos != -1 else "http"
|
|
||||||
if scheme == "https":
|
if scheme == "https":
|
||||||
scheme = "http"
|
scheme = "http"
|
||||||
instance = self.downloaders.get(scheme)
|
try:
|
||||||
if instance is None:
|
return self.downloaders[scheme]
|
||||||
klass = downloader.find(scheme)
|
except KeyError:
|
||||||
instance = klass(self.extractor.session, self.out)
|
pass
|
||||||
self.downloaders[scheme] = instance
|
klass = downloader.find(scheme)
|
||||||
|
instance = klass(self.extractor.session, self.out)
|
||||||
|
self.downloaders[scheme] = instance
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user