Skip to content

Commit

Permalink
Added published date to solidtorrents
Browse files Browse the repository at this point in the history
  • Loading branch information
ducalex committed Aug 10, 2024
1 parent 286b510 commit 57baa7d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions nova3/engines/solidtorrents.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# VERSION: 2.2
# VERSION: 2.3
# AUTHORS: nKlido

# LICENSING INFORMATION
Expand All @@ -23,6 +23,7 @@
from helpers import retrieve_url
from novaprinter import prettyPrinter
from html.parser import HTMLParser
from datetime import datetime
import math


Expand All @@ -43,6 +44,7 @@ def __init__(self, url):
self.parseSeeders = False
self.parseLeechers = False
self.parseSize = False
self.parseDate = False
self.column = 0
self.torrentReady = False
self.foundSearchStats = False
Expand All @@ -59,7 +61,8 @@ def empty_torrent_info(self):
'seeds': '-1',
'leech': '-1',
'engine_url': self.url,
'desc_link': ''
'desc_link': '',
'pub_date': -1,
}

def handle_starttag(self, tag, attrs):
Expand Down Expand Up @@ -99,6 +102,9 @@ def handle_starttag(self, tag, attrs):
if (self.foundStats and tag == 'font' and self.column == 4):
self.parseLeechers = True

if (self.foundStats and tag == 'div' and self.column == 5):
self.parseDate = True

if (self.foundResult and 'dl-magnet' in params.get('class', '') and tag == 'a'):
self.torrent_info['link'] = params.get('href')
self.foundResult = False
Expand Down Expand Up @@ -133,6 +139,18 @@ def handle_data(self, data):
if (self.parseLeechers):
self.torrent_info['leech'] = data
self.parseLeechers = False

if (self.parseDate):
try:
# I chose not to use strptime here because it depends on user's locale
months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun',
'jul', 'aug', 'sep', 'oct', 'nov', 'dec']
[month, day, year] = data.replace(',', '').lower().split()
date = datetime(int(year), int(months.index(month) + 1), int(day))
self.torrent_info['pub_date'] = int(date.timestamp())
except Exception:
self.torrent_info['pub_date'] = -1
self.parseDate = False
self.foundStats = False

def request(self, searchTerm, category, page=1):
Expand Down
2 changes: 1 addition & 1 deletion nova3/engines/versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ eztv: 1.14
jackett: 4.0
limetorrents: 4.7
piratebay: 3.3
solidtorrents: 2.2
solidtorrents: 2.3
torlock: 2.23
torrentproject: 1.3
torrentscsv: 1.4

0 comments on commit 57baa7d

Please sign in to comment.