Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions torrentgalaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ class TorrentGalaxyParser(HTMLParser):
count_div, = -1,
get_size, get_seeds, get_leechs = False, False, False
this_record = {}
url = 'https://torrentgalaxy.to'

def __init__(self, url):
HTMLParser.__init__(self)
self.url = url

def handle_starttag(self, tag, attrs):
if tag == self.DIV:
my_attrs = dict(attrs)
# if (my_attrs.get('class') == 'tgxtablerow txlight'):
if my_attrs.get('class') and 'tgxtablerow' in my_attrs.get('class'):
self.count_div = 0
self.this_record = {}
Expand Down Expand Up @@ -89,20 +91,20 @@ def handle_data(self, data):

def do_search(self, url):
webpage = retrieve_url(url)
tgParser = self.TorrentGalaxyParser()
tgParser = self.TorrentGalaxyParser(url)
tgParser.feed(webpage)

def search(self, what, cat='all'):
query = str(what).replace(r' ', '+')
search_url = 'https://torrentgalaxy.to/torrents.php?'
search_url = self.url + 'torrents.php?'
full_url = \
search_url + \
self.supported_categories[cat.lower()] + \
'sort=seeders&order=desc&search=' + \
query

webpage = retrieve_url(full_url)
tgParser = self.TorrentGalaxyParser()
tgParser = self.TorrentGalaxyParser(self.url)
tgParser.feed(webpage)

all_results_re = re.compile(r'steelblue[^>]+>(.*?)<')
Expand All @@ -115,7 +117,6 @@ def search(self, what, cat='all'):
t = threading.Thread(args=(this_url,), target=self.do_search)
threads.append(t)
t.start()
# self.do_search(this_url)

for thread in threads:
thread.join()
Expand Down