From 55300aef48335969f5615f44e6ac5e1bf05667ec Mon Sep 17 00:00:00 2001 From: Loic Coyle Date: Thu, 20 Feb 2020 01:10:57 +0100 Subject: added top --- tpblite/tpblite.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tpblite/tpblite.py') diff --git a/tpblite/tpblite.py b/tpblite/tpblite.py index 1ec3991..abd59ae 100644 --- a/tpblite/tpblite.py +++ b/tpblite/tpblite.py @@ -61,3 +61,19 @@ class TPB: q = QueryParser.browse(self.base_url, category, page, order) self._search_url = q.url return Torrents(q.html_source) + + def top(self, category: int=0, last_48=False): + """Get the top torrents of a category and return a list of Torrents + + Args: + category: Restrict search to specific category, for list of categories see + tpblite.models.constants.CATEGORIES + last_48: wether to fetch the top torrent in the last 48 hours or the overall top + + Return: + Torrent object + """ + q = QueryParser.top(self.base_url, category, last_48) + self._search_url = q.url + return Torrents(q.html_source) + -- cgit v1.2.3 From e2a941fbfc032e1aa57994879c43ab0585324346 Mon Sep 17 00:00:00 2001 From: Loic Coyle Date: Sat, 22 Aug 2020 03:40:37 +0200 Subject: PEP8 and remove unused import --- tpblite/tpblite.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'tpblite/tpblite.py') diff --git a/tpblite/tpblite.py b/tpblite/tpblite.py index abd59ae..b4028b6 100644 --- a/tpblite/tpblite.py +++ b/tpblite/tpblite.py @@ -1,11 +1,10 @@ from typing import Optional -from .models.torrents import Torrents, Torrent +from .models.torrents import Torrents from .models.utils import QueryParser class TPB: - def __init__(self, base_url: str = "https://tpb.party"): """ThePirateBay Object @@ -62,7 +61,7 @@ class TPB: self._search_url = q.url return Torrents(q.html_source) - def top(self, category: int=0, last_48=False): + def top(self, category: int = 0, last_48: bool = False): """Get the top torrents of a category and return a list of Torrents Args: -- cgit v1.2.3