Removed nyaa.pantsu.cat (fixed #15)
This commit is contained in:
@@ -6,5 +6,4 @@ __url__ = 'http://juanjosalvador.me'
|
||||
__copyright__ = '2017 Juanjo Salvador'
|
||||
__license__ = 'MIT license'
|
||||
|
||||
from NyaaPy.nyaa import Nyaa
|
||||
from NyaaPy.nyaapantsu import NyaaPantsu
|
||||
from NyaaPy.nyaa import Nyaa
|
||||
@@ -1,35 +0,0 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from NyaaPy.utils import Utils as utils
|
||||
|
||||
|
||||
class NyaaPantsu():
|
||||
'''
|
||||
Simple search.
|
||||
Return a list of dicts with the results of the query.
|
||||
'''
|
||||
def search(keyword, category, subcategory, filters, page):
|
||||
if page > 0:
|
||||
r = requests.get("http://nyaa.pantsu.cat/search/{}?c={}_{}&q={}".format(page, category, subcategory, keyword))
|
||||
else:
|
||||
r = requests.get("http://nyaa.pantsu.cat/search/?c={}_{}&q={}".format(category, subcategory, keyword))
|
||||
|
||||
soup = BeautifulSoup(r.text, 'html.parser')
|
||||
rows = soup.select('table tr')
|
||||
|
||||
results = {}
|
||||
|
||||
if rows:
|
||||
results = utils.parse_pantsu(rows, limit=None)
|
||||
|
||||
return results
|
||||
|
||||
'''
|
||||
Returns an array of dicts with the n last updates of Nyaa.si
|
||||
'''
|
||||
def news(number_of_results):
|
||||
r = requests.get("http://nyaa.pantsu.cat/")
|
||||
soup = BeautifulSoup(r.text, 'html.parser')
|
||||
rows = soup.select('table tr')
|
||||
|
||||
return utils.parse_pantsu(rows, limit=number_of_results)
|
||||
@@ -68,15 +68,6 @@ class Utils():
|
||||
|
||||
return category_name
|
||||
|
||||
def pantsu_categories(b):
|
||||
c = b.replace('/search?c=', '')
|
||||
cats = c.split('_')
|
||||
|
||||
cat = cats[0]
|
||||
subcat = cats[1]
|
||||
|
||||
return "{} - {}".format(cat, subcat)
|
||||
|
||||
def parse_nyaa(table_rows, limit):
|
||||
|
||||
torrents = []
|
||||
@@ -113,42 +104,4 @@ class Utils():
|
||||
except IndexError as ie:
|
||||
pass
|
||||
|
||||
return torrents
|
||||
|
||||
def parse_pantsu(table_rows, limit):
|
||||
|
||||
torrents = []
|
||||
|
||||
limit = limit + 1
|
||||
|
||||
for row in table_rows[1:limit]:
|
||||
block = []
|
||||
|
||||
for td in row.find_all('td'):
|
||||
if td.find_all('a'):
|
||||
for link in td.find_all('a'):
|
||||
if "lang" not in link.get('href'):
|
||||
block.append(link.get('href'))
|
||||
|
||||
if td.text.rstrip():
|
||||
block.append(td.text.replace('\n', ''))
|
||||
|
||||
try:
|
||||
torrent = {
|
||||
'category': Utils.pantsu_categories(block[0]),
|
||||
'url': "http://nyaa.pantsu.cat{}".format(block[1]),
|
||||
'name': block[2],
|
||||
'download_url': block[4],
|
||||
'magnet': block[3],
|
||||
'size': block[5],
|
||||
'date': block[9],
|
||||
'seeders': block[6],
|
||||
'leechers': block[7],
|
||||
'completed_downloads': block[8],
|
||||
}
|
||||
|
||||
torrents.append(torrent)
|
||||
except IndexError as ie:
|
||||
pass
|
||||
|
||||
return torrents
|
||||
@@ -1,6 +1,6 @@
|
||||
# NyaaPy
|
||||
|
||||
Unofficial Python module to search into Nyaa.si and nyaa.pantsu.cat.
|
||||
Unofficial Python module to search into Nyaa.si
|
||||
|
||||
Supports Python 3+
|
||||
|
||||
@@ -23,7 +23,7 @@ Install it using pip.
|
||||
## Example
|
||||
|
||||
```python
|
||||
from NyaaPy import Nyaa, NyaaPantsu
|
||||
from NyaaPy import Nyaa
|
||||
|
||||
nyaa_query = Nyaa.search(keyword='koe no katachi 1080', category=1, subcategory=0, filters=0, page=0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user