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
Release history Release notifications | RSS feed
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.1a7.tar.gz
(13.8 kB
view details)
Built Distribution
File details
Details for the file glutamate-0.0.1a7.tar.gz
.
File metadata
- Download URL: glutamate-0.0.1a7.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50ae4b052d57a8e2b37892e7973f9f18fc04dd7107007b59bfeebe17429bd619 |
|
MD5 | 80298f0a42af72a83db1dce9b6f13fcf |
|
BLAKE2b-256 | c509abaf474669421b1f787be0d0f79f49949a2ba54692fd9c658df7a090a518 |
File details
Details for the file glutamate-0.0.1a7-py3-none-any.whl
.
File metadata
- Download URL: glutamate-0.0.1a7-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e32695182766d65a500615fba76001d732856d765b001a6dbc8131ea6d9bfeb0 |
|
MD5 | c50d61671839c2a5961806261614d34d |
|
BLAKE2b-256 | 85f07ae0a6d79e23c1dcece07971eb22431bb8ee64ef7023ab505832907d1cb6 |