Fix infinite start loop, fix date parsing on alpine, switch to alpine
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
4e38abaf94
commit
a6ea87bd1c
@ -1,4 +1,4 @@
|
|||||||
FROM python:slim
|
FROM python:alpine
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
ENV LANG C.UTF-8
|
ENV LANG C.UTF-8
|
||||||
@ -6,8 +6,5 @@ COPY pynyaata /app/pynyaata
|
|||||||
COPY requirements.txt /app
|
COPY requirements.txt /app
|
||||||
COPY *.py /app/
|
COPY *.py /app/
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apt-get update && apt-get -y upgrade && apt-get -y install locales && \
|
RUN apk add build-base bash && pip install -r requirements.txt
|
||||||
printf "en_US.UTF-8 UTF-8\nfr_FR.UTF-8 UTF-8\n" > /etc/locale.gen && \
|
|
||||||
locale-gen && rm -rf /var/lib/apt/lists/* && \
|
|
||||||
pip install -r requirements.txt
|
|
||||||
CMD ["python", "run.py"]
|
CMD ["python", "run.py"]
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import locale
|
|
||||||
import re
|
import re
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
@ -9,6 +8,7 @@ from urllib.parse import quote
|
|||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from cloudscraper import create_scraper
|
from cloudscraper import create_scraper
|
||||||
|
from dateparser import parse
|
||||||
from requests import RequestException
|
from requests import RequestException
|
||||||
|
|
||||||
from pynyaata.config import IS_DEBUG, MYSQL_ENABLED, CACHE_TIMEOUT, BLACKLIST_WORDS
|
from pynyaata.config import IS_DEBUG, MYSQL_ENABLED, CACHE_TIMEOUT, BLACKLIST_WORDS
|
||||||
@ -307,22 +307,6 @@ class Pantsu(Connector):
|
|||||||
|
|
||||||
valid_trs = valid_trs + 1
|
valid_trs = valid_trs + 1
|
||||||
href = '%s%s' % (self.base_url, url['href'])
|
href = '%s%s' % (self.base_url, url['href'])
|
||||||
splitted_date = re.search(r'(\d+)/(\d+)/(\d+), (\d+):(\d+):(\d+)\s(\w+)\s.+', tds[7]['title'])
|
|
||||||
|
|
||||||
current_locale = locale.getlocale()
|
|
||||||
locale.setlocale(locale.LC_ALL, ('en_US', 'UTF-8'))
|
|
||||||
formatted_date = datetime.strptime(
|
|
||||||
'%s/%s/%s, %s:%s:%s %s' % (
|
|
||||||
splitted_date.group(1),
|
|
||||||
splitted_date.group(2),
|
|
||||||
splitted_date.group(3),
|
|
||||||
splitted_date.group(4).zfill(2).replace('00', '12'),
|
|
||||||
splitted_date.group(5),
|
|
||||||
splitted_date.group(6),
|
|
||||||
splitted_date.group(7)
|
|
||||||
), '%m/%d/%Y, %I:%M:%S %p'
|
|
||||||
)
|
|
||||||
locale.setlocale(locale.LC_ALL, current_locale)
|
|
||||||
|
|
||||||
self.data.append({
|
self.data.append({
|
||||||
'lang': self.get_lang(url_safe),
|
'lang': self.get_lang(url_safe),
|
||||||
@ -332,7 +316,7 @@ class Pantsu(Connector):
|
|||||||
'link': tds[2].decode_contents().replace('icon-magnet', 'fa fa-fw fa-magnet').replace(
|
'link': tds[2].decode_contents().replace('icon-magnet', 'fa fa-fw fa-magnet').replace(
|
||||||
'icon-floppy', 'fa fa-fw fa-download'),
|
'icon-floppy', 'fa fa-fw fa-download'),
|
||||||
'size': tds[3].string,
|
'size': tds[3].string,
|
||||||
'date': formatted_date,
|
'date': parse(tds[7]['title']),
|
||||||
'seeds': check_seeds,
|
'seeds': check_seeds,
|
||||||
'leechs': tds[5].string,
|
'leechs': tds[5].string,
|
||||||
'downloads': check_downloads,
|
'downloads': check_downloads,
|
||||||
@ -502,11 +486,6 @@ class AnimeUltime(Connector):
|
|||||||
|
|
||||||
tds = tr.findAll('td')
|
tds = tr.findAll('td')
|
||||||
link = tds[0].a
|
link = tds[0].a
|
||||||
|
|
||||||
current_locale = locale.getlocale()
|
|
||||||
locale.setlocale(locale.LC_ALL, ('fr_FR', 'UTF-8'))
|
|
||||||
release_date = datetime.strptime(h3s[i].string, '%A %d %B %Y : ')
|
|
||||||
locale.setlocale(locale.LC_ALL, current_locale)
|
|
||||||
href = '%s/%s' % (self.base_url, link['href'])
|
href = '%s/%s' % (self.base_url, link['href'])
|
||||||
|
|
||||||
self.data.append({
|
self.data.append({
|
||||||
@ -514,7 +493,7 @@ class AnimeUltime(Connector):
|
|||||||
'href': '%s/%s' % (self.base_url, link['href']),
|
'href': '%s/%s' % (self.base_url, link['href']),
|
||||||
'name': link.string,
|
'name': link.string,
|
||||||
'type': tds[4].string,
|
'type': tds[4].string,
|
||||||
'date': release_date,
|
'date': parse(h3s[i].string[:-3], languages=['fr']),
|
||||||
'class': self.color if link_exist_in_db(href) else ''
|
'class': self.color if link_exist_in_db(href) else ''
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -8,3 +8,4 @@ requests==2.23.0
|
|||||||
beautifulsoup4==4.9.0
|
beautifulsoup4==4.9.0
|
||||||
python-dotenv==0.12.0
|
python-dotenv==0.12.0
|
||||||
cloudscraper==1.2.33
|
cloudscraper==1.2.33
|
||||||
|
dateparser==0.7.4
|
||||||
|
9
run.py
9
run.py
@ -1,12 +1,3 @@
|
|||||||
from logging import getLogger
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
from pynyaata.config import app, APP_PORT, IS_DEBUG
|
from pynyaata.config import app, APP_PORT, IS_DEBUG
|
||||||
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
app.run('0.0.0.0', APP_PORT, IS_DEBUG)
|
app.run('0.0.0.0', APP_PORT, IS_DEBUG)
|
||||||
except Exception as e:
|
|
||||||
getLogger().exception(e)
|
|
||||||
sleep(10)
|
|
||||||
pass
|
|
||||||
|
Reference in New Issue
Block a user