1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-25 04:02:32 +01:00

fix issues with 'Extractor.finalize()'

- prevent crash in InstagramUserExtractor (#4359)
- call it at the end of every DownloadJob
- add it to tests
This commit is contained in:
Mike Fährmann 2023-07-29 13:43:27 +02:00
parent ed21908fda
commit 48ef062867
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
4 changed files with 8 additions and 3 deletions

View File

@ -36,7 +36,6 @@ class Extractor():
browser = None
root = ""
test = None
finalize = None
request_interval = 0.0
request_interval_min = 0.0
request_timestamp = 0.0
@ -66,6 +65,9 @@ class Extractor():
self._init()
self.initialize = util.noop
def finalize(self):
pass
def items(self):
yield Message.Version, 1

View File

@ -405,6 +405,9 @@ class InstagramUserExtractor(InstagramExtractor):
def initialize(self):
pass
def finalize(self):
pass
def items(self):
base = "{}/{}/".format(self.root, self.item)
stories = "{}/stories/{}/".format(self.root, self.item)

View File

@ -140,8 +140,7 @@ class Job():
log.info("No results for %s", extractor.url)
finally:
self.handle_finalize()
if extractor.finalize:
extractor.finalize()
extractor.finalize()
return self.status

View File

@ -138,6 +138,7 @@ class TestExtractorModule(unittest.TestCase):
for test in cls._get_tests():
extr = cls.from_url(test[0])
extr.initialize()
extr.finalize()
break
def test_docstrings(self):