Cleanup based on pylint rules
This commit is contained in:
@@ -37,22 +37,26 @@ class Nyaa:
|
|||||||
user_uri = ""
|
user_uri = ""
|
||||||
|
|
||||||
if page > 0:
|
if page > 0:
|
||||||
uri = "{}/{}?f={}&c={}_{}&q={}&p={}".format(url, user_uri, filters, category, subcategory, keyword, page)
|
uri = f"{url}/{user_uri}?f={filters}&c={category}_{subcategory}&q={keyword}&p={page}"
|
||||||
else:
|
else:
|
||||||
uri = "{}/{}?f={}&c={}_{}&q={}".format(url, user_uri, filters, category, subcategory, keyword)
|
uri = f"{url}/{user_uri}?f={filters}&c={category}_{subcategory}&q={keyword}"
|
||||||
|
|
||||||
if not user:
|
if not user:
|
||||||
uri += "&page=rss"
|
uri += "&page=rss"
|
||||||
|
|
||||||
r = requests.get(uri)
|
http_response = requests.get(uri)
|
||||||
|
|
||||||
r.raise_for_status()
|
http_response.raise_for_status()
|
||||||
|
|
||||||
if user:
|
if user:
|
||||||
json_data = utils.parse_nyaa(request_text=r.text, limit=None, site=self.SITE)
|
json_data = utils.parse_nyaa(
|
||||||
|
request_text=http_response.text,
|
||||||
|
limit=None,
|
||||||
|
site=self.SITE
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
json_data = utils.parse_nyaa_rss(
|
json_data = utils.parse_nyaa_rss(
|
||||||
request_text=r.text,
|
request_text=http_response.text,
|
||||||
limit=None,
|
limit=None,
|
||||||
site=self.SITE
|
site=self.SITE
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -84,6 +84,9 @@ def nyaa_categories(b):
|
|||||||
|
|
||||||
|
|
||||||
def parse_nyaa_rss(request_text, limit, site):
|
def parse_nyaa_rss(request_text, limit, site):
|
||||||
|
"""
|
||||||
|
Extracts torrent information from a given rss response.
|
||||||
|
"""
|
||||||
root = etree.fromstring(request_text)
|
root = etree.fromstring(request_text)
|
||||||
torrents = []
|
torrents = []
|
||||||
|
|
||||||
@@ -273,6 +276,9 @@ def sukebei_categories(b):
|
|||||||
|
|
||||||
|
|
||||||
def magnet_builder(info_hash, title):
|
def magnet_builder(info_hash, title):
|
||||||
|
"""
|
||||||
|
Generates a magnet link using the info_hash and title of a given file.
|
||||||
|
"""
|
||||||
known_trackers = [
|
known_trackers = [
|
||||||
"http://nyaa.tracker.wf:7777/announce",
|
"http://nyaa.tracker.wf:7777/announce",
|
||||||
"udp://open.stealth.si:80/announce",
|
"udp://open.stealth.si:80/announce",
|
||||||
|
|||||||
Reference in New Issue
Block a user