first commit

This commit is contained in:
JuanjoSalvador
2017-08-12 17:09:52 +02:00
commit 9141a71ce2
15 changed files with 192 additions and 0 deletions

0
NyaaPy/__init__.py Normal file
View File

23
NyaaPy/nyaa.py Normal file
View File

@@ -0,0 +1,23 @@
import requests
import xmltodict
class Nyaa():
def search(keyword):
nyaa_baseurl = "https://nyaa.si/?page=rss&c=1_0&f=0&q="
request = requests.get(nyaa_baseurl + keyword)
response = xmltodict.parse(request.text)
results = response['rss']['channel']['item']
return results
class NyaaPantsu():
def search(keyword):
nyaapantsu_baseurl = "https://nyaa.pantsu.cat/feed?c=_&s=0&max=99999&userID=0&q="
request = requests.get(nyaapantsu_baseurl + keyword)
response = xmltodict.parse(request.text)
results = response['rss']['channel']['item']
return results

56
README.md Normal file
View File

@@ -0,0 +1,56 @@
# NyaaPy
Unofficial Python module to search into Nyaa.si and nyaa.pantsu.cat.
Based on [Kylart's Nyaapi](https://github.com/Kylart/Nyaapi).
### Installation and ussage
Install it using pip.
pip install nyaapy
### Contributions and development
At this moment there isn't an official Nyaa.si API, so we only can make requests using the search URI.
#### Instructions to contribute
1. Clone or fork the repo.
```
$ git clone https://github.com/JuanjoSalvador/nyaapy.github
```
2. Set the virtual environment.
```
$ virtualenv nyaa
$ source nyaa/bin/activate
```
3. If you are ussing a clonned repo, please create a new branch named `patch-<username>-<version>`. Example: `patch-juanjosalvador-0.2`
4. Always use the code into `src` folder, never the package.
### Example code
from NyaaPy.nyaa import Nyaa
from NyaaPy.nyaa import NyaaPantsu
# Nyaa.si results
nyaa_query = Nyaa.search('new game')
for result in nyaa_query:
print(result['title'])
# Nyaa.pantsu.cat results
pantsu_query = NyaaPantsu.search('new game')
for result in pantsu_query:
print(result['title'])
### License
MIT license.

View File

23
build/lib/NyaaPy/nyaa.py Normal file
View File

@@ -0,0 +1,23 @@
import requests
import xmltodict
class Nyaa():
def search(keyword):
nyaa_baseurl = "https://nyaa.si/?page=rss&c=1_0&f=0&q="
request = requests.get(nyaa_baseurl + keyword)
response = xmltodict.parse(request.text)
results = response['rss']['channel']['item']
return results
class NyaaPantsu():
def search(keyword):
nyaapantsu_baseurl = "https://nyaa.pantsu.cat/feed?c=_&s=0&max=99999&userID=0&q="
request = requests.get(nyaapantsu_baseurl + keyword)
response = xmltodict.parse(request.text)
results = response['rss']['channel']['item']
return results

BIN
dist/nyaapy-0.1-py3.6.egg vendored Normal file

Binary file not shown.

15
nyaapy.egg-info/PKG-INFO Normal file
View File

@@ -0,0 +1,15 @@
Metadata-Version: 1.0
Name: nyaapy
Version: 0.1
Summary: Allows you to make requests on Nyaa.si and nyaa.pantsu.cat
Home-page: https://github.com/juanjosalvador/nyaapy
Author: Juanjo Salvador
Author-email: juanjosalvador@netc.eu
License: MIT
Description: # NyaaPy
Unofficial Python module to search into Nyaa.si and nyaa.pantsu.cat.
Based on [Kylart's Nyaapi](https://github.com/Kylart/Nyaapi).
Platform: UNKNOWN

View File

@@ -0,0 +1,8 @@
setup.py
NyaaPy/__init__.py
NyaaPy/nyaa.py
nyaapy.egg-info/PKG-INFO
nyaapy.egg-info/SOURCES.txt
nyaapy.egg-info/dependency_links.txt
nyaapy.egg-info/not-zip-safe
nyaapy.egg-info/top_level.txt

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@
NyaaPy

5
requirements.txt Normal file
View File

@@ -0,0 +1,5 @@
certifi==2017.7.27.1
chardet==3.0.4
idna==2.5
requests==2.18.3
urllib3==1.22

12
setup.py Normal file
View File

@@ -0,0 +1,12 @@
from setuptools import setup, find_packages
setup(name='nyaapy',
version='0.1',
url='https://github.com/juanjosalvador/nyaapy',
license='MIT',
author='Juanjo Salvador',
author_email='juanjosalvador@netc.eu',
description='Allows you to make requests on Nyaa.si and nyaa.pantsu.cat',
packages=find_packages(exclude=['tests']),
long_description=open('README.md').read(),
zip_safe=False)

33
src/nyaa.py Normal file
View File

@@ -0,0 +1,33 @@
import requests
import xmltodict
class Nyaa:
'''
Makes a search query to nyaa.si with the given keyword that returns a
RSS file converted into a dictionary that we can use.
'''
def search(keyword):
nyaa_baseurl = "https://nyaa.si/?page=rss&c=1_0&f=0&q="
request = requests.get(nyaa_baseurl + keyword)
response = xmltodict.parse(request.text)
results = response['rss']['channel']['item']
return results
class NyaaPantsu:
'''
Makes a search query to nyaa.pantsu.cat with the given keyword that returns a
RSS file converted into a dictionary that we can use.
'''
def search(keyword):
nyaa_baseurl = "https://nyaa.pantsu.cat/feed?c=_&s=0&max=99999&userID=0&q="
request = requests.get(nyaa_baseurl + keyword)
response = xmltodict.parse(request.text)
results = response['rss']['channel']['item']
return results

14
tests/test.py Normal file
View File

@@ -0,0 +1,14 @@
from NyaaPy.nyaa import Nyaa
from NyaaPy.nyaa import NyaaPantsu
# Nyaa.si results
nyaa_query = Nyaa.search('new game')
for result in nyaa_query:
print(result['title'])
# Nyaa.pantsu.cat results
pantsu_query = NyaaPantsu.search('new game')
for result in pantsu_query:
print(result['title'])