Commit 785d040f authored by prx's avatar prx

- feu btdigg

- torrentproject qui a désactivé son API et bloque les scripts
+ torrent9 réparé avec sa bonne URL
+ fix parsing torrent9
parent 4cb338fd
......@@ -19,7 +19,7 @@ import sys
from argparse import ArgumentParser
from dontpanic.ui import DontPanic
from dontpanic.i18n import _
from dontpanic.i18nlib import _
from dontpanic.utils import setup_logging, progname, progversion
serverlist = ["cgi", "paste", "cherrypy", "tornado", "auto"]
......
......@@ -13,7 +13,7 @@ from threading import Thread
import webbrowser
from .database import DontPanicDB
from .i18n import _
from .i18nlib import _
from .subtitle import Subtitle
from .torrentsession import TorrentSession
from .utils import *
......
......@@ -16,7 +16,10 @@ if sys.version_info >= (3, 0):
else:
import ConfigParser as cp
from .i18n import _
try:
from i18nlib import _
except :
from .i18nlib import _
####################
# Global variables #
......
......@@ -4,8 +4,12 @@ import sys
import requests
import bs4
from .utils import convb
from .i18n import _
try :
from utils import convb
from i18nlib import _
except:
from .utils import convb
from .i18nlib import _
if sys.version_info >= (3, 0):
from concurrent.futures import ThreadPoolExecutor
......@@ -258,11 +262,11 @@ class TorrentSearch:
def search(self, sch, page=0):
try :
if self.searchengine == 'btdigg':
s = [res for res in self._btdigg(sch, page)]
elif self.searchengine == 'torrentproject':
s = [res for res in self._torrentproject(sch)]
elif self.searchengine == 'piratebay':
#if self.searchengine == 'btdigg':
# s = [res for res in self._btdigg(sch, page)]
#elif self.searchengine == 'torrentproject':
# s = [res for res in self._torrentproject(sch)]
if self.searchengine == 'piratebay':
s = [res for res in self._piratebay(sch)]
elif self.searchengine == 'kickasstorrents':
s = [res for res in self._kickasstorrents(sch)]
......@@ -318,7 +322,7 @@ class TorrentSearch:
name = j.a.string
infos = i.find_all('span', 'attr_val')
if len(infos) == 0:
if not infos:
continue
else:
size = infos[0].string
......@@ -403,30 +407,30 @@ class TorrentSearch:
seeds = str()
leechs = str()
for i in soup.find_all('td'):
if len(name) == 0:
if not name:
name_result = i.find('div', class_='detName')
if name_result:
name = name_result.a.string
if len(magnet) == 0:
if not magnet:
alinks = i.find_all('a')
for magnet_result in alinks:
href = magnet_result['href']
if href.startswith('magnet:'):
magnet = href.split('&tr=')[0] # to remove trackers
if len(size) == 0:
if not size:
size_result = i.find('font', class_='detDesc')
if size_result:
size = size_result.text.split(',')[1].replace('Size', '').strip()
if i.string:
if len(seeds) == 0:
if not seeds:
seeds = i.string
elif len(leechs) == 0:
elif not leechs:
leechs = i.string
if name != "" and magnet != "" and size != "" and seeds != "" and leechs != "":
if name and magnet and size and seeds and leechs :
if sys.version_info < (3, 0):
magnet = magnet.encode('utf-8')
name = name.encode('utf-8')
......@@ -546,7 +550,7 @@ class TorrentSearch:
seed : number of seeds
"""
thesch = sch.replace(' ', '-')
baseurl = 'http://www.torrent9.ws'
baseurl = 'http://www.torrent9.biz'
url = '{}/search_torrent/{}.html'.format(baseurl,thesch)
s = do_req_get(url, "text")
soup = bs4.BeautifulSoup(s, "html.parser")
......@@ -574,14 +578,14 @@ class TorrentSearch:
break
else:
if len(size) == 0:
if not size:
size = d.string
elif len(seeds) == 0:
elif not seeds :
seeds = d.string
elif len(leechs) == 0:
elif not leechs :
leechs = d.string
if name != '' and magnet != '' and size != '' and seeds != '' and leechs != '':
if name and magnet and size and seeds and leechs :
if sys.version_info < (3, 0):
magnet = magnet.encode('utf-8')
......@@ -631,8 +635,8 @@ def isohunt_parse_results(z):
if __name__ == '__main__':
with TorrentSearch('torrent9') as ts:
s = ts.search('orange is the new black', 0)
with TorrentSearch('torrentproject') as ts:
s = ts.search('vikings', 0)
print(s)
......
......@@ -4,7 +4,7 @@
import logging
import os
import subprocess
from dontpanic.i18n import _, i18n_domain
from dontpanic.i18nlib import _, i18n_domain
from dontpanic.utils import localedir, podir, progname, setup_logging
from argparse import ArgumentParser
......
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