Conform to PEP8 style
This commit is contained in:
@@ -2,6 +2,7 @@ import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from NyaaPy.utils import Utils as utils
|
||||
|
||||
|
||||
class SukebeiNyaa:
|
||||
def search(self, keyword, **kwargs):
|
||||
category = kwargs.get('category', 0)
|
||||
@@ -10,9 +11,13 @@ class SukebeiNyaa:
|
||||
page = kwargs.get('page', 0)
|
||||
|
||||
if page > 0:
|
||||
r = requests.get("{}/?f={}&c={}_{}&q={}&p={}".format("http://sukebei.nyaa.si", filters, category, subcategory, keyword, page))
|
||||
r = requests.get("{}/?f={}&c={}_{}&q={}&p={}".format(
|
||||
"http://sukebei.nyaa.si", filters, category, subcategory,
|
||||
keyword, page))
|
||||
else:
|
||||
r = requests.get("{}/?f={}&c={}_{}&q={}".format("http://sukebei.nyaa.si", filters, category, subcategory, keyword))
|
||||
r = requests.get("{}/?f={}&c={}_{}&q={}".format(
|
||||
"http://sukebei.nyaa.si", filters, category, subcategory,
|
||||
keyword))
|
||||
|
||||
soup = BeautifulSoup(r.text, 'html.parser')
|
||||
rows = soup.select('table tr')
|
||||
@@ -22,8 +27,8 @@ class SukebeiNyaa:
|
||||
def get(self, id):
|
||||
r = requests.get("http://sukebei.nyaa.si/view/{}".format(id))
|
||||
soup = BeautifulSoup(r.text, 'html.parser')
|
||||
content = soup.findAll("div", { "class": "panel", "id": None})
|
||||
|
||||
content = soup.findAll("div", {"class": "panel", "id": None})
|
||||
|
||||
return utils.parse_single(content)
|
||||
|
||||
def get_user(self, username):
|
||||
@@ -39,17 +44,20 @@ class SukebeiNyaa:
|
||||
|
||||
return utils.parse_sukebei(rows, limit=number_of_results + 1)
|
||||
|
||||
|
||||
class SukebeiPantsu:
|
||||
BASE_URL = "https://sukebei.pantsu.cat/api"
|
||||
|
||||
# Torrents - GET
|
||||
def search(self, keyword, **kwargs):
|
||||
request = requests.get("{}/search{}".format(SukebeiPantsu.BASE_URL, utils.query_builder(keyword, kwargs)))
|
||||
|
||||
request = requests.get("{}/search{}".format(
|
||||
SukebeiPantsu.BASE_URL, utils.query_builder(keyword, kwargs)))
|
||||
|
||||
return request.json()
|
||||
|
||||
def view(self, item_id):
|
||||
request = requests.get("{}/view/{}".format(SukebeiPantsu.BASE_URL, item_id))
|
||||
request = requests.get("{}/view/{}".format(
|
||||
SukebeiPantsu.BASE_URL, item_id))
|
||||
|
||||
return request.json()
|
||||
|
||||
@@ -64,11 +72,14 @@ class SukebeiPantsu:
|
||||
# Users
|
||||
|
||||
def login(self, username, password):
|
||||
login = requests.post("{}/login/".format(SukebeiPantsu.BASE_URL), data={'username': username, 'password': password})
|
||||
login = requests.post("{}/login/".format(
|
||||
SukebeiPantsu.BASE_URL), data={'username': username,
|
||||
'password': password})
|
||||
|
||||
return login.json()
|
||||
|
||||
def profile(self, user_id):
|
||||
profile = requests.post("{}/profile/".format(SukebeiPantsu.BASE_URL), data={'id': user_id})
|
||||
profile = requests.post("{}/profile/".format(
|
||||
SukebeiPantsu.BASE_URL), data={'id': user_id})
|
||||
|
||||
return profile.json()
|
||||
return profile.json()
|
||||
|
||||
Reference in New Issue
Block a user