Last active
January 23, 2018 05:38
-
-
Save mikf/052916c25a9bda7d6876a355cacbe88f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from gallery_dl.job import Job, Message | |
| class CacheJob(Job): | |
| def __init__(self, url, parent=None): | |
| Job.__init__(self, url, parent) | |
| self.data = [] | |
| def run(self): | |
| for msg in self.extractor: | |
| self.data.append([ | |
| e.copy() if hasattr(e, "copy") else e | |
| for e in msg | |
| ]) | |
| url = "http://example.org" | |
| j = CacheJob(url) | |
| j.run() | |
| # j.data now contains a cached version | |
| # of its extractor's results | |
| for msg in j.data: | |
| # do stuff with cached data | |
| if msg[0] != Message.Url: | |
| pass | |
| ##################################### | |
| # If you only want the extractor results and nothing else: | |
| from gallery_dl import extractor | |
| data = [] | |
| for msg in (extractor.find(url) or []): | |
| data.append([ | |
| e.copy() if hasattr(e, "copy") else e | |
| for e in msg | |
| ]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment