merge fixes
This commit is contained in:
108
NyaaPy/nyaa.py
108
NyaaPy/nyaa.py
@@ -1,54 +1,54 @@
|
|||||||
import requests
|
import requests
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from NyaaPy import utils
|
from NyaaPy import utils
|
||||||
|
|
||||||
class Nyaa:
|
class Nyaa:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.URI = "http://nyaa.si"
|
self.URI = "http://nyaa.si"
|
||||||
|
|
||||||
def search(self, keyword, **kwargs):
|
def last_uploads(self, number_of_results):
|
||||||
user = kwargs.get('user', None)
|
r = requests.get(self.URI)
|
||||||
category = kwargs.get('category', 0)
|
soup = BeautifulSoup(r.text, 'html.parser')
|
||||||
subcategory = kwargs.get('subcategory', 0)
|
rows = soup.select('table tr')
|
||||||
filters = kwargs.get('filters', 0)
|
|
||||||
page = kwargs.get('page', 0)
|
return utils.parse_nyaa(table_rows=rows, limit=number_of_results + 1)
|
||||||
|
|
||||||
if user:
|
def search(self, keyword, **kwargs):
|
||||||
user_uri = "user/{}".format(user)
|
user = kwargs.get('user', None)
|
||||||
else:
|
category = kwargs.get('category', 0)
|
||||||
user_uri = ""
|
subcategory = kwargs.get('subcategory', 0)
|
||||||
|
filters = kwargs.get('filters', 0)
|
||||||
if page > 0:
|
page = kwargs.get('page', 0)
|
||||||
r = requests.get("{}/{}?f={}&c={}_{}&q={}&p={}".format(
|
|
||||||
self.URI, user_uri, filters, category, subcategory, keyword,
|
if user:
|
||||||
page))
|
user_uri = "user/{}".format(user)
|
||||||
else:
|
else:
|
||||||
r = requests.get("{}/{}?f={}&c={}_{}&q={}".format(
|
user_uri = ""
|
||||||
self.URI, user_uri, filters, category, subcategory, keyword))
|
|
||||||
|
if page > 0:
|
||||||
soup = BeautifulSoup(r.text, 'html.parser')
|
r = requests.get("{}/{}?f={}&c={}_{}&q={}&p={}".format(
|
||||||
rows = soup.select('table tr')
|
self.URI, user_uri, filters, category, subcategory, keyword,
|
||||||
|
page))
|
||||||
return utils.parse_nyaa(rows, limit=None)
|
else:
|
||||||
|
r = requests.get("{}/{}?f={}&c={}_{}&q={}".format(
|
||||||
def get(self, id):
|
self.URI, user_uri, filters, category, subcategory, keyword))
|
||||||
r = requests.get("{}/view/{}".format(self.URI, id))
|
|
||||||
soup = BeautifulSoup(r.text, 'html.parser')
|
soup = BeautifulSoup(r.text, 'html.parser')
|
||||||
content = soup.findAll("div", {"class": "panel", "id": None})
|
rows = soup.select('table tr')
|
||||||
|
|
||||||
return utils.parse_single(content)
|
return utils.parse_nyaa(rows, limit=None)
|
||||||
|
|
||||||
def get_user(self, username):
|
def get(self, id):
|
||||||
r = requests.get("{}/user/{}".format(self.URI, username))
|
r = requests.get("{}/view/{}".format(self.URI, id))
|
||||||
soup = BeautifulSoup(r.text, 'html.parser')
|
soup = BeautifulSoup(r.text, 'html.parser')
|
||||||
|
content = soup.findAll("div", {"class": "panel", "id": None})
|
||||||
return utils.parse_nyaa(soup.select('table tr'), limit=None)
|
|
||||||
|
return utils.parse_single(content)
|
||||||
def news(self, number_of_results):
|
|
||||||
r = requests.get(self.URI)
|
def get_user(self, username):
|
||||||
soup = BeautifulSoup(r.text, 'html.parser')
|
r = requests.get("{}/user/{}".format(self.URI, username))
|
||||||
rows = soup.select('table tr')
|
soup = BeautifulSoup(r.text, 'html.parser')
|
||||||
|
|
||||||
return utils.parse_nyaa(rows, limit=number_of_results + 1)
|
return utils.parse_nyaa(soup.select('table tr'), limit=None)
|
||||||
|
|||||||
@@ -1,40 +1,48 @@
|
|||||||
import requests
|
import requests
|
||||||
from NyaaPy import utils
|
from NyaaPy import utils
|
||||||
|
|
||||||
class Pantsu:
|
class Pantsu:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.BASE_URL = "https://nyaa.pantsu.cat/api"
|
self.BASE_URL = "https://nyaa.pantsu.cat/api"
|
||||||
|
|
||||||
# Torrents - GET
|
def last_uploads(self, number_of_results):
|
||||||
def search(self, keyword, **kwargs):
|
r = requests.get(self.URI)
|
||||||
request = requests.get("{}/search{}".format(
|
soup = BeautifulSoup(r.text, 'html.parser')
|
||||||
self.BASE_URL, utils.query_builder(keyword, kwargs)))
|
rows = soup.select('table tr')
|
||||||
return request.json()
|
|
||||||
|
return utils.parse_nyaa(rows, limit=number_of_results + 1)
|
||||||
def view(self, item_id):
|
|
||||||
request = requests.get("{}/view/{}".format(self.BASE_URL, item_id))
|
|
||||||
|
# Torrents - GET
|
||||||
return request.json()
|
def search(self, keyword, **kwargs):
|
||||||
|
request = requests.get("{}/search{}".format(
|
||||||
# Torrents - POST
|
self.BASE_URL, utils.query_builder(keyword, kwargs)))
|
||||||
|
return request.json()
|
||||||
def upload(self):
|
|
||||||
return "Work in progress!"
|
def view(self, item_id):
|
||||||
|
request = requests.get("{}/view/{}".format(self.BASE_URL, item_id))
|
||||||
def update(self):
|
|
||||||
return "Work in progress!"
|
return request.json()
|
||||||
|
|
||||||
# Users
|
# Torrents - POST
|
||||||
|
|
||||||
def login(self, username, password):
|
def upload(self):
|
||||||
login = requests.post("{}/login/".format(
|
return "Work in progress!"
|
||||||
self.BASE_URL), data={'username': username, 'password': password})
|
|
||||||
|
def update(self):
|
||||||
return login.json()
|
return "Work in progress!"
|
||||||
|
|
||||||
def profile(self, user_id):
|
# Users
|
||||||
profile = requests.post("{}/profile/".format(
|
|
||||||
self.BASE_URL), data={'id': user_id})
|
def login(self, username, password):
|
||||||
|
login = requests.post("{}/login/".format(
|
||||||
return profile.json()
|
self.BASE_URL), data={'username': username, 'password': password})
|
||||||
|
|
||||||
|
return login.json()
|
||||||
|
|
||||||
|
def profile(self, user_id):
|
||||||
|
profile = requests.post("{}/profile/".format(
|
||||||
|
self.BASE_URL), data={'id': user_id})
|
||||||
|
|
||||||
|
return profile.json()
|
||||||
|
|||||||
@@ -1,84 +1,84 @@
|
|||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from NyaaPy import utils
|
from NyaaPy import utils
|
||||||
|
|
||||||
class SukebeiNyaa:
|
class SukebeiNyaa:
|
||||||
def search(self, keyword, **kwargs):
|
def search(self, keyword, **kwargs):
|
||||||
category = kwargs.get('category', 0)
|
category = kwargs.get('category', 0)
|
||||||
subcategory = kwargs.get('subcategory', 0)
|
subcategory = kwargs.get('subcategory', 0)
|
||||||
filters = kwargs.get('filters', 0)
|
filters = kwargs.get('filters', 0)
|
||||||
page = kwargs.get('page', 0)
|
page = kwargs.get('page', 0)
|
||||||
|
|
||||||
if page > 0:
|
if page > 0:
|
||||||
r = requests.get("{}/?f={}&c={}_{}&q={}&p={}".format(
|
r = requests.get("{}/?f={}&c={}_{}&q={}&p={}".format(
|
||||||
"http://sukebei.nyaa.si", filters, category, subcategory,
|
"http://sukebei.nyaa.si", filters, category, subcategory,
|
||||||
keyword, page))
|
keyword, page))
|
||||||
else:
|
else:
|
||||||
r = requests.get("{}/?f={}&c={}_{}&q={}".format(
|
r = requests.get("{}/?f={}&c={}_{}&q={}".format(
|
||||||
"http://sukebei.nyaa.si", filters, category, subcategory,
|
"http://sukebei.nyaa.si", filters, category, subcategory,
|
||||||
keyword))
|
keyword))
|
||||||
|
|
||||||
soup = BeautifulSoup(r.text, 'html.parser')
|
soup = BeautifulSoup(r.text, 'html.parser')
|
||||||
rows = soup.select('table tr')
|
rows = soup.select('table tr')
|
||||||
|
|
||||||
return utils.parse_nyaa(rows, limit=None)
|
return utils.parse_nyaa(rows, limit=None)
|
||||||
|
|
||||||
def get(self, id):
|
def get(self, id):
|
||||||
r = requests.get("http://sukebei.nyaa.si/view/{}".format(id))
|
r = requests.get("http://sukebei.nyaa.si/view/{}".format(id))
|
||||||
soup = BeautifulSoup(r.text, 'html.parser')
|
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)
|
return utils.parse_single(content)
|
||||||
|
|
||||||
def get_user(self, username):
|
def get_user(self, username):
|
||||||
r = requests.get("http://sukebei.nyaa.si/user/{}".format(username))
|
r = requests.get("http://sukebei.nyaa.si/user/{}".format(username))
|
||||||
soup = BeautifulSoup(r.text, 'html.parser')
|
soup = BeautifulSoup(r.text, 'html.parser')
|
||||||
|
|
||||||
return utils.parse_nyaa(soup.select('table tr'), limit=None)
|
return utils.parse_nyaa(soup.select('table tr'), limit=None)
|
||||||
|
|
||||||
def news(self, number_of_results):
|
def news(self, number_of_results):
|
||||||
r = requests.get("http://sukebei.nyaa.si/")
|
r = requests.get("http://sukebei.nyaa.si/")
|
||||||
soup = BeautifulSoup(r.text, 'html.parser')
|
soup = BeautifulSoup(r.text, 'html.parser')
|
||||||
rows = soup.select('table tr')
|
rows = soup.select('table tr')
|
||||||
|
|
||||||
return utils.parse_sukebei(rows, limit=number_of_results + 1)
|
return utils.parse_sukebei(rows, limit=number_of_results + 1)
|
||||||
|
|
||||||
|
|
||||||
class SukebeiPantsu:
|
class SukebeiPantsu:
|
||||||
BASE_URL = "https://sukebei.pantsu.cat/api"
|
BASE_URL = "https://sukebei.pantsu.cat/api"
|
||||||
|
|
||||||
# Torrents - GET
|
# Torrents - GET
|
||||||
def search(self, keyword, **kwargs):
|
def search(self, keyword, **kwargs):
|
||||||
request = requests.get("{}/search{}".format(
|
request = requests.get("{}/search{}".format(
|
||||||
SukebeiPantsu.BASE_URL, utils.query_builder(keyword, kwargs)))
|
SukebeiPantsu.BASE_URL, utils.query_builder(keyword, kwargs)))
|
||||||
|
|
||||||
return request.json()
|
return request.json()
|
||||||
|
|
||||||
def view(self, item_id):
|
def view(self, item_id):
|
||||||
request = requests.get("{}/view/{}".format(
|
request = requests.get("{}/view/{}".format(
|
||||||
SukebeiPantsu.BASE_URL, item_id))
|
SukebeiPantsu.BASE_URL, item_id))
|
||||||
|
|
||||||
return request.json()
|
return request.json()
|
||||||
|
|
||||||
# Torrents - POST
|
# Torrents - POST
|
||||||
|
|
||||||
def upload(self):
|
def upload(self):
|
||||||
return "Work in progress!"
|
return "Work in progress!"
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
return "Work in progress!"
|
return "Work in progress!"
|
||||||
|
|
||||||
# Users
|
# Users
|
||||||
|
|
||||||
def login(self, username, password):
|
def login(self, username, password):
|
||||||
login = requests.post("{}/login/".format(
|
login = requests.post("{}/login/".format(
|
||||||
SukebeiPantsu.BASE_URL), data={'username': username,
|
SukebeiPantsu.BASE_URL), data={'username': username,
|
||||||
'password': password})
|
'password': password})
|
||||||
|
|
||||||
return login.json()
|
return login.json()
|
||||||
|
|
||||||
def profile(self, user_id):
|
def profile(self, user_id):
|
||||||
profile = requests.post("{}/profile/".format(
|
profile = requests.post("{}/profile/".format(
|
||||||
SukebeiPantsu.BASE_URL), data={'id': user_id})
|
SukebeiPantsu.BASE_URL), data={'id': user_id})
|
||||||
|
|
||||||
return profile.json()
|
return profile.json()
|
||||||
|
|||||||
Reference in New Issue
Block a user