From 9141a71ce21b21429b97e83b73e3e5e0cab60bea Mon Sep 17 00:00:00 2001 From: JuanjoSalvador Date: Sat, 12 Aug 2017 17:09:52 +0200 Subject: [PATCH] first commit --- NyaaPy/__init__.py | 0 NyaaPy/nyaa.py | 23 +++++++++++ README.md | 56 +++++++++++++++++++++++++++ build/lib/NyaaPy/__init__.py | 0 build/lib/NyaaPy/nyaa.py | 23 +++++++++++ dist/nyaapy-0.1-py3.6.egg | Bin 0 -> 2445 bytes nyaapy.egg-info/PKG-INFO | 15 +++++++ nyaapy.egg-info/SOURCES.txt | 8 ++++ nyaapy.egg-info/dependency_links.txt | 1 + nyaapy.egg-info/not-zip-safe | 1 + nyaapy.egg-info/top_level.txt | 1 + requirements.txt | 5 +++ setup.py | 12 ++++++ src/nyaa.py | 33 ++++++++++++++++ tests/test.py | 14 +++++++ 15 files changed, 192 insertions(+) create mode 100644 NyaaPy/__init__.py create mode 100644 NyaaPy/nyaa.py create mode 100644 README.md create mode 100644 build/lib/NyaaPy/__init__.py create mode 100644 build/lib/NyaaPy/nyaa.py create mode 100644 dist/nyaapy-0.1-py3.6.egg create mode 100644 nyaapy.egg-info/PKG-INFO create mode 100644 nyaapy.egg-info/SOURCES.txt create mode 100644 nyaapy.egg-info/dependency_links.txt create mode 100644 nyaapy.egg-info/not-zip-safe create mode 100644 nyaapy.egg-info/top_level.txt create mode 100644 requirements.txt create mode 100644 setup.py create mode 100644 src/nyaa.py create mode 100644 tests/test.py 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 0000000000000000000000000000000000000000..35c68af7b143cd7838b823be288a8b605df7cdc1 GIT binary patch literal 2445 zcmaJ?4LFl~AAaV$84VMPqlknt^lGiVNi(rw&0CagT((XY^U=ui%C~czjrr^pl`EVh zTE0q0%fZQOKC(W1QxqB%9Ts`7%E$Yt_ngg+)Bm}C&;NR!Yxn*9p8L7?yNP&t1q1*9 zDnL&v41Zl2jSdB`8o^q<>+Ir!boIb_T6=jOAsuw~vSLOvL)gDT@1x+@nPq$z*Ua4L zc1zcs=JXv)wStsj_Ei6AhSNTWlOqJ&a0~kiMm3;HDgGkjMd_HenwN(-Ygs5C|(ixM2f zIDKZ7WBhAqZD}+kl!-hS6oxz#aFX^Hl=cWztPVb~4J-|56cPVL+E^mqvl#_znDq7; z1N1L2`Y-E_0h~P7z%WOB!c>JGEB8MT(ev)eUIn?)9MPlYZ^)W~>6{!F=;4@Bf78+; zEFO9SH(i4^^4g;{MMb9a{281TPG+p!g1*JWBHjVnEn#R1t^89lzvJ5a8u1DL( zhJ5pxb#G0MPgs=~4bU0gH+c2Ps13spU3MAzd?Ip8C(?Wk5zo}kcrMYGJ===xq31`) z=rK2v=2^axPRw1AFsZJ{M{!sTe@#X4JLCiy`z@0NIPcAByok!trjHoCq0;o^YxD#6 z8di2(Ulg88%X+gEcU5Q5|3x<%&ip8v=6dT#{m?A06-nwJy-z&M3yxJ+^oV_LZU-x5(+-NWWj?u9@)@UoyD{CtHBNz ztM~~uh)w8*TW-s-?(yIMtGtI1n-hC>=3pfwWYPyyAHCi5Fn6UPq|SmabW#}xvYt^O z*`?{35XB4G@XHn1cI5qgy$NiHss4na<10Voyc0({FW4Wm@AN9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oO~Gpq?KSq|Bhl5mVjbF7zHU!z)$tUp#sf<72Wf4-1(fXPzG=9h$mBu(*0 znn}ago8S^S7o0+C=eaa?z3C>wR)Q)1*I6fxU-h5ttdrnJrSV^#e6pOfo|bUBD@pYv Y;rtti6Y+}R?*U)~c*KB8EPlTFA1@(-?f?J) literal 0 HcmV?d00001 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'])