-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
17 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
#VERSION: 2.22 | ||
#VERSION: 2.23 | ||
# AUTHORS: Douman ([email protected]) | ||
# CONTRIBUTORS: Diego de las Heras ([email protected]) | ||
|
||
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 = {} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters