From 68c4e36803deb7d93972397bc7c47225c176a079 Mon Sep 17 00:00:00 2001 From: Alex Duchesne Date: Tue, 13 Aug 2024 16:31:41 -0400 Subject: [PATCH] Added date field to eztv They don't provide a convenient format unfortunately, and my parsing might not be exhaustive. It's also not very accurate when all you have to go by is "1 year ago" But it's certainly better than nothing --- nova3/engines/eztv.py | 22 +++++++++++++++++++++- nova3/engines/versions.txt | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/nova3/engines/eztv.py b/nova3/engines/eztv.py index ea45d5d..0cca6c4 100644 --- a/nova3/engines/eztv.py +++ b/nova3/engines/eztv.py @@ -1,7 +1,9 @@ -#VERSION: 1.14 +#VERSION: 1.16 # AUTHORS: nindogo # CONTRIBUTORS: Diego de las Heras (ngosang@hotmail.es) +import re +from datetime import datetime, timedelta from html.parser import HTMLParser from novaprinter import prettyPrinter @@ -35,6 +37,7 @@ def handle_starttag(self, tag, attrs): self.current_item['leech'] = -1 self.current_item['size'] = -1 self.current_item['engine_url'] = self.url + self.current_item['pub_date'] = -1 if (tag == self.A and self.in_table_row and params.get('class') == 'magnet'): @@ -54,6 +57,23 @@ def handle_data(self, data): elif self.in_table_row and data.isnumeric(): self.current_item['seeds'] = int(data) + elif self.in_table_row: # Check for a relative time + if m := re.match(r'(\d+)h\s+(\d+)m', data): + date = datetime.now() - timedelta(hours=int(m.group(1)), minutes=int(m.group(2))) + self.current_item['pub_date'] = int(date.timestamp()) + elif m := re.match(r'(\d+)d\s+(\d+)h', data): + date = datetime.now() - timedelta(days=int(m.group(1)), hours=int(m.group(2))) + self.current_item['pub_date'] = int(date.timestamp()) + elif m := re.match(r'(\d+)\s+weeks?', data): + date = datetime.now() - timedelta(weeks=int(m.group(1))) + self.current_item['pub_date'] = int(date.timestamp()) + elif m := re.match(r'(\d+)\s+mo', data): + date = datetime.now() - timedelta(weeks=int(m.group(1)) * 4) + self.current_item['pub_date'] = int(date.timestamp()) + elif m := re.match(r'(\d+)\s+years?', data): + date = datetime.now() - timedelta(weeks=int(m.group(1)) * 52) + self.current_item['pub_date'] = int(date.timestamp()) + def handle_endtag(self, tag): if self.in_table_row and tag == self.TR: prettyPrinter(self.current_item) diff --git a/nova3/engines/versions.txt b/nova3/engines/versions.txt index 9bf4c79..3b7ef9d 100644 --- a/nova3/engines/versions.txt +++ b/nova3/engines/versions.txt @@ -1,4 +1,4 @@ -eztv: 1.14 +eztv: 1.16 jackett: 4.0 limetorrents: 4.7 piratebay: 3.3