# `gallery-dl-bytes`
[<img alt="UV Badge" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fastral-sh%2Fuv%2Frefs%2Fheads%2Fmain%2Fassets%2Fbadge%2Fv0.json&style=for-the-badge">](https://docs.astral.sh/uv/)
[<img alt="Python Version Badge" src="https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fthcrt%2Fgallery-dl-bytes%2Frefs%2Fheads%2Fmain%2Fpyproject.toml&style=for-the-badge">](#)
[<img alt="PyPI Downloads Badge" src="https://img.shields.io/pypi/dm/gallery-dl-bytes?style=for-the-badge&color=blue">](https://pypi.org/project/gallery-dl-bytes/)
[<img alt="License Badge" src="https://img.shields.io/pypi/l/gallery-dl-bytes?style=for-the-badge&color=blue">](./LICENSE)
[<img alt="Build Status Badge" src="https://img.shields.io/github/actions/workflow/status/thcrt/gallery-dl-bytes/publish.yml?event=release&style=for-the-badge">](https://github.com/thcrt/gallery-dl-bytes/actions/workflows/publish.yml)
[<img alt="Maintenance Status Badge" src="https://img.shields.io/maintenance/yes/2025?style=for-the-badge">](https://github.com/thcrt/gallery-dl-bytes/pulse)
[<img alt="Free Palestine Badge" src="https://img.shields.io/badge/Free%20-%20Palestine%20-%20red?style=for-the-badge">](https://bdsmovement.net/)
Programmatically run `gallery-dl` extractors to download content from the web directly to a `bytes` object in memory. With an easy, fully typed API.
<p align="center"><a href="https://github.com/thcrt/gallery-dl-bytes/"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" height="1em" width="1em" fill="currentcolor"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M64 0C28.7 0 0 28.7 0 64L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-288-128 0c-17.7 0-32-14.3-32-32L224 0 64 0zM256 0l0 128 128 0L256 0zM153 289l-31 31 31 31c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0L71 337c-9.4-9.4-9.4-24.6 0-33.9l48-48c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9zM265 255l48 48c9.4 9.4 9.4 24.6 0 33.9l-48 48c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l31-31-31-31c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0z"/></svg> <b>Source</b></a> | <a href="https://pypi.org/project/gallery-dl-bytes/"><svg viewBox="0 0 512 454" width="1em" height="1em" fill="currentcolor" xmlns="http://www.w3.org/2000/svg"><!-- PyPI icon from the File-Icons set - https://github.com/file-icons/icons/ --><path d="m454 305.8294373-91.1191101 33.691803v106.4807434l-180.9360199 65.9980163v-213.7029724l179.8842926-66.8633728v-172.609642l92.1708374 33.6728515zm-177.1609497 57.5555114c-15.7174377 5.7245483-28.4572144 23.9239502-28.4515686 40.6481018.0061646 16.7174377 12.7523499 25.6329346 28.4636841 19.919281 15.7173462-5.7247009 28.4602051-23.9217834 28.4544983-40.6459656-.0026551-16.7253112-12.749115-25.6428222-28.4666138-19.9214172zm57.7770386-150.8851623-180.3925323 66.8782959.2966461 135.7604065-64.2104874 22.9912415-90.3097153-32.8702699v-213.3329162l90.704361-33.6917877v-106.4804306l142.2673492-51.7543259 101.6443787 32.4636765zm-119.4016114-117.6667481c-15.7174835 5.7222672-28.4621582 23.9249802-28.458725 40.6499329.0025787 16.725235 12.750824 25.6462555 28.4683228 19.9248505 15.7174988-5.7219086 28.4623871-23.9248047 28.4592285-40.6498184-.0026397-16.7253037-12.7513275-25.64637-28.4688263-19.924965z"/></svg> <b>PyPI</b></a></p>
## Installation
### With `uv` (recommended)
```shell
uv add gallery-dl-bytes
```
### With `pip`
```shell
pip install gallery-dl-bytes
```
## Usage
### Single item
```python
from gallery_dl_bytes import DownloadJob
url = "https://www.reddit.com/r/me_irl/comments/1f4qc59/me_irl/"
job = DownloadJob(url)
job.run()
post = job.files[0]
print(f"{post.name}")
print(post.headers.get("Content-Type"))
print(post.metadata.get("author"))
```
### Gallery
```python
job = DownloadJob("https://imgur.com/gallery/dog-3s8hj1j")
job.run()
for file in job.files:
print(f"{file.name}")
print(file.headers.get("Last-Modified"))
print(file.metadata.get("created_at"))
print()
```
### Access media
```python
from pathlib import Path
job = DownloadJob("https://www.pexels.com/photo/man-riding-white-surfboard-1005456/")
job.run()
file = job.files[0]
Path(file.name).write_bytes(file.data)
```
### Access posts without media
```python
job = DownloadJob("https://bsky.app/profile/dril.bsky.social/post/3lia54f7fg22x")
job.run()
print(job.metadata.get("text"))
```
### Set `gallery-dl` configuration
> [!WARNING]
> Note that not all configuration is supported. Options may be silently ignored. This feature is not yet complete.
```python
from gallery_dl_bytes import set_config
set_config(("extractor",), "browser", "firefox")
```
Raw data
{
"_id": null,
"home_page": null,
"name": "gallery-dl-bytes",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "crawler, downloader, gallery, image, scraper",
"author": null,
"author_email": "thcrt <110127860+thcrt@users.noreply.github.com>",
"download_url": "https://files.pythonhosted.org/packages/2b/0b/bced19418df26ec8908c5981eb2a382d4b2246b73887fa13df31d21d2e28/gallery_dl_bytes-2.4.0.tar.gz",
"platform": null,
"description": "# `gallery-dl-bytes`\n\n[<img alt=\"UV Badge\" src=\"https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fastral-sh%2Fuv%2Frefs%2Fheads%2Fmain%2Fassets%2Fbadge%2Fv0.json&style=for-the-badge\">](https://docs.astral.sh/uv/)\n[<img alt=\"Python Version Badge\" src=\"https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fthcrt%2Fgallery-dl-bytes%2Frefs%2Fheads%2Fmain%2Fpyproject.toml&style=for-the-badge\">](#)\n[<img alt=\"PyPI Downloads Badge\" src=\"https://img.shields.io/pypi/dm/gallery-dl-bytes?style=for-the-badge&color=blue\">](https://pypi.org/project/gallery-dl-bytes/)\n[<img alt=\"License Badge\" src=\"https://img.shields.io/pypi/l/gallery-dl-bytes?style=for-the-badge&color=blue\">](./LICENSE)\n\n[<img alt=\"Build Status Badge\" src=\"https://img.shields.io/github/actions/workflow/status/thcrt/gallery-dl-bytes/publish.yml?event=release&style=for-the-badge\">](https://github.com/thcrt/gallery-dl-bytes/actions/workflows/publish.yml)\n[<img alt=\"Maintenance Status Badge\" src=\"https://img.shields.io/maintenance/yes/2025?style=for-the-badge\">](https://github.com/thcrt/gallery-dl-bytes/pulse)\n[<img alt=\"Free Palestine Badge\" src=\"https://img.shields.io/badge/Free%20-%20Palestine%20-%20red?style=for-the-badge\">](https://bdsmovement.net/)\n\nProgrammatically run `gallery-dl` extractors to download content from the web directly to a `bytes` object in memory. With an easy, fully typed API.\n\n<p align=\"center\"><a href=\"https://github.com/thcrt/gallery-dl-bytes/\"><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 384 512\" height=\"1em\" width=\"1em\" fill=\"currentcolor\"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d=\"M64 0C28.7 0 0 28.7 0 64L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-288-128 0c-17.7 0-32-14.3-32-32L224 0 64 0zM256 0l0 128 128 0L256 0zM153 289l-31 31 31 31c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0L71 337c-9.4-9.4-9.4-24.6 0-33.9l48-48c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9zM265 255l48 48c9.4 9.4 9.4 24.6 0 33.9l-48 48c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l31-31-31-31c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0z\"/></svg> <b>Source</b></a> | <a href=\"https://pypi.org/project/gallery-dl-bytes/\"><svg viewBox=\"0 0 512 454\" width=\"1em\" height=\"1em\" fill=\"currentcolor\" xmlns=\"http://www.w3.org/2000/svg\"><!-- PyPI icon from the File-Icons set - https://github.com/file-icons/icons/ --><path d=\"m454 305.8294373-91.1191101 33.691803v106.4807434l-180.9360199 65.9980163v-213.7029724l179.8842926-66.8633728v-172.609642l92.1708374 33.6728515zm-177.1609497 57.5555114c-15.7174377 5.7245483-28.4572144 23.9239502-28.4515686 40.6481018.0061646 16.7174377 12.7523499 25.6329346 28.4636841 19.919281 15.7173462-5.7247009 28.4602051-23.9217834 28.4544983-40.6459656-.0026551-16.7253112-12.749115-25.6428222-28.4666138-19.9214172zm57.7770386-150.8851623-180.3925323 66.8782959.2966461 135.7604065-64.2104874 22.9912415-90.3097153-32.8702699v-213.3329162l90.704361-33.6917877v-106.4804306l142.2673492-51.7543259 101.6443787 32.4636765zm-119.4016114-117.6667481c-15.7174835 5.7222672-28.4621582 23.9249802-28.458725 40.6499329.0025787 16.725235 12.750824 25.6462555 28.4683228 19.9248505 15.7174988-5.7219086 28.4623871-23.9248047 28.4592285-40.6498184-.0026397-16.7253037-12.7513275-25.64637-28.4688263-19.924965z\"/></svg> <b>PyPI</b></a></p>\n\n\n## Installation\n\n### With `uv` (recommended)\n\n```shell\nuv add gallery-dl-bytes\n```\n\n### With `pip`\n\n```shell\npip install gallery-dl-bytes\n```\n\n## Usage\n\n### Single item\n\n```python\nfrom gallery_dl_bytes import DownloadJob\n\nurl = \"https://www.reddit.com/r/me_irl/comments/1f4qc59/me_irl/\"\n\njob = DownloadJob(url)\njob.run()\npost = job.files[0]\n\nprint(f\"{post.name}\")\nprint(post.headers.get(\"Content-Type\"))\nprint(post.metadata.get(\"author\"))\n```\n\n### Gallery\n\n```python\njob = DownloadJob(\"https://imgur.com/gallery/dog-3s8hj1j\")\njob.run()\n\nfor file in job.files:\n print(f\"{file.name}\")\n print(file.headers.get(\"Last-Modified\"))\n print(file.metadata.get(\"created_at\"))\n print()\n```\n\n### Access media\n\n```python\nfrom pathlib import Path\n\njob = DownloadJob(\"https://www.pexels.com/photo/man-riding-white-surfboard-1005456/\")\njob.run()\n\nfile = job.files[0]\nPath(file.name).write_bytes(file.data)\n```\n\n### Access posts without media\n\n```python\njob = DownloadJob(\"https://bsky.app/profile/dril.bsky.social/post/3lia54f7fg22x\")\njob.run()\n\nprint(job.metadata.get(\"text\"))\n```\n\n### Set `gallery-dl` configuration\n\n> [!WARNING] \n> Note that not all configuration is supported. Options may be silently ignored. This feature is not yet complete.\n\n```python\nfrom gallery_dl_bytes import set_config\n\nset_config((\"extractor\",), \"browser\", \"firefox\")\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "API to download files directly to memory with gallery-dl",
"version": "2.4.0",
"project_urls": {
"Issues": "https://github.com/thcrt/gallery-dl-bytes/issues/",
"PyPI": "https://pypi.org/project/gallery-dl-bytes/",
"Source": "https://github.com/thcrt/gallery-dl-bytes/"
},
"split_keywords": [
"crawler",
" downloader",
" gallery",
" image",
" scraper"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "6f6f390b0a31c62e9bf8d16f7ab6b1cdbb09bba71bc096936244e8a92c2d3ed6",
"md5": "73d0e763585ec1288388a40c2bca2eba",
"sha256": "a1f69655cc1b22a421795254990cf63346a9f536698b2d4fe66c8b1634be7678"
},
"downloads": -1,
"filename": "gallery_dl_bytes-2.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "73d0e763585ec1288388a40c2bca2eba",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 17557,
"upload_time": "2025-02-17T19:41:07",
"upload_time_iso_8601": "2025-02-17T19:41:07.820074Z",
"url": "https://files.pythonhosted.org/packages/6f/6f/390b0a31c62e9bf8d16f7ab6b1cdbb09bba71bc096936244e8a92c2d3ed6/gallery_dl_bytes-2.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "2b0bbced19418df26ec8908c5981eb2a382d4b2246b73887fa13df31d21d2e28",
"md5": "5a9bbc52e9e21eddb2e77e3a0ecfd296",
"sha256": "f1e1e5d842d0dbdc43209d14f63bfe9cbf1f74e363b6dc10381b4a9203bc013c"
},
"downloads": -1,
"filename": "gallery_dl_bytes-2.4.0.tar.gz",
"has_sig": false,
"md5_digest": "5a9bbc52e9e21eddb2e77e3a0ecfd296",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 37614,
"upload_time": "2025-02-17T19:41:09",
"upload_time_iso_8601": "2025-02-17T19:41:09.675253Z",
"url": "https://files.pythonhosted.org/packages/2b/0b/bced19418df26ec8908c5981eb2a382d4b2246b73887fa13df31d21d2e28/gallery_dl_bytes-2.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-17 19:41:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "thcrt",
"github_project": "gallery-dl-bytes",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "gallery-dl-bytes"
}