Skip to content

Commit

Permalink
improve extractor.get_downloader()
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Sep 5, 2018
1 parent eb3185d commit 41249f3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions gallery_dl/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,16 @@ def handle_finalize(self):

def get_downloader(self, url):
"""Return, and possibly construct, a downloader suitable for 'url'"""
pos = url.find(":")
scheme = url[:pos] if pos != -1 else "http"
scheme = url.partition(":")[0]
if scheme == "https":
scheme = "http"
instance = self.downloaders.get(scheme)
if instance is None:
klass = downloader.find(scheme)
instance = klass(self.extractor.session, self.out)
self.downloaders[scheme] = instance
try:
return self.downloaders[scheme]
except KeyError:
pass
klass = downloader.find(scheme)
instance = klass(self.extractor.session, self.out)
self.downloaders[scheme] = instance
return instance


Expand Down

0 comments on commit 41249f3

Please sign in to comment.