Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

The Nth NYAA API - fetch and downloads torrents from Nyaa.

Project Description
# Nnyaaa: the Nth Nyaa API

## Usage

```
usage: nnyaaa.py [-h] [-s {date,seeders,leechers,downloads,size}]
[-o {asc,desc}] [-f {all,noremake,trusted,aplus}] [-r range]
[-c] [-q] [-d] [-D]
[query [query ...]]

__
/\ \ \_ __ _ _ __ _ __ _ __ _
/ \/ / '_ \| | | |/ _` |/ _` |/ _` |
/ /\ /| | | | |_| | (_| | (_| | (_| |
\_\ \/ |_| |_|\__, |\__,_|\__,_|\__,_|
althonos |___/ the Nth NYAA API


positional arguments:
query The string to search for on Nyaa

optional arguments:
-h, --help show this help message and exit
-s {date,seeders,leechers,downloads,size}
the sorting key to use for the resulting torrent list
-o {asc,desc} the order to use for the resulting torrent list
-f {all,noremake,trusted,aplus}
the filter for the resulting torrent list
-r range the ranges of pages to fetch
-c, --color colored output (only in Unix terminals)
-q, --quiet do not print any output
-d, --detail print details about each torrent
-D, --download flag to download torrents
```

## Library
This app comes with its implementation of Nyaa torrents scrapers :


* #### Class **TList**:
A class that implements search queries and filters of Nyaa Torrent.
Methods are :
* **\_\_init\_\_**:
```python3
__init__ (self, query=None, sort='date', order='desc', filter='all', start_page=1, end_page=1, color=False):
```
where:
* *query* is the search query to look for in Nyaa database (if None, then Nyaa main page torrents will be scraped instead)
* *sort* is the sorting key to use for the resulting torrent list (in {'date','seeders','leechers','downloads','size'})
* *order* is the order of results filtering (in {'asc', 'desc'})
* filter is the minimal trust level of torrents to display (in {'all','noremake','trusted','aplus'})
* *start_page*, *end_page* are pages to start and stop looking for torrents
* *color* is display a colored output
* **build_url**:
```python3
build_url(self):
```
creates the query url that will be used to fetch torrents and stores it in `self.url`. where:
* **get_html**:
```python3
get_html(self,headers={'User-agent':'Firefox'})
```
gets the page located at self.url, where:
* *headers* are the headers to send via the GET query (default performs browser spoofing)
* **set_url_offset**:
```python3
set_url_offset(self, offset)
```
sets the url to require the page *offset* next time the get_html method is called, where:
* *offset* is the number of the page to set
* **fetch**:
```python3
fetch(self)
```
an iterator over torrents entry of TList, fetching the torrents on the query page and yielding them as Torrent objects


* #### Class **Torrent**:
A Class that implements torrent representation and downloading. Methods are:
* **\_\_init\_\_**:
```python3
__init__(self, url=None, soup=None, color=False)
```
where:
* *url* is the url of the torrent's page
* *soup* is an html block containing the torrent informations **extracted from a TList html block**
* *color* is a flag to display in color
Either soup or url are required, but if both are provided, then informations will be extracted from soup and the Torrent won't connect to the url until explicitly requested via **get_extended_infos** method.

* **get_html**:
```python3
get_html(self, headers={'User-Agent':'Firefox'}):
```
gets the page located at self.url, where:
* *headers* are the headers to send via the GET query (default performs browser spoofing)

* **get_extended_infos**:
```python3
get_extended_infos(self, headers={'User-Agent':'Firefox'})
```
Connects to the url and get infos from the torrent page, where:
* *headers* are the headers to send via the GET query (default performs browser spoofing)

* **download**
```python3
download(self, directory=".", headers={'User-Agent' : 'Firefox'})
```
downloads the torrent with a multithreaded downloader, where:
* *directory* is the directory to download the files in
* *headers* are the headers to send via the GET query (default performs browser spoofing)


* #### Class **Comment**
A Class that implements comment representation from a torrent page.
Methods are:
* **\_\_init\_\_**:
```python3
__init__(self, comment_block)
```
where:
* *comment_block* is the html `<div class="comment">` block comming from the torrent page.
Release History

Release History

This version
History Node

1.1.1

History Node

1.1.0

History Node

1.0.1

History Node

1.0.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
nnyaaa-1.1.1-py3-none-any.whl (9.4 kB) Copy SHA256 Checksum SHA256 3.6 Wheel Feb 28, 2017
nnyaaa-1.1.1.tar.gz (6.7 kB) Copy SHA256 Checksum SHA256 Source Feb 28, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting