Skip to content

Save downloaded media in memory via Python API #6932

@thcrt

Description

@thcrt

Using gallery-dl programmatically as a Python module, I can of course download to a file like normal, as shown in #642:

>>> import gallery_dl as dl
>>> job = dl.job.DownloadJob('https://www.reddit.com/r/aww/comments/1igojpv/this_loafingblepping_cat_in_istanbul/')
>>> job.run()
./gallery-dl/reddit/aww/1igojpv This loafing_blepping cat in Istanbul.jpg
0

I can then see the metadata:

>>> meta = list(job.extractor.items())[0][1]
>>> print(meta["title"])
This loafing/blepping cat in Istanbul

But the media itself is still saved to a file on disk, in this case ./gallery-dl/reddit/aww/1igojpv This loafing_blepping cat in Istanbul.jpg.

Is there a way to instead save the media to a BytesIO object or similar?

My goal is to then save the raw data to a database, and this would mean I could avoid the extra steps of writing and then reading and then deleting the saved file on disc.

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions