Fix Pylint errors (optimized code)

This commit is contained in:
Juan José Salvador
2018-03-08 23:33:54 +01:00
parent 5691782c8c
commit 1e2ba25882
6 changed files with 55 additions and 45 deletions

View File

@@ -1,36 +1,39 @@
import requests
from NyaaPy.utils import Utils as utils
from NyaaPy.utils import Utils
utils = Utils()
class Pantsu:
BASE_URL = "https://nyaa.pantsu.cat/api"
def __init__(self):
self.BASE_URL = "https://nyaa.pantsu.cat/api"
# Torrents - GET
def search(keyword, **kwargs):
request = requests.get("{}/search{}".format(Pantsu.BASE_URL, utils.query_builder(keyword, kwargs)))
def search(self, keyword, **kwargs):
request = requests.get("{}/search{}".format(self.BASE_URL, utils.query_builder(keyword, kwargs)))
return request.json()
def view(item_id):
request = requests.get("{}/view/{}".format(Pantsu.BASE_URL, item_id))
def view(self, item_id):
request = requests.get("{}/view/{}".format(self.BASE_URL, item_id))
return request.json()
# Torrents - POST
def upload():
def upload(self):
return "Work in progress!"
def update():
def update(self):
return "Work in progress!"
# Users
def login(username, password):
login = requests.post("{}/login/".format(Pantsu.BASE_URL), data={'username': username, 'password': password})
def login(self, username, password):
login = requests.post("{}/login/".format(self.BASE_URL), data={'username': username, 'password': password})
return login.json()
def profile(user_id):
profile = requests.post("{}/profile/".format(Pantsu.BASE_URL), data={'id': user_id})
def profile(self, user_id):
profile = requests.post("{}/profile/".format(self.BASE_URL), data={'id': user_id})
return profile.json()