pynyaasi.nyaasi

NYAASI_ENDPOINT

pynyaasi.nyaasi.NYAASI_ENDPOINT = 'https://nyaa.si'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

CategoryType

enum pynyaasi.nyaasi.CategoryType(value)[source]

An enumeration.

Member Type:

str

Valid values are as follows:

ALL_CATEGORIES = <CategoryType.ALL_CATEGORIES: '0_0'>
ANIME = <CategoryType.ANIME: '1_0'>
ANIME_AMV = <CategoryType.ANIME_AMV: '1_1'>
ANIME_ENGLISH = <CategoryType.ANIME_ENGLISH: '1_2'>
ANIME_NON_ENGLISH = <CategoryType.ANIME_NON_ENGLISH: '1_3'>
ANIME_RAW = <CategoryType.ANIME_RAW: '1_4'>
AUDIO = <CategoryType.AUDIO: '2_0'>
AUDIO_LOSSLESS = <CategoryType.AUDIO_LOSSLESS: '2_1'>
AUDIO_LOSSY = <CategoryType.AUDIO_LOSSY: '2_2'>
LITERATURE = <CategoryType.LITERATURE: '3_0'>
LITERATURE_ENGLISH = <CategoryType.LITERATURE_ENGLISH: '3_1'>
LITERATURE_NON_ENGLISH = <CategoryType.LITERATURE_NON_ENGLISH: '3_2'>
LITERATURE_RAW = <CategoryType.LITERATURE_RAW: '3_3'>
LIVE_ACTION = <CategoryType.LIVE_ACTION: '4_0'>
LIVE_ACTION_ENGLISH = <CategoryType.LIVE_ACTION_ENGLISH: '4_1'>
LIVE_ACTION_IDOL_PV = <CategoryType.LIVE_ACTION_IDOL_PV: '4_2'>
LIVE_ACTION_NON_ENGLISH = <CategoryType.LIVE_ACTION_NON_ENGLISH: '4_3'>
LIVE_ACTION_RAW = <CategoryType.LIVE_ACTION_RAW: '4_4'>
PICTURES = <CategoryType.PICTURES: '5_0'>
PICTURES_GRAPHICS = <CategoryType.PICTURES_GRAPHICS: '5_1'>
PICTURES_PHOTOS = <CategoryType.PICTURES_PHOTOS: '5_2'>
SOFTWARE = <CategoryType.SOFTWARE: '6_0'>
SOFTWARE_APPS = <CategoryType.SOFTWARE_APPS: '6_1'>
SOFTWARE_GAMES = <CategoryType.SOFTWARE_GAMES: '6_2'>

FilterType

enum pynyaasi.nyaasi.FilterType(value)[source]

An enumeration.

Member Type:

str

Valid values are as follows:

NO_FILTER = <FilterType.NO_FILTER: '0'>
NO_REMAKES = <FilterType.NO_REMAKES: '1'>
TRUSTED_ONLY = <FilterType.TRUSTED_ONLY: '2'>

NyaaSiClient

class pynyaasi.nyaasi.NyaaSiClient(session: Optional[requests.Session] = None)[source]

A client class for accessing the nyaa.si website.

The NyaaSiClient class is a subclass of BaseClient and provides specific functionality for accessing the nyaa.si website.

Parameters:

session (Optional[requests.Session]) – An optional requests.Session object to be used for making HTTP requests.

Variables:
  • __endpoint__ (str) – The base endpoint URL for the nyaa.si website.

  • __filter_class__ (FilterType) – The available filter options for search queries on nyaa.si.

  • __default_filter__ (FilterType) – The default filter option for search queries on nyaa.si.

  • __category_class__ (CategoryType) – The available category options for search queries on nyaa.si.

  • __default_category__ (CategoryType) – The default category option for search queries on nyaa.si.

__init__(session: Optional[requests.Session] = None)[source]

Initialize a new NyaaSiClient instance.

Parameters:

session (Optional[requests.Session]) – An optional requests.Session object to be used for making HTTP requests.

get_resource(id_: int)

Retrieves detailed information about a resource.

Parameters:

id (int) – The ID of the resource.

Returns:

A ResourceItem object with resource details.

Return type:

ResourceItem

iter_items(query: str = '', filter=Ellipsis, category=Ellipsis, sort_by=None, order=<Order.DESC: 'desc'>, from_page: int = 1)

Iterates through items on the website with paging support.

Parameters:
  • query (str) – The search query.

  • filter – The filter for items.

  • category – The category for items.

  • sort_by – The sorting option.

  • order (Order) – The sorting order (ascending or descending).

  • from_page (1) – The page number to start from.

Returns:

An iterator of ListItem objects.

Return type:

Iterator[ListItem]

iter_items_by_page(query: str = '', filter=Ellipsis, category=Ellipsis, sort_by=None, order=<Order.DESC: 'desc'>, page: int = 1) → Iterator[pynyaasi.client.client.ListItem]

Iterates through items on the website by page.

Parameters:
  • query (str) – The search query.

  • filter – The filter for items.

  • category – The category for items.

  • sort_by – The sorting option.

  • order (Order) – The sorting order (ascending or descending).

  • page (1) – The page number to start from.

Returns:

An iterator of ListItem objects.

Return type:

Iterator[ListItem]