From 612087fd74b849525c32dfc4033603808b0c2433 Mon Sep 17 00:00:00 2001 From: Matt Lyon Date: Sun, 3 Nov 2019 10:38:05 +1100 Subject: initial commit for TPB Controller --- tpblite/models/torrents.py | 1 + tpblite/models/utils.py | 2 +- tpblite/tpblite.py | 11 +++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tpblite/models/torrents.py b/tpblite/models/torrents.py index 8567280..9fd40c4 100644 --- a/tpblite/models/torrents.py +++ b/tpblite/models/torrents.py @@ -1,5 +1,6 @@ import re from bs4 import BeautifulSoup +from .utils import Query def fileSizeStrToInt(size_str): diff --git a/tpblite/models/utils.py b/tpblite/models/utils.py index 72409b8..977672b 100644 --- a/tpblite/models/utils.py +++ b/tpblite/models/utils.py @@ -8,7 +8,7 @@ class Query(object): Query object capable of getting html response given a search query and other parameters. ''' - def __init__(self, query, base_url='https://tpb.party', page=0, order=99, category=0): + def __init__(self, query, base_url, page, order, category): self.base_url = base_url segments = ('search', query, str(page), str(order), str(category)) self.url = URL(base_url, segments) diff --git a/tpblite/tpblite.py b/tpblite/tpblite.py index c987e49..c99bfd2 100644 --- a/tpblite/tpblite.py +++ b/tpblite/tpblite.py @@ -1,8 +1,15 @@ from .models.torrents import Torrents, Torrent from .models.utils import Query - - +class TPB(object): + + def __init__(self, base_url='https://tpb.party'): + self.base_url = base_url + + def search(self, query, base_url, page=0, order=99, category=0): + webpage = Query(query, base_url, page=0, order=99, category=0) + return Torrents(webpage) + def run(): q = Query('avengers endgame 1080p') print(q.url) -- cgit v1.2.3