nyaascraper is an asynchronous Python library for scraping nyaa.si and sukebei.nyaa.si.
Project description
nyaascraper
nyaascraper
is an asynchronous Python library for scraping nyaa.si and sukebei.nyaa.si.
Installation
Installing through pip:
pip install nyaascraper
Usage
Initializing Client with Site
By default, the site is nyaa.si (work-safe site).
from nyaascraper import NyaaClient, SITE
# Work-safe site. (Default)
client = NyaaClient(SITE.FUN)
# Non-work-safe site.
client = NyaaClient(SITE.FAP)
Changing Site
Changing the site of the client dynamically.
from nyaascraper import SITE
client.site = SITE.FUN
Searching Torrents
Search with Term
from nyaascraper.models import SearchResult
result: SearchResult = await client.search(term="...")
print(result)
for torrent in result.torrents:
print(torrent)
Search by Username
result = await client.search(username="...")
print(result)
Search with Quality Filter
from nyaascraper import QualityFilter
# No Filter. (Default)
result = await client.search(quality_filter=QualityFilter.NO_FILTER)
print(result)
# Trusted only.
result = await client.search(quality_filter=QualityFilter.TRUSTED_ONLY)
print(result)
# No Remakes.
result = await client.search(quality_filter=QualityFilter.NO_REMAKES)
print(result)
Search with Category
from nyaascraper.enums import FunCategory, FapCategory
# Work-safe category.
result = await client.search(category=FunCategory.ANIME)
print(result)
# Work-safe subcategory search.
result = await client.search(category=FunCategory.ANIME_ENGLISH_TRANSLATED)
print(result)
# Non-work-safe category.
result = await client.search(category=FapCategory.ART)
print(result)
# Non-work-safe subcategory search.
result = await client.search(category=FapCategory.ART_MANGA)
print(result)
Search with Sorting
from nyaascraper.enums import SortBy, SortOrder
# Sort by comments.
result = await client.search(sort_by=SortBy.COMMENTS)
print(result)
# Sort by size.
result = await client.search(sort_by=SortBy.SIZE)
print(result)
# Sort by date.
result = await client.search(sort_by=SortBy.DATE)
print(result)
# Sort by seeders.
result = await client.search(sort_by=SortBy.SEEDERS)
print(result)
# Sort by leechers.
result = await client.search(sort_by=SortBy.LEECHERS)
print(result)
# Sort by downloads.
result = await client.search(sort_by=SortBy.DOWNLOADS)
print(result)
# Sort order: Ascending.
result = await client.search(sort_order=SortOrder.ASCENDING)
print(result)
# Sort order: Descending.
result = await client.search(sort_order=SortOrder.DESCENDING)
print(result)
Search by Page
result = await client.search(page=2)
print(result)
Getting Torrent Information
from nyaascraper.models import TorrentInfo
result = await client.search()
# Select View-ID of the first torrent from the search result.
view_id: int = result.torrents[0].view_id
torrent_info: TorrentInfo = await client.get_torrent_info(view_id)
print(torrent_info)
RSS Feed
Initializing Client with Site
By default, the site is nyaa.si (work-safe site).
from nyaascraper import NyaaRSSClient, SITE
# Work-safe site. (Default)
client = NyaaRSSClient(SITE.FUN)
# Non-work-safe site.
client = NyaaRSSClient(SITE.FAP)
Changing Site
Changing the site of the client dynamically.
from nyaascraper import SITE
client.site = SITE.FUN
Get RSS feed
from nyaascraper.models import NyaaRSSFeed
feed: NyaaRSSFeed = await client.get_feed()
print("Title:", feed.title)
print("Description:", feed.description)
for torrent in feed.torrents:
print(torrent)
Get RSS Feed with Magnet Links Only
feed = await client.get_feed(use_magnets=True)
License
© 2023-2024 Zrekryu. Licensed under MIT License. See the LICENSE file for details.
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
nyaascraper-1.0.5.tar.gz
(10.1 kB
view details)
Built Distribution
File details
Details for the file nyaascraper-1.0.5.tar.gz
.
File metadata
- Download URL: nyaascraper-1.0.5.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2e40d6391c4c3ba3ed32f972ab6d27c483699f362a6bc78b4485b108b3e0810 |
|
MD5 | 9ce693c9acc768cdd49c45f1f79c4445 |
|
BLAKE2b-256 | bc83cc91a26255412ab280168b92ffcc8b358cf5ae524f98f7a3afc6decbdeda |
File details
Details for the file nyaascraper-1.0.5-py3-none-any.whl
.
File metadata
- Download URL: nyaascraper-1.0.5-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c650c2e61a96d03f016d87f640a2c019437cee3cfeecaa81e47828f9baadf17 |
|
MD5 | 97c13dcfd12ea248080c3ff54e57de18 |
|
BLAKE2b-256 | af1a786dab7890a08aff271680f240f4103b598b9b998f401eb0b8a8738d75aa |