From e1ac066c5231c2937ac520d400093c2a86e55b39 Mon Sep 17 00:00:00 2001 From: Alex Duchesne Date: Tue, 2 Jul 2024 13:34:55 -0400 Subject: [PATCH] Added published date to torlock --- nova3/engines/torlock.py | 18 ++++++++++++++++-- nova3/engines/versions.txt | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/nova3/engines/torlock.py b/nova3/engines/torlock.py index 3512158..049f594 100644 --- a/nova3/engines/torlock.py +++ b/nova3/engines/torlock.py @@ -1,9 +1,10 @@ -#VERSION: 2.22 +#VERSION: 2.23 # AUTHORS: Douman (custparasite@gmx.se) # CONTRIBUTORS: Diego de las Heras (ngosang@hotmail.es) from re import compile as re_compile from html.parser import HTMLParser +from datetime import datetime, timedelta from novaprinter import prettyPrinter from helpers import retrieve_url, download_file @@ -34,7 +35,8 @@ def __init__(self, url): self.item_bad = False # set to True for malicious links self.current_item = None # dict for found item self.item_name = None # key's name in current_item dict - self.parser_class = {"ts": "size", + self.parser_class = {"td": "pub_date", + "ts": "size", "tul": "seeds", "tdl": "leech"} @@ -76,6 +78,18 @@ def handle_endtag(self, tag): elif self.item_found and tag == "tr": self.item_found = False if not self.item_bad: + try: + # Date seems like it can be Today, Yesterday, or M/D/YYYY (Timezone unknown) + if self.current_item["pub_date"] == "Today": + date = datetime.now() + elif self.current_item["pub_date"] == "Yesterday": + date = datetime.now() - timedelta(days=1) + else: + date = datetime.strptime(self.current_item["pub_date"], '%m/%d/%Y') + date = date.replace(hour=0, minute=0, second=0, microsecond=0) # We have no time info + self.current_item["pub_date"] = int(date.timestamp()) + except: + self.current_item["pub_date"] = -1 prettyPrinter(self.current_item) self.current_item = {} diff --git a/nova3/engines/versions.txt b/nova3/engines/versions.txt index bfeb834..e222441 100644 --- a/nova3/engines/versions.txt +++ b/nova3/engines/versions.txt @@ -3,6 +3,6 @@ jackett: 4.0 limetorrents: 4.7 piratebay: 3.2 solidtorrents: 2.1 -torlock: 2.22 +torlock: 2.23 torrentproject: 1.2 torrentscsv: 1.2