Skip to content

Instantly share code, notes, and snippets.

@mikf
Last active January 23, 2018 05:38
Show Gist options
  • Select an option

  • Save mikf/052916c25a9bda7d6876a355cacbe88f to your computer and use it in GitHub Desktop.

Select an option

Save mikf/052916c25a9bda7d6876a355cacbe88f to your computer and use it in GitHub Desktop.
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