From 3f39dd112375b35aa4029603ada1f70df43dd2a4 Mon Sep 17 00:00:00 2001 From: JuanjoSalvador Date: Sat, 2 Dec 2017 18:17:46 +0100 Subject: [PATCH] Sukebei update --- NyaaPy/__init__.py | 2 +- NyaaPy/sukebei.py | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/NyaaPy/__init__.py b/NyaaPy/__init__.py index 106e560..050a8fc 100644 --- a/NyaaPy/__init__.py +++ b/NyaaPy/__init__.py @@ -8,4 +8,4 @@ __license__ = 'MIT license' from NyaaPy.nyaa import Nyaa from NyaaPy.pantsu import Pantsu -from NyaaPy.sukebei import SukebeiNyaa \ No newline at end of file +from NyaaPy.sukebei import SukebeiNyaa, SukebeiPantsu \ No newline at end of file diff --git a/NyaaPy/sukebei.py b/NyaaPy/sukebei.py index ccf442c..5819cc3 100644 --- a/NyaaPy/sukebei.py +++ b/NyaaPy/sukebei.py @@ -37,4 +37,38 @@ class SukebeiNyaa: soup = BeautifulSoup(r.text, 'html.parser') rows = soup.select('table tr') - return utils.parse_sukebei(rows, limit=number_of_results + 1) \ No newline at end of file + return utils.parse_sukebei(rows, limit=number_of_results + 1) + +class SukebeiPantsu: + BASE_URL = "https://sukebei.pantsu.cat/api" + + # Torrents - GET + def search(keyword, **kwargs): + request = requests.get("{}/search{}".format(SukebeiPantsu.BASE_URL, utils.query_builder(keyword, kwargs))) + + return request.json() + + def view(item_id): + request = requests.get("{}/view/{}".format(SukebeiPantsu.BASE_URL, item_id)) + + return request.json() + + # Torrents - POST + + def upload(): + return "Work in progress!" + + def update(): + return "Work in progress!" + + # Users + + def login(username, password): + login = requests.post("{}/login/".format(SukebeiPantsu.BASE_URL), data={'username': username, 'password': password}) + + return login.json() + + def profile(user_id): + profile = requests.post("{}/profile/".format(SukebeiPantsu.BASE_URL), data={'id': user_id}) + + return profile.json() \ No newline at end of file