Fix crash date ?
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Michel Roux 2020-04-13 21:49:09 +02:00
parent 4d0a312c1a
commit ba953ccd58

View File

@ -6,6 +6,7 @@ from functools import wraps
from logging import getLogger
from urllib.parse import quote
import pytz
from bs4 import BeautifulSoup
from cloudscraper import create_scraper
from dateparser import parse
@ -14,6 +15,7 @@ from requests import RequestException
from pynyaata.config import IS_DEBUG, MYSQL_ENABLED, CACHE_TIMEOUT, BLACKLIST_WORDS
scraper = create_scraper()
utc = pytz.UTC
class ConnectorReturn(Enum):
@ -252,7 +254,7 @@ class Nyaa(Connector):
'link': tds[2].decode_contents().replace('/download/',
'%s%s' % (self.base_url, '/download/')),
'size': tds[3].string,
'date': datetime.strptime(tds[4].string, '%Y-%m-%d %H:%M'),
'date': utc.localize(datetime.strptime(tds[4].string, '%Y-%m-%d %H:%M')),
'seeds': check_seeds,
'leechs': tds[6].string,
'downloads': check_downloads,
@ -316,7 +318,7 @@ class Pantsu(Connector):
'link': tds[2].decode_contents().replace('icon-magnet', 'fa fa-fw fa-magnet').replace(
'icon-floppy', 'fa fa-fw fa-download'),
'size': tds[3].string,
'date': parse(tds[7]['title']),
'date': utc.localize(parse(tds[7]['title'])),
'seeds': check_seeds,
'leechs': tds[5].string,
'downloads': check_downloads,
@ -385,7 +387,7 @@ class YggTorrent(Connector):
'<i class="fa fa-fw fa-download"></i>'
'</a>' % (self.base_url, re.search(r'/(\d+)', url['href']).group(1)),
'size': tds[5].string,
'date': datetime.fromtimestamp(int(tds[4].div.string)),
'date': utc.localize(datetime.fromtimestamp(int(tds[4].div.string))),
'seeds': check_seeds,
'leechs': tds[8].string,
'downloads': check_downloads,
@ -450,7 +452,7 @@ class AnimeUltime(Connector):
'href': '%s/%s' % (self.base_url, url['href']),
'name': url.get_text(),
'type': tds[1].string,
'date': datetime.fromtimestamp(0),
'date': utc.localize(datetime.fromtimestamp(0)),
'class': self.color if link_exist_in_db(href) else ''
})
else:
@ -464,7 +466,7 @@ class AnimeUltime(Connector):
'href': '%s/file-0-1/%s' % (self.base_url, player[0]['data-serie']),
'name': name[0].string,
'type': ani_type[0].string.replace(':', ''),
'date': datetime.fromtimestamp(0),
'date': utc.localize(datetime.fromtimestamp(0)),
'class': self.color if link_exist_in_db(href) else ''
})
@ -493,7 +495,7 @@ class AnimeUltime(Connector):
'href': '%s/%s' % (self.base_url, link['href']),
'name': link.string,
'type': tds[4].string,
'date': parse(h3s[i].string[:-3], languages=['fr']),
'date': utc.localize(parse(h3s[i].string[:-3], languages=['fr'])),
'class': self.color if link_exist_in_db(href) else ''
})