Commit fee1dacf authored by prx's avatar prx

remove torrentz. RIP

parent d804cdd8
File mode changed from 100755 to 100644
......@@ -295,7 +295,7 @@ def watchlist(user):
def create_select_search_engine(selected):
list_search_engines = ["btdigg", "kickasstorrents", "piratebay", "torrentproject", "torrentz", tpl_msg['tpl_all']]
list_search_engines = ["btdigg", "kickasstorrents", "piratebay", "torrentproject", tpl_msg['tpl_all']]
list_html = str()
for search_engine in list_search_engines:
......@@ -643,9 +643,9 @@ class DontPanic:
subtitles = ''
if perc >= int(self.startperc) and session.ready2watch():
# Show the link to play the file
playlink = '<span class="big">' \
playlink = '<p><span class="big">' \
'\t<a href="/html5/{}" target="_blank">{} ▷</a>' \
'</span>'.format(moviepath, _('Play'))
'</span></p>'.format(moviepath, _('Play'))
subtitles = '<a href="/getsubtitles/{}/{}" target="_blank">{}</a> - '.format(
name, moviepath, _('Find subtitles'))
......@@ -675,10 +675,18 @@ class DontPanic:
@self.app.route('/html5/<filename:path>')
def html5(filename):
mtype = 'type="{}"'.format(mimetypes.guess_type(filename)[0])
video = '<video width="640" controls preload="auto" autoplay="true" >\n'
video += '<source src="/video/{}" {} >\n'.format(filename, mtype)
video += '</video>\n'
mt = mimetypes.guess_type(filename)[0]
if mt == 'video/x-msvideo-nimportequoi' :
#video = '<object data="/video/{}" width="360" height="250">\n'.format(filename)
#video += '<param name="src" value="/video/{}" /> </object>\n'.format(filename)
video = '<embed src="/video/{}">\n'.format(filename)
else:
mtype = 'type="{}"'.format(mt)
video = '<video width="640" controls preload="auto" autoplay="true" >\n'
video += '<source src="/video/{}" {} >\n'.format(filename, mtype)
video += '</video>\n'
links = '<div>\n'
links += '<br/>\n'
......@@ -921,7 +929,7 @@ class DontPanic:
while not is_running():
time.sleep(0.1)
time.sleep(1)
time.sleep(0.5)
if self.magnet_as_arg:
webbrowser.open("http://localhost:{}/stream/dontpanic/{}/0".format(port, self.magnet_as_arg))
else:
......
File added
......@@ -22,7 +22,6 @@ Suggestion:
À réfléchir :
-------------
- Poids d'un fichier parfois manquant (constaté avec torrentz - provient directement du moteur de recherche malheureusement)
Mis de côté :
-------------
......
......@@ -263,8 +263,6 @@ class TorrentSearch:
s = [res for res in self._btdigg(sch, page)]
elif self.searchengine == 'torrentproject':
s = [res for res in self._torrentproject(sch)]
elif self.searchengine == 'torrentz':
s = [res for res in self._torrentz(sch)]
elif self.searchengine == 'piratebay':
s = [res for res in self._piratebay(sch)]
elif self.searchengine == 'kickasstorrents':
......@@ -280,7 +278,7 @@ class TorrentSearch:
def _search_all(self, sch):
s = []
searchengine_list = [self._btdigg, self._torrentproject, self._torrentz, self._piratebay]
searchengine_list = [self._btdigg, self._torrentproject, self._piratebay]
if sys.version_info >= (3, 0):
with ThreadPoolExecutor(max_workers=4) as e:
for searchengine in searchengine_list:
......@@ -290,7 +288,6 @@ class TorrentSearch:
else:
s += [res for res in self._btdigg(sch)]
s += [res for res in self._torrentproject(sch)]
s += [res for res in self._torrentz(sch)]
s += [res for res in self._piratebay(sch)]
s += [res for res in self._kickasstorrents(sch)]
......@@ -380,64 +377,6 @@ class TorrentSearch:
d = {'name': name, 'magnet': magnet, 'size': size, 'seeds': seeds, "leechs": leechs}
yield(d)
def _torrentz(self, sch):
"""
Search on torrentz.eu
Args:
sch:
Return:
List of dictionnaries with keys :
name : torrent name
magnet : magnet link
size : size
seed : number of seeds
"""
url = 'https://torrentz.eu/search'
keys = {'q': sch}
s = do_req_get(url, "text", keys)
soup = bs4.BeautifulSoup(s, "html.parser")
# Find results and not links pub
result = soup.find('div', class_='results')
for dl in result.find_all('dl'):
magnet = dl.find('a')
if not magnet:
continue
magnet = 'magnet:?xt=urn:btih:{}'.format(magnet['href'][1:]) # remove first "/"
name = dl.find('a').get_text()
size = dl.find('span', 's')
if size:
size = size.string
else:
size = ''
seeds = dl.find('span', 'u')
if seeds:
seeds = seeds.string
if ',' in seeds:
seeds = seeds.replace(',', '')
leechs = dl.find('span', 'd').string
if leechs:
leechs = leechs.string
if ',' in leechs:
leechs = leechs.replace(',', '')
if sys.version_info < (3, 0):
magnet = magnet.encode('utf-8')
name = name.encode('utf-8')
size = size.encode('utf-8')
d = {'name': name, 'magnet': magnet, 'size': size, 'seeds': seeds, "leechs": leechs}
yield(d)
def _piratebay(self, sch, page=0):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment