diff --git a/nova3/engines/torrentproject.py b/nova3/engines/torrentproject.py index ddc148f..e736871 100644 --- a/nova3/engines/torrentproject.py +++ b/nova3/engines/torrentproject.py @@ -1,10 +1,11 @@ -#VERSION: 1.3 +#VERSION: 1.4 #AUTHORS: mauricci from helpers import retrieve_url from novaprinter import prettyPrinter import re +from datetime import datetime from html.parser import HTMLParser from urllib.parse import unquote @@ -23,7 +24,14 @@ def __init__(self, url): self.insideDataDiv = False self.pageComplete = False self.spanCount = -1 - self.infoMap = {'name': 0, 'torrLink': 0, 'size': 5, 'seeds': 2, 'leech': 3} + self.infoMap = { + "name": 0, + "torrLink": 0, + "seeds": 2, + "leech": 3, + "pub_date": 4, + "size": 5, + } self.fullResData = [] self.pageRes = [] self.singleResData = self.get_single_data() @@ -36,7 +44,8 @@ def get_single_data(self): 'size': '-1', 'link': '-1', 'desc_link': '-1', - 'engine_url': self.url + 'engine_url': self.url, + 'pub_date': '-1', } def handle_starttag(self, tag, attrs): @@ -68,6 +77,12 @@ def handle_endtag(self, tag): # ignore those with link and desc_link equals to -1 if self.singleResData['desc_link'] != '-1' \ or self.singleResData['link'] != '-1': + try: + date_string = self.singleResData['pub_date'] + date = datetime.strptime(date_string, '%Y-%m-%d %H:%M:%S') + self.singleResData['pub_date'] = int(date.timestamp()) + except Exception: + pass try: prettyPrinter(self.singleResData) except Exception: @@ -100,7 +115,7 @@ def search(self, what, cat='all'): what = what.replace('%20', '+') # analyze first 5 pages of results for currPage in range(0, 5): - url = self.url + '?t={0}&p={1}'.format(what, currPage) + url = self.url + '/browse?t={0}&p={1}'.format(what, currPage) html = retrieve_url(url) parser.feed(html) if len(parser.pageRes) <= 0: diff --git a/nova3/engines/versions.txt b/nova3/engines/versions.txt index c276897..994f495 100644 --- a/nova3/engines/versions.txt +++ b/nova3/engines/versions.txt @@ -4,5 +4,5 @@ limetorrents: 4.7 piratebay: 3.3 solidtorrents: 2.3 torlock: 2.23 -torrentproject: 1.3 +torrentproject: 1.4 torrentscsv: 1.4