Change how Ygg is handled
This commit is contained in:
parent
fbf42ece8e
commit
fa57752714
21
app.py
21
app.py
@ -16,7 +16,7 @@ def verify_password(username, password):
|
||||
|
||||
@app.route('/')
|
||||
def home():
|
||||
return render_template('home.html', form=SearchForm())
|
||||
return render_template('layout.html', form=SearchForm())
|
||||
|
||||
|
||||
@app.route('/search')
|
||||
@ -28,8 +28,8 @@ def search():
|
||||
results = [
|
||||
Nyaa(query).run(),
|
||||
Pantsu(query).run(),
|
||||
YggTorrent(query, category=2179).run(),
|
||||
YggTorrent(query, category=2178).run(),
|
||||
YggTorrent(query).run(),
|
||||
YggAnimation(query).run(),
|
||||
AnimeUltime(query).run(),
|
||||
]
|
||||
return render_template('search.html', form=SearchForm(), connectors=results)
|
||||
@ -37,6 +37,21 @@ def search():
|
||||
|
||||
@app.route('/latest')
|
||||
def latest():
|
||||
torrents = [
|
||||
Nyaa('', return_type=ConnectorReturn.HISTORY, page=request.args.get('page', 1)).run(),
|
||||
Pantsu('', return_type=ConnectorReturn.HISTORY, page=request.args.get('page', 1)).run(),
|
||||
YggTorrent('', return_type=ConnectorReturn.HISTORY, page=request.args.get('page', 1)).run(),
|
||||
YggAnimation('', return_type=ConnectorReturn.HISTORY, page=request.args.get('page', 1)).run(),
|
||||
AnimeUltime('', return_type=ConnectorReturn.HISTORY, page=request.args.get('page', 1)).run(),
|
||||
]
|
||||
|
||||
results = []
|
||||
|
||||
for torrent in torrents:
|
||||
results = results + torrent.data
|
||||
|
||||
print(results)
|
||||
|
||||
return 'Hello!'
|
||||
|
||||
|
||||
|
@ -25,9 +25,38 @@ class ConnectorLang(Enum):
|
||||
class Connector(ABC):
|
||||
blacklist_words = ['Chris44', 'Vol.']
|
||||
|
||||
def __init__(self, query, page=1, return_type=ConnectorReturn.SEARCH, category=None):
|
||||
@property
|
||||
@abstractmethod
|
||||
def color(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def title(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def favicon(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def base_url(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def is_light(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def is_behind_cloudflare(self):
|
||||
pass
|
||||
|
||||
def __init__(self, query, page=1, return_type=ConnectorReturn.SEARCH):
|
||||
self.query = query
|
||||
self.category = category
|
||||
self.data = []
|
||||
self.is_more = False
|
||||
self.on_error = True
|
||||
@ -54,7 +83,7 @@ class Connector(ABC):
|
||||
return self
|
||||
|
||||
def curl_content(self, url, params=None, ajax=False):
|
||||
if isinstance(self, YggTorrent):
|
||||
if self.is_behind_cloudflare:
|
||||
try:
|
||||
qt_env = {'QT_QPA_PLATFORM': 'offscreen'} if platform is 'linux' else {}
|
||||
qt_output = run('phantomjs --cookies-file=/tmp/cookies.json delay.js "%s" 5000' % url, env=qt_env,
|
||||
@ -114,6 +143,7 @@ class Nyaa(Connector):
|
||||
favicon = 'nyaa.png'
|
||||
base_url = 'https://nyaa.si'
|
||||
is_light = False
|
||||
is_behind_cloudflare = False
|
||||
|
||||
def get_full_search_url(self):
|
||||
sort_type = 'size'
|
||||
@ -186,6 +216,7 @@ class Pantsu(Connector):
|
||||
favicon = 'pantsu.png'
|
||||
base_url = 'https://nyaa.net'
|
||||
is_light = False
|
||||
is_behind_cloudflare = False
|
||||
|
||||
def get_full_search_url(self):
|
||||
sort_type = 4
|
||||
@ -253,6 +284,8 @@ class YggTorrent(Connector):
|
||||
favicon = 'yggtorrent.png'
|
||||
base_url = 'https://www2.yggtorrent.pe'
|
||||
is_light = False
|
||||
is_behind_cloudflare = True
|
||||
category = 2179
|
||||
|
||||
def get_full_search_url(self):
|
||||
sort_type = 'size'
|
||||
@ -312,12 +345,23 @@ class YggTorrent(Connector):
|
||||
self.is_more = valid_trs is not len(trs)
|
||||
|
||||
|
||||
class YggAnimation(YggTorrent):
|
||||
color = 'is-success'
|
||||
title = 'YggAnimation'
|
||||
favicon = 'yggtorrent.png'
|
||||
base_url = 'https://www2.yggtorrent.pe'
|
||||
is_light = False
|
||||
is_behind_cloudflare = True
|
||||
category = 2178
|
||||
|
||||
|
||||
class AnimeUltime(Connector):
|
||||
color = 'is-warning'
|
||||
title = 'Anime-Ultime'
|
||||
favicon = 'animeultime.png'
|
||||
base_url = 'http://www.anime-ultime.net'
|
||||
is_light = True
|
||||
is_behind_cloudflare = False
|
||||
|
||||
def get_full_search_url(self):
|
||||
from_date = ''
|
||||
@ -416,6 +460,7 @@ class Other(Connector):
|
||||
title = 'Other'
|
||||
favicon = 'blank.png'
|
||||
is_light = True
|
||||
is_behind_cloudflare = False
|
||||
|
||||
def get_full_search_url(self):
|
||||
pass
|
||||
|
@ -1,3 +0,0 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block title %}Animes torrents search engine{% endblock %}
|
||||
{% block body %}{% endblock %}
|
27
templates/latest.html
Normal file
27
templates/latest.html
Normal file
@ -0,0 +1,27 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block title %} - Latest{% endblock %}
|
||||
{% block body %}
|
||||
<table class="table is-bordered is-striped is-narrow is-fullwidth is-hoverable is-size-7">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Link</th>
|
||||
<th>Size</th>
|
||||
<th>Date</th>
|
||||
<th>
|
||||
<i class="fa fa-arrow-up"></i>
|
||||
</th>
|
||||
<th>
|
||||
<i class="fa fa-arrow-down"></i>
|
||||
</th>
|
||||
<th>
|
||||
<i class="fa fa fa-check"></i>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
@ -5,7 +5,7 @@
|
||||
<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 name="description" content="Xefir's animes search engine (っ^‿^)っ">
|
||||
<title>{% block title %}{% endblock %}</title>
|
||||
<title>Animes torrents search engine{% block title %}{% endblock %}</title>
|
||||
<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-tooltip.min.css') }}">
|
||||
|
@ -1,5 +1,5 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block title %}Animes torrents search engine - {{ request.args.get('q') }}{% endblock %}
|
||||
{% block title %} - {{ request.args.get('q') }}{% endblock %}
|
||||
{% block body %}
|
||||
<table class="table is-bordered is-striped is-narrow is-fullwidth is-hoverable search">
|
||||
<thead>
|
||||
|
Reference in New Issue
Block a user