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 qulified file paths
e621_data_directory = Path('./e621-data/')
posts_csv = e621_data_directory / 'posts-2023-04-07.csv'
posts = E621PostsCSV(posts_csv)
tags_csv = e621_data_directory / 'tags-2023-04-04.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)
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
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.1a2.tar.gz
(2.1 kB
view details)
Built Distribution
File details
Details for the file glutamate-0.0.1a2.tar.gz
.
File metadata
- Download URL: glutamate-0.0.1a2.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d1d35d6030bc664be3ae8901eae2a4585ac34050a447bf6e324c887a250b92a |
|
MD5 | 2eab91de3ac94c85adf6d18dae5c9efa |
|
BLAKE2b-256 | 60bed6fb26cb967d5f6192bed52aa078c758aab242992429cd352250d404b145 |
Provenance
File details
Details for the file glutamate-0.0.1a2-py3-none-any.whl
.
File metadata
- Download URL: glutamate-0.0.1a2-py3-none-any.whl
- Upload date:
- Size: 1.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53dad706d209ddf5989ec885ad2177e65aa469c6eda113e42d6c63770accfb26 |
|
MD5 | 8211707fdbff7b394ba104c63eee3f1e |
|
BLAKE2b-256 | b7f40ab8d900cf1be88fdaa664e837a3ff3750cebdab9cdec50bf925f05d00fc |