diff options
author | Matt <32886639+mattlyon93@users.noreply.github.com> | 2020-08-23 20:42:15 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-23 20:42:15 +1000 |
commit | fb301e7a1bdb4e010bc7fb1e2da353a4808fce7a (patch) | |
tree | f6c522c749fbb345c6db7c1544dfd2c319e2018c /tpblite/models | |
parent | ce541a018328e270f6d190a53b2a52a6f00649b9 (diff) | |
parent | e2a941fbfc032e1aa57994879c43ab0585324346 (diff) | |
download | tpb-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/models')
-rw-r--r-- | tpblite/models/utils.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tpblite/models/utils.py b/tpblite/models/utils.py index 6c479d4..b9126e9 100644 --- a/tpblite/models/utils.py +++ b/tpblite/models/utils.py @@ -42,6 +42,16 @@ class QueryParser: segments = ("browse", str(category), str(page), str(order), "0") return cls(base_url, segments) + @classmethod + def top(cls: Type[T], base_url: str, category: int, last_48: bool) -> T: + if category == 0: + category = "all" + if last_48: + segments = ("top", "48h" + str(category)) + else: + segments = ("top", str(category)) + return cls(base_url, segments) + def _sendRequest(self): req = Request(self.url, headers=headers()) return urlopen(req).read() |