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"))
selected_posts = e621.select_posts(query, exclude_unknown_tags=True)

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 = get_captions(
    selected_posts, tags,
    naming='id',
    remove_underscores=True,
    tags_to_head=('kisha', 'kisha (character)')
)
write_captions(captions, target_directory)

counts_csv = target_directory / 'tags.csv'
counts = selected_posts.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.1a5.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

glutamate-0.0.1a5-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for glutamate-0.0.1a5.tar.gz
Algorithm Hash digest
SHA256 bd4f6e97b55d4054364b9b0acba14bc1966c36a4e2680834cac21065db8f0221
MD5 cdc8178337a543baa055bad02296e647
BLAKE2b-256 885db991a8d7b72631b9d4610d5816a3799d748b501a57a169284efbf7f2856f

See more details on using hashes here.

Provenance

File details

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

File metadata

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

File hashes

Hashes for glutamate-0.0.1a5-py3-none-any.whl
Algorithm Hash digest
SHA256 e22f43bd84e3d1ef141d03cc719a9a67466d3a0db0a82d6051e7847c03843a79
MD5 5006a3374702bf878bccd9d8edf31cec
BLAKE2b-256 ea8c97341bb3ed2858fedb0b10de75f83e98845ee9f1888b4fd1e68f4ed94760

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