First pass on latest
This commit is contained in:
parent
fa57752714
commit
5de3a85231
11
app.py
11
app.py
@ -1,10 +1,11 @@
|
|||||||
|
from operator import itemgetter
|
||||||
from os import environ
|
from os import environ
|
||||||
|
|
||||||
from flask import redirect, render_template, url_for, request
|
from flask import redirect, render_template, url_for, request
|
||||||
|
|
||||||
from config import app, auth
|
from config import app, auth
|
||||||
from connectors import *
|
from connectors import *
|
||||||
from models import SearchForm
|
from models import SearchForm, AnimeTitle
|
||||||
|
|
||||||
|
|
||||||
@auth.verify_password
|
@auth.verify_password
|
||||||
@ -46,13 +47,15 @@ def latest():
|
|||||||
]
|
]
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
for torrent in torrents:
|
for torrent in torrents:
|
||||||
results = results + torrent.data
|
results = results + torrent.data
|
||||||
|
results.sort(key=itemgetter('date'))
|
||||||
|
|
||||||
print(results)
|
for keyword in AnimeTitle.query.all():
|
||||||
|
for result in results:
|
||||||
|
result['name'] = Connector.boldify(result['name'], keyword)
|
||||||
|
|
||||||
return 'Hello!'
|
return render_template('latest.html', form=SearchForm(), torrents=results)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/list')
|
@app.route('/list')
|
||||||
|
@ -130,9 +130,10 @@ class Connector(ABC):
|
|||||||
else:
|
else:
|
||||||
return ConnectorLang.JP
|
return ConnectorLang.JP
|
||||||
|
|
||||||
def boldify(self, str_to_replace):
|
@staticmethod
|
||||||
if self.query:
|
def boldify(str_to_replace, keyword):
|
||||||
return re.sub('(%s)' % self.query, r'<b>\1</b>', str_to_replace, flags=re.IGNORECASE)
|
if keyword:
|
||||||
|
return re.sub('(%s)' % keyword, r'<b>\1</b>', str_to_replace, flags=re.IGNORECASE)
|
||||||
else:
|
else:
|
||||||
return str_to_replace
|
return str_to_replace
|
||||||
|
|
||||||
@ -190,15 +191,16 @@ class Nyaa(Connector):
|
|||||||
href = '%s%s' % (self.base_url, url['href'])
|
href = '%s%s' % (self.base_url, url['href'])
|
||||||
|
|
||||||
self.data.append({
|
self.data.append({
|
||||||
|
'self': self,
|
||||||
'lang': self.get_lang(url.string),
|
'lang': self.get_lang(url.string),
|
||||||
'href': href,
|
'href': href,
|
||||||
'name': self.boldify(url.string),
|
'name': self.boldify(url.string, self.query),
|
||||||
'comment': str(urls[0]).replace('/view/',
|
'comment': str(urls[0]).replace('/view/',
|
||||||
'%s%s' % (self.base_url, '/view/')) if has_comment else '',
|
'%s%s' % (self.base_url, '/view/')) if has_comment else '',
|
||||||
'link': tds[2].decode_contents().replace('/download/',
|
'link': tds[2].decode_contents().replace('/download/',
|
||||||
'%s%s' % (self.base_url, '/download/')),
|
'%s%s' % (self.base_url, '/download/')),
|
||||||
'size': tds[3].string,
|
'size': tds[3].string,
|
||||||
'date': '%s:00' % tds[4].string,
|
'date': datetime.strptime(tds[4].string, '%Y-%m-%d %H:%M'),
|
||||||
'seeds': check_seeds,
|
'seeds': check_seeds,
|
||||||
'leechs': tds[6].string,
|
'leechs': tds[6].string,
|
||||||
'downloads': check_downloads,
|
'downloads': check_downloads,
|
||||||
@ -254,19 +256,34 @@ 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[1],
|
||||||
|
splitted_date[2],
|
||||||
|
splitted_date[3],
|
||||||
|
splitted_date[4].zfill(2).replace('00', '12'),
|
||||||
|
splitted_date[5],
|
||||||
|
splitted_date[6],
|
||||||
|
splitted_date[7]
|
||||||
|
), '%m/%d/%Y, %I:%M:%S %p'
|
||||||
|
)
|
||||||
|
locale.setlocale(locale.LC_ALL, current_locale)
|
||||||
|
|
||||||
self.data.append({
|
self.data.append({
|
||||||
|
'self': self,
|
||||||
'lang': self.get_lang(url.string),
|
'lang': self.get_lang(url.string),
|
||||||
'href': href,
|
'href': href,
|
||||||
'name': self.boldify(url.string),
|
'name': self.boldify(url.string, self.query),
|
||||||
'comment': '',
|
'comment': '',
|
||||||
'link': tds[2].decode_contents()
|
'link': tds[2].decode_contents()
|
||||||
.replace('icon-magnet', 'fa fa-fw fa-magnet')
|
.replace('icon-magnet', 'fa fa-fw fa-magnet')
|
||||||
.replace('icon-floppy', 'fa fa-fw fa-download'),
|
.replace('icon-floppy', 'fa fa-fw fa-download'),
|
||||||
'size': tds[3].string,
|
'size': tds[3].string,
|
||||||
'date': datetime
|
'date': formatted_date,
|
||||||
.strptime(tds[7]['title'], '%m/%d/%Y, %I:%M:%S %p %Z+0')
|
|
||||||
.strftime('%Y-%m-%d %H:%M:%S'),
|
|
||||||
'seeds': check_seeds,
|
'seeds': check_seeds,
|
||||||
'leechs': tds[5].string,
|
'leechs': tds[5].string,
|
||||||
'downloads': check_downloads,
|
'downloads': check_downloads,
|
||||||
@ -325,16 +342,17 @@ class YggTorrent(Connector):
|
|||||||
valid_trs = valid_trs + 1
|
valid_trs = valid_trs + 1
|
||||||
|
|
||||||
self.data.append({
|
self.data.append({
|
||||||
|
'self': self,
|
||||||
'lang': self.get_lang(url.string),
|
'lang': self.get_lang(url.string),
|
||||||
'href': url['href'],
|
'href': url['href'],
|
||||||
'name': self.boldify(url.string),
|
'name': self.boldify(url.string, self.query),
|
||||||
'comment': '<a href="%s#comm" target="_blank"><i class="fa fa-comments-o"></i>%s</a>' %
|
'comment': '<a href="%s#comm" target="_blank"><i class="fa fa-comments-o"></i>%s</a>' %
|
||||||
(url['href'], tds[3].string),
|
(url['href'], tds[3].string),
|
||||||
'link': '<a href="%s/engine/download_torrent?id=%s">'
|
'link': '<a href="%s/engine/download_torrent?id=%s">'
|
||||||
'<i class="fa fa-fw fa-download"></i>'
|
'<i class="fa fa-fw fa-download"></i>'
|
||||||
'</a>' % (self.base_url, re.search(r'/(\d+)', url['href']).group(1)),
|
'</a>' % (self.base_url, re.search(r'/(\d+)', url['href']).group(1)),
|
||||||
'size': tds[5].string,
|
'size': tds[5].string,
|
||||||
'date': datetime.fromtimestamp(int(tds[4].div.string)).strftime('%Y-%m-%d %H:%M:%S'),
|
'date': datetime.fromtimestamp(int(tds[4].div.string)),
|
||||||
'seeds': check_seeds,
|
'seeds': check_seeds,
|
||||||
'leechs': tds[8].string,
|
'leechs': tds[8].string,
|
||||||
'downloads': check_downloads,
|
'downloads': check_downloads,
|
||||||
@ -368,7 +386,7 @@ class AnimeUltime(Connector):
|
|||||||
sort_type = 'search'
|
sort_type = 'search'
|
||||||
|
|
||||||
if self.return_type is ConnectorReturn.HISTORY:
|
if self.return_type is ConnectorReturn.HISTORY:
|
||||||
page_date = datetime.now() - timedelta((self.page - 1) * 365 / 12)
|
page_date = datetime.now() - timedelta((int(self.page) - 1) * 365 / 12)
|
||||||
from_date = page_date.strftime('%m%Y')
|
from_date = page_date.strftime('%m%Y')
|
||||||
sort_type = 'history'
|
sort_type = 'history'
|
||||||
|
|
||||||
@ -398,6 +416,7 @@ class AnimeUltime(Connector):
|
|||||||
href = '%s/%s' % (self.base_url, url['href'])
|
href = '%s/%s' % (self.base_url, url['href'])
|
||||||
|
|
||||||
self.data.append({
|
self.data.append({
|
||||||
|
'self': self,
|
||||||
'lang': ConnectorLang.JP,
|
'lang': ConnectorLang.JP,
|
||||||
'href': '%s/%s' % (self.base_url, url['href']),
|
'href': '%s/%s' % (self.base_url, url['href']),
|
||||||
'name': url.decode_contents(),
|
'name': url.decode_contents(),
|
||||||
@ -411,9 +430,10 @@ class AnimeUltime(Connector):
|
|||||||
href = '%s/file-0-1/%s' % (self.base_url, player[0]['data-serie'])
|
href = '%s/file-0-1/%s' % (self.base_url, player[0]['data-serie'])
|
||||||
|
|
||||||
self.data.append({
|
self.data.append({
|
||||||
|
'self': self,
|
||||||
'lang': ConnectorLang.JP,
|
'lang': ConnectorLang.JP,
|
||||||
'href': '%s/file-0-1/%s' % (self.base_url, player[0]['data-serie']),
|
'href': '%s/file-0-1/%s' % (self.base_url, player[0]['data-serie']),
|
||||||
'name': self.boldify(name[0].string),
|
'name': self.boldify(name[0].string, self.query),
|
||||||
'type': ani_type[0].string.replace(':', ''),
|
'type': ani_type[0].string.replace(':', ''),
|
||||||
'class': self.color if AnimeLink.query.filter_by(link=href).first() else ''
|
'class': self.color if AnimeLink.query.filter_by(link=href).first() else ''
|
||||||
})
|
})
|
||||||
@ -439,11 +459,12 @@ class AnimeUltime(Connector):
|
|||||||
|
|
||||||
current_locale = locale.getlocale()
|
current_locale = locale.getlocale()
|
||||||
locale.setlocale(locale.LC_ALL, ('fr_FR', 'UTF-8'))
|
locale.setlocale(locale.LC_ALL, ('fr_FR', 'UTF-8'))
|
||||||
release_date = datetime.strptime(h3s[i].string, '%A %d %B %Y : ').strftime('%Y-%m-%d %H:%M:%S')
|
release_date = datetime.strptime(h3s[i].string, '%A %d %B %Y : ')
|
||||||
locale.setlocale(locale.LC_ALL, current_locale)
|
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({
|
||||||
|
'self': self,
|
||||||
'lang': ConnectorLang.JP,
|
'lang': ConnectorLang.JP,
|
||||||
'href': '%s/%s' % (self.base_url, link['href']),
|
'href': '%s/%s' % (self.base_url, link['href']),
|
||||||
'name': link.string,
|
'name': link.string,
|
||||||
@ -459,6 +480,7 @@ class Other(Connector):
|
|||||||
color = 'is-danger'
|
color = 'is-danger'
|
||||||
title = 'Other'
|
title = 'Other'
|
||||||
favicon = 'blank.png'
|
favicon = 'blank.png'
|
||||||
|
base_url = ''
|
||||||
is_light = True
|
is_light = True
|
||||||
is_behind_cloudflare = False
|
is_behind_cloudflare = False
|
||||||
|
|
||||||
|
@ -21,6 +21,55 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
|
{% for torrent in torrents %}
|
||||||
|
<tr class="{{ torrent.class }}">
|
||||||
|
|
||||||
|
{% if torrent.self.is_light %}
|
||||||
|
<td colspan="3">
|
||||||
|
<img class="favicon" src="{{ url_for('static', filename='favicons/%s' % torrent.self.favicon) }}" alt="">
|
||||||
|
<i> </i>
|
||||||
|
{{ torrent.lang.value }}
|
||||||
|
<a href="{{ torrent.href }}" target="_blank">
|
||||||
|
{{ torrent.name }}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ torrent.date }}
|
||||||
|
</td>
|
||||||
|
<td colspan="3">
|
||||||
|
{{ torrent.type }}
|
||||||
|
</td>
|
||||||
|
{% else %}
|
||||||
|
{# <td>#}
|
||||||
|
{# <img class="favicon" src="{{ url_for('static', filename='favicons/%s' % torrent.self.favicon) }}" alt="">#}
|
||||||
|
{# <i> </i>#}
|
||||||
|
{# {{ torrent.lang.value }}#}
|
||||||
|
{# <a href="<?php e($tr['href']); ?>" target="_blank">#}
|
||||||
|
{# <?php e(preg_replace('/' . implode('|', $keywords) . '/i', '<b>\0</b>', $this->raw($tr['name']))); ?>#}
|
||||||
|
{# </a>#}
|
||||||
|
{# </td>#}
|
||||||
|
{# <td>#}
|
||||||
|
{# <?php e($this->raw($tr['link'])); ?>#}
|
||||||
|
{# </td>#}
|
||||||
|
{# <td>#}
|
||||||
|
{# <?php e($tr['size']); ?>#}
|
||||||
|
{# </td>#}
|
||||||
|
{# <td>#}
|
||||||
|
{# <?php e($tr['date']); ?>#}
|
||||||
|
{# </td>#}
|
||||||
|
{# <td>#}
|
||||||
|
{# <?php e($tr['seeds']); ?>#}
|
||||||
|
{# </td>#}
|
||||||
|
{# <td>#}
|
||||||
|
{# <?php e($tr['leechs']); ?>#}
|
||||||
|
{# </td>#}
|
||||||
|
{# <td>#}
|
||||||
|
{# <?php e($tr['check']); ?>#}
|
||||||
|
{# </td>#}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, minimum-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, minimum-scale=1.0">
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<meta name="description" content="Xefir's animes search engine (っ^‿^)っ">
|
<meta name="description" content="Xefir's animes search engine (っ^‿^)っ">
|
||||||
<title>Animes torrents search engine{% block title %}{% endblock %}</title>
|
<title>𝛑 =^._.^= た{% block title %}{% endblock %}</title>
|
||||||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicons/favicon.ico') }}">
|
<link rel="shortcut icon" href="{{ url_for('static', filename='favicons/favicon.ico') }}">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/bulma.min.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/bulma.min.css') }}">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/bulma-tooltip.min.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/bulma-tooltip.min.css') }}">
|
||||||
@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
<nav class="navbar is-dark" role="navigation" aria-label="main navigation">
|
<nav class="navbar is-dark" role="navigation" aria-label="main navigation">
|
||||||
<div class="navbar-start">
|
<div class="navbar-start">
|
||||||
|
<a class="navbar-item tooltip is-tooltip-bottom" data-tooltip="Home" href="{{ url_for('home') }}">
|
||||||
|
𝛑 =^._.^= た
|
||||||
|
</a>
|
||||||
<a class="navbar-item tooltip is-tooltip-bottom" data-tooltip="Latest torrents" href="{{ url_for('latest') }}">
|
<a class="navbar-item tooltip is-tooltip-bottom" data-tooltip="Latest torrents" href="{{ url_for('latest') }}">
|
||||||
<i class="fa fa-newspaper-o"></i><i> </i><span class="is-hidden-mobile">Latest torrents</span>
|
<i class="fa fa-newspaper-o"></i><i> </i><span class="is-hidden-mobile">Latest torrents</span>
|
||||||
</a>
|
</a>
|
||||||
|
Reference in New Issue
Block a user