aboutsummaryrefslogtreecommitdiffstats
path: root/tpblite/tpblite.py
diff options
context:
space:
mode:
authorMatt <32886639+mattlyon93@users.noreply.github.com>2020-08-23 20:42:15 +1000
committerGitHub <noreply@github.com>2020-08-23 20:42:15 +1000
commitfb301e7a1bdb4e010bc7fb1e2da353a4808fce7a (patch)
treef6c522c749fbb345c6db7c1544dfd2c319e2018c /tpblite/tpblite.py
parentce541a018328e270f6d190a53b2a52a6f00649b9 (diff)
parente2a941fbfc032e1aa57994879c43ab0585324346 (diff)
downloadtpb-lite-fb301e7a1bdb4e010bc7fb1e2da353a4808fce7a.tar.gz
tpb-lite-fb301e7a1bdb4e010bc7fb1e2da353a4808fce7a.tar.bz2
tpb-lite-fb301e7a1bdb4e010bc7fb1e2da353a4808fce7a.zip
Merge pull request #3 from loiccoyle/top
add a top() method to the TPB class
Diffstat (limited to 'tpblite/tpblite.py')
-rw-r--r--tpblite/tpblite.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/tpblite/tpblite.py b/tpblite/tpblite.py
index 1ec3991..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
@@ -61,3 +60,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: bool = 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)
+