commit 9141a71ce21b21429b97e83b73e3e5e0cab60bea Author: JuanjoSalvador Date: Sat Aug 12 17:09:52 2017 +0200 first commit diff --git a/NyaaPy/__init__.py b/NyaaPy/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/NyaaPy/nyaa.py b/NyaaPy/nyaa.py new file mode 100644 index 0000000..05e25f7 --- /dev/null +++ b/NyaaPy/nyaa.py @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..8b25236 --- /dev/null +++ b/README.md @@ -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--`. 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. diff --git a/build/lib/NyaaPy/__init__.py b/build/lib/NyaaPy/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/build/lib/NyaaPy/nyaa.py b/build/lib/NyaaPy/nyaa.py new file mode 100644 index 0000000..05e25f7 --- /dev/null +++ b/build/lib/NyaaPy/nyaa.py @@ -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 diff --git a/dist/nyaapy-0.1-py3.6.egg b/dist/nyaapy-0.1-py3.6.egg new file mode 100644 index 0000000..35c68af Binary files /dev/null and b/dist/nyaapy-0.1-py3.6.egg differ diff --git a/nyaapy.egg-info/PKG-INFO b/nyaapy.egg-info/PKG-INFO new file mode 100644 index 0000000..009d92c --- /dev/null +++ b/nyaapy.egg-info/PKG-INFO @@ -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 diff --git a/nyaapy.egg-info/SOURCES.txt b/nyaapy.egg-info/SOURCES.txt new file mode 100644 index 0000000..97358db --- /dev/null +++ b/nyaapy.egg-info/SOURCES.txt @@ -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 \ No newline at end of file diff --git a/nyaapy.egg-info/dependency_links.txt b/nyaapy.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/nyaapy.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/nyaapy.egg-info/not-zip-safe b/nyaapy.egg-info/not-zip-safe new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/nyaapy.egg-info/not-zip-safe @@ -0,0 +1 @@ + diff --git a/nyaapy.egg-info/top_level.txt b/nyaapy.egg-info/top_level.txt new file mode 100644 index 0000000..bfc9dae --- /dev/null +++ b/nyaapy.egg-info/top_level.txt @@ -0,0 +1 @@ +NyaaPy diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8d986c4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +certifi==2017.7.27.1 +chardet==3.0.4 +idna==2.5 +requests==2.18.3 +urllib3==1.22 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..2c86597 --- /dev/null +++ b/setup.py @@ -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) diff --git a/src/nyaa.py b/src/nyaa.py new file mode 100644 index 0000000..60afc42 --- /dev/null +++ b/src/nyaa.py @@ -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 diff --git a/tests/test.py b/tests/test.py new file mode 100644 index 0000000..58800ce --- /dev/null +++ b/tests/test.py @@ -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'])