Skip to main content

Python library for querying and downloading posts from e621

Project description

glutamate

Easy to use Python library for querying and downloading posts from e621.net.

Installation

pip install glutamate

Example

from pathlib import Path

from glutamate.database import E621, E621Data, E621PostsCSV, E621TagsCSV, Query, autoinit_from_directory
from glutamate.dataset import get_captions, write_captions, write_stats
from glutamate.download import download_posts


# Init with qualified file paths
e621_data_directory = Path('./e621-data/')
posts_csv = e621_data_directory / 'posts.csv'
posts = E621PostsCSV(posts_csv)
tags_csv = e621_data_directory / 'tags.csv'
tags = E621TagsCSV(tags_csv)
e621: E621 = E621Data(posts, tags)

# or simple automatic init with directory contains CSVs
e621_data_directory = Path('./e621-data/')
e621 = autoinit_from_directory(e621_data_directory)

query = Query(("kisha", "solo"))
kisha_dataset = e621.select(query)

target_directory = Path().cwd() / 'tmp' / 'kisha_solo'
target_directory.mkdir(parents=True, exist_ok=True)

results = download_posts(posts, target_directory, naming='id')
failed = [result for result in results if not result.ok]
if failed:
    print(f"Failed to download {len(failed)} posts")

captions = kisha_dataset.get_captions(
    naming='id',
    remove_underscores=True,
    tags_to_head=('kisha', 'kisha (character)')
)
write_captions(captions, target_directory)

counts_csv = target_directory / 'tags.csv'
counts = kisha_dataset.get_tags_stats()
write_stats(counts, counts_csv)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glutamate-0.0.1a6.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

glutamate-0.0.1a6-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file glutamate-0.0.1a6.tar.gz.

File metadata

  • Download URL: glutamate-0.0.1a6.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for glutamate-0.0.1a6.tar.gz
Algorithm Hash digest
SHA256 4b15ffdf9b6970779d899ddd6f1cd6e0b73b75e4a44e0d3f78ac8b270795ae33
MD5 b3a82ac7a07970dbd290b663f989c0c7
BLAKE2b-256 9ba221a1a6847001c5426ffbcfc5f96ebed5e951d90fc84f8bdef97f2b89b3ab

See more details on using hashes here.

Provenance

File details

Details for the file glutamate-0.0.1a6-py3-none-any.whl.

File metadata

  • Download URL: glutamate-0.0.1a6-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for glutamate-0.0.1a6-py3-none-any.whl
Algorithm Hash digest
SHA256 a175c53ba3dc7323dad182601718a7de265487103fb859e34c95b744a8d0ca56
MD5 ab705eafa657c436230f9f7fb276acec
BLAKE2b-256 2e627ee57e2002ef43b45f142a1d9786ac280812ec23d91d706c1e5d61e1064a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page