Minor fixes

This commit is contained in:
JuanjoSalvador
2017-08-12 19:40:34 +02:00
parent 3805a2de6c
commit a17186393d
5 changed files with 39 additions and 17 deletions

View File

@@ -8,7 +8,11 @@ class Nyaa():
request = requests.get(nyaa_baseurl + keyword)
response = xmltodict.parse(request.text)
try:
results = response['rss']['channel']['item']
except KeyError as ex:
results = {}
return results
@@ -18,6 +22,10 @@ class NyaaPantsu():
request = requests.get(nyaapantsu_baseurl + keyword)
response = xmltodict.parse(request.text)
try:
results = response['rss']['channel']['item']
except KeyError as ex:
results = {}
return results

View File

@@ -41,15 +41,21 @@ At this moment there isn't an official Nyaa.si API, so we only can make requests
from NyaaPy.nyaa import NyaaPantsu
# Nyaa.si results
nyaa_query = Nyaa.search('new game')
nyaa_query = Nyaa.search('illo que pasa')
if len(nyaa_query) > 0:
for result in nyaa_query:
print(result['title'])
else:
print('Nothing here!')
# Nyaa.pantsu.cat results
pantsu_query = NyaaPantsu.search('new game')
if len(pantsu_query) > 0:
for result in pantsu_query:
print(result['title'])
else:
print('Nothing here!')
### License

View File

@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
setup(name='nyaapy',
version='0.1',
version='0.3',
url='https://github.com/juanjosalvador/nyaapy',
download_url = 'https://github.com/juanjosalvador/nyaapy/archive/0.1.tar.gz',
license='MIT',
@@ -9,5 +9,4 @@ setup(name='nyaapy',
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)

View File

@@ -13,7 +13,11 @@ class Nyaa:
request = requests.get(nyaa_baseurl + keyword)
response = xmltodict.parse(request.text)
try:
results = response['rss']['channel']['item']
except Exception as ex:
print(ex)
return results

View File

@@ -2,13 +2,18 @@ from NyaaPy.nyaa import Nyaa
from NyaaPy.nyaa import NyaaPantsu
# Nyaa.si results
nyaa_query = Nyaa.search('illo que pasa')
nyaa_query = Nyaa.search('new game')
if len(nyaa_query) > 0:
for result in nyaa_query:
print(result['title'])
else:
print('Nothing here!')
# Nyaa.pantsu.cat results
pantsu_query = NyaaPantsu.search('new game')
if len(pantsu_query) > 0:
for result in pantsu_query:
print(result['title'])
else:
print('Nothing here!')