Commit 5d923bc7 authored by Julien Veyssier's avatar Julien Veyssier

autopep8 with 120 chars line length on my modules

parent 6a7bc092
......@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.capabilities.recipe import ICapRecipe,Recipe
from weboob.capabilities.recipe import ICapRecipe, Recipe
from weboob.tools.backend import BaseBackend
from .browser import SevenFiftyGramsBrowser
......@@ -46,16 +46,16 @@ class SevenFiftyGramsBackend(BaseBackend, ICapRecipe):
def fill_recipe(self, recipe, fields):
if 'nb_person' in fields or 'instructions' in fields:
rec = self.get_recipe(recipe.id)
recipe.picture_url = rec.picture_url
recipe.instructions = rec.instructions
recipe.ingredients = rec.ingredients
recipe.comments = rec.comments
recipe.nb_person = rec.nb_person
recipe.cooking_time = rec.cooking_time
recipe.picture_url = rec.picture_url
recipe.instructions = rec.instructions
recipe.ingredients = rec.ingredients
recipe.comments = rec.comments
recipe.nb_person = rec.nb_person
recipe.cooking_time = rec.cooking_time
recipe.preparation_time = rec.preparation_time
return recipe
OBJECTS = {
Recipe:fill_recipe,
}
Recipe: fill_recipe,
}
......@@ -34,10 +34,10 @@ class SevenFiftyGramsBrowser(BaseBrowser):
PAGES = {
'http://www.750g.com/recettes_.*.htm': ResultsPage,
'http://www.750g.com/fiche_de_cuisine_complete.htm\?recettes_id=[0-9]*': RecipePage,
}
}
def iter_recipes(self, pattern):
self.location('http://www.750g.com/recettes_%s.htm' % (pattern.replace(' ','_')))
self.location('http://www.750g.com/recettes_%s.htm' % (pattern.replace(' ', '_')))
assert self.is_on_page(ResultsPage)
return self.page.iter_recipes()
......
......@@ -30,35 +30,36 @@ class ResultsPage(BasePage):
""" Page which contains results as a list of recipies
"""
def iter_recipes(self):
for div in self.parser.select(self.document.getroot(),'div.recette_description > div.data'):
links = self.parser.select(div,'div.info > p.title > a.fn')
for div in self.parser.select(self.document.getroot(), 'div.recette_description > div.data'):
links = self.parser.select(div, 'div.info > p.title > a.fn')
if len(links) > 0:
link = links[0]
title = unicode(link.text)
#id = unicode(link.attrib.get('href','').strip('/').replace('.htm','htm'))
id = unicode(self.parser.select(div,'div.carnet-add a',1).attrib.get('href','').split('=')[-1])
# id = unicode(link.attrib.get('href','').strip('/').replace('.htm','htm'))
id = unicode(self.parser.select(div, 'div.carnet-add a', 1).attrib.get('href', '').split('=')[-1])
thumbnail_url = NotAvailable
short_description = NotAvailable
imgs = self.parser.select(div,'img.recipe-image')
imgs = self.parser.select(div, 'img.recipe-image')
if len(imgs) > 0:
thumbnail_url = unicode(imgs[0].attrib.get('src',''))
short_description = unicode(' '.join(self.parser.select(div,'div.infos_column',1).text_content().split()).strip())
imgs_cost = self.parser.select(div,'div.infos_column img')
thumbnail_url = unicode(imgs[0].attrib.get('src', ''))
short_description = unicode(' '.join(self.parser.select(
div, 'div.infos_column', 1).text_content().split()).strip())
imgs_cost = self.parser.select(div, 'div.infos_column img')
cost_tot = len(imgs_cost)
cost_on = 0
for img in imgs_cost:
if img.attrib.get('src','').endswith('euro_on.png'):
if img.attrib.get('src', '').endswith('euro_on.png'):
cost_on += 1
short_description += u' %s/%s'%(cost_on,cost_tot)
short_description += u' %s/%s' % (cost_on, cost_tot)
recipe = Recipe(id,title)
recipe = Recipe(id, title)
recipe.thumbnail_url = thumbnail_url
recipe.short_description= short_description
recipe.instructions = NotLoaded
recipe.ingredients = NotLoaded
recipe.nb_person = NotLoaded
recipe.cooking_time = NotLoaded
recipe.short_description = short_description
recipe.instructions = NotLoaded
recipe.ingredients = NotLoaded
recipe.nb_person = NotLoaded
recipe.cooking_time = NotLoaded
recipe.preparation_time = NotLoaded
yield recipe
......@@ -76,10 +77,10 @@ class RecipePage(BasePage):
instructions = NotAvailable
comments = []
title = unicode(self.parser.select(self.document.getroot(),'head > title',1).text.split(' - ')[1])
main = self.parser.select(self.document.getroot(),'div.recette_description',1)
title = unicode(self.parser.select(self.document.getroot(), 'head > title', 1).text.split(' - ')[1])
main = self.parser.select(self.document.getroot(), 'div.recette_description', 1)
rec_infos = self.parser.select(self.document.getroot(),'div.recette_infos div.infos_column strong')
rec_infos = self.parser.select(self.document.getroot(), 'div.recette_infos div.infos_column strong')
for info_title in rec_infos:
if u'Temps de préparation' in unicode(info_title.text):
if info_title.tail.strip() != '':
......@@ -96,31 +97,31 @@ class RecipePage(BasePage):
nb_person = int(info_title.tail)
ingredients = []
p_ing = self.parser.select(main,'div.data.top.left > div.content p')
p_ing = self.parser.select(main, 'div.data.top.left > div.content p')
for ing in p_ing:
ingtxt = unicode(ing.text_content().strip())
if ingtxt != '':
ingredients.append(ingtxt)
lines_instr = self.parser.select(main,'div.data.top.right div.content li')
lines_instr = self.parser.select(main, 'div.data.top.right div.content li')
if len(lines_instr) > 0:
instructions = u''
for line in lines_instr:
inst = ' '.join(line.text_content().strip().split())
instructions += '%s\n'% inst
instructions += '%s\n' % inst
instructions = instructions.strip('\n')
imgillu = self.parser.select(self.document.getroot(),'div.resume_recette_illustree img.photo')
imgillu = self.parser.select(self.document.getroot(), 'div.resume_recette_illustree img.photo')
if len(imgillu) > 0:
picture_url = unicode(imgillu[0].attrib.get('src',''))
picture_url = unicode(imgillu[0].attrib.get('src', ''))
for divcom in self.parser.select(self.document.getroot(),'div.comment-outer'):
for divcom in self.parser.select(self.document.getroot(), 'div.comment-outer'):
comtxt = unicode(' '.join(divcom.text_content().strip().split()))
if u'| Répondre' in comtxt:
comtxt = comtxt.strip('0123456789').replace(u' | Répondre','')
comtxt = comtxt.strip('0123456789').replace(u' | Répondre', '')
comments.append(comtxt)
recipe = Recipe(id,title)
recipe = Recipe(id, title)
recipe.preparation_time = preparation_time
recipe.cooking_time = cooking_time
recipe.nb_person = nb_person
......
......@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.capabilities.subtitle import ICapSubtitle,LanguageNotSupported
from weboob.capabilities.subtitle import ICapSubtitle, LanguageNotSupported
from weboob.tools.backend import BaseBackend
from .browser import AttilasubBrowser
......@@ -53,4 +53,4 @@ class AttilasubBackend(BaseBackend, ICapSubtitle):
def iter_subtitles(self, language, pattern):
if language not in self.LANGUAGE_LIST:
raise LanguageNotSupported()
return self.browser.iter_subtitles(language,quote_plus(pattern.encode('utf-8')))
return self.browser.iter_subtitles(language, quote_plus(pattern.encode('utf-8')))
......@@ -34,12 +34,13 @@ class AttilasubBrowser(BaseBrowser):
PAGES = {
'http://search.freefind.com/find.html.*': SearchPage,
'http://davidbillemont3.free.fr/.*.htm': SubtitlesPage,
}
}
def iter_subtitles(self, language, pattern):
self.location('http://search.freefind.com/find.html?id=81131980&_charset_=&bcd=%%F7&scs=1&pageid=r&query=%s&mode=Find%%20pages%%20matching%%20ALL%%20words' % pattern.encode('utf-8'))
self.location('http://search.freefind.com/find.html?id=81131980&_charset_=&bcd=%%F7&scs=1&pageid=r&query=%s&mode=Find%%20pages%%20matching%%20ALL%%20words' %
pattern.encode('utf-8'))
assert self.is_on_page(SearchPage)
return self.page.iter_subtitles(language,pattern)
return self.page.iter_subtitles(language, pattern)
def get_subtitle(self, id):
url_end = id.split('|')[0]
......
......@@ -23,16 +23,16 @@ from weboob.capabilities.base import NotAvailable
from weboob.tools.browser import BasePage
__all__ = ['SubtitlesPage','SearchPage']
__all__ = ['SubtitlesPage', 'SearchPage']
class SearchPage(BasePage):
def iter_subtitles(self, language, pattern):
fontresult = self.parser.select(self.document.getroot(),'div.search-results font.search-results')
fontresult = self.parser.select(self.document.getroot(), 'div.search-results font.search-results')
# for each result in freefind, explore the subtitle list page to iter subtitles
for res in fontresult:
a = self.parser.select(res,'a',1)
url = a.attrib.get('href','')
a = self.parser.select(res, 'a', 1)
url = a.attrib.get('href', '')
self.browser.location(url)
assert self.browser.is_on_page(SubtitlesPage)
# subtitles page does the job
......@@ -41,15 +41,15 @@ class SearchPage(BasePage):
class SubtitlesPage(BasePage):
def get_subtitle(self,id):
def get_subtitle(self, id):
href = id.split('|')[1]
# we have to find the 'tr' which contains the link to this address
a = self.parser.select(self.document.getroot(),'a[href="%s"]'%href,1)
a = self.parser.select(self.document.getroot(), 'a[href="%s"]' % href, 1)
line = a.getparent().getparent().getparent().getparent().getparent()
cols = self.parser.select(line,'td')
traduced_title = self.parser.select(cols[0],'font',1).text.lower()
original_title = self.parser.select(cols[1],'font',1).text.lower()
nb_cd = self.parser.select(cols[2],'font',1).text.strip()
cols = self.parser.select(line, 'td')
traduced_title = self.parser.select(cols[0], 'font', 1).text.lower()
original_title = self.parser.select(cols[1], 'font', 1).text.lower()
nb_cd = self.parser.select(cols[2], 'font', 1).text.strip()
nb_cd = int(nb_cd.split()[0])
traduced_title_words = traduced_title.split()
......@@ -59,30 +59,30 @@ class SubtitlesPage(BasePage):
traduced_title = " ".join(traduced_title_words)
original_title = " ".join(original_title_words)
name = unicode('%s (%s)'%(original_title,traduced_title))
url = unicode('http://davidbillemont3.free.fr/%s'%href)
subtitle = Subtitle(id,name)
name = unicode('%s (%s)' % (original_title, traduced_title))
url = unicode('http://davidbillemont3.free.fr/%s' % href)
subtitle = Subtitle(id, name)
subtitle.url = url
subtitle.language = unicode('fr')
subtitle.nb_cd = nb_cd
subtitle.description = NotAvailable
return subtitle
def iter_subtitles(self,language, pattern):
pattern = pattern.strip().replace('+',' ').lower()
def iter_subtitles(self, language, pattern):
pattern = pattern.strip().replace('+', ' ').lower()
pattern_words = pattern.split()
tab = self.parser.select(self.document.getroot(),'table[bordercolor="#B8C0B2"]')
tab = self.parser.select(self.document.getroot(), 'table[bordercolor="#B8C0B2"]')
if len(tab) == 0:
tab = self.parser.select(self.document.getroot(),'table[bordercolordark="#B8C0B2"]')
tab = self.parser.select(self.document.getroot(), 'table[bordercolordark="#B8C0B2"]')
if len(tab) == 0:
return
# some results of freefind point on useless pages
if tab[0].attrib.get('width','') != '100%':
if tab[0].attrib.get('width', '') != '100%':
return
for line in tab[0].getiterator('tr'):
cols = self.parser.select(line,'td')
traduced_title = self.parser.select(cols[0],'font',1).text.lower()
original_title = self.parser.select(cols[1],'font',1).text.lower()
cols = self.parser.select(line, 'td')
traduced_title = self.parser.select(cols[0], 'font', 1).text.lower()
original_title = self.parser.select(cols[1], 'font', 1).text.lower()
traduced_title_words = traduced_title.split()
original_title_words = original_title.split()
......@@ -98,13 +98,13 @@ class SubtitlesPage(BasePage):
traduced_title = " ".join(traduced_title_words)
original_title = " ".join(original_title_words)
nb_cd = self.parser.select(cols[2],'font',1).text.strip()
nb_cd = self.parser.select(cols[2], 'font', 1).text.strip()
nb_cd = int(nb_cd.strip(' CD'))
name = unicode('%s (%s)'%(original_title,traduced_title))
href = self.parser.select(cols[3],'a',1).attrib.get('href','')
url = unicode('http://davidbillemont3.free.fr/%s'%href)
id = unicode('%s|%s'%(self.browser.geturl().split('/')[-1],href))
subtitle = Subtitle(id,name)
name = unicode('%s (%s)' % (original_title, traduced_title))
href = self.parser.select(cols[3], 'a', 1).attrib.get('href', '')
url = unicode('http://davidbillemont3.free.fr/%s' % href)
id = unicode('%s|%s' % (self.browser.geturl().split('/')[-1], href))
subtitle = Subtitle(id, name)
subtitle.url = url
subtitle.language = unicode('fr')
subtitle.nb_cd = nb_cd
......
......@@ -27,7 +27,7 @@ class AttilasubTest(BackendTest):
BACKEND = 'attilasub'
def test_subtitle(self):
subtitles = list(self.backend.iter_subtitles('fr','spiderman'))
subtitles = list(self.backend.iter_subtitles('fr', 'spiderman'))
assert (len(subtitles) > 0)
for subtitle in subtitles:
path, qs = urllib.splitquery(subtitle.url)
......
......@@ -67,25 +67,25 @@ class ImdbBackend(BaseBackend, ICapCinema):
return self.browser.get_person_biography(id)
def get_movie_releases(self, id, country=None):
return self.browser.get_movie_releases(id,country)
return self.browser.get_movie_releases(id, country)
def fill_person(self, person, fields):
if 'real_name' in fields or 'birth_place' in fields\
or 'death_date' in fields or 'nationality' in fields\
or 'short_biography' in fields or 'roles' in fields\
or 'birth_date' in fields or 'thumbnail_url' in fields\
or 'gender' in fields or fields is None:
or 'death_date' in fields or 'nationality' in fields\
or 'short_biography' in fields or 'roles' in fields\
or 'birth_date' in fields or 'thumbnail_url' in fields\
or 'gender' in fields or fields is None:
per = self.get_person(person.id)
person.real_name = per.real_name
person.birth_date = per.birth_date
person.death_date = per.death_date
person.birth_place = per.birth_place
person.gender = per.gender
person.nationality = per.nationality
person.real_name = per.real_name
person.birth_date = per.birth_date
person.death_date = per.death_date
person.birth_place = per.birth_place
person.gender = per.gender
person.nationality = per.nationality
person.short_biography = per.short_biography
person.short_description = per.short_description
person.roles = per.roles
person.thumbnail_url = per.thumbnail_url
person.roles = per.roles
person.thumbnail_url = per.thumbnail_url
if 'biography' in fields:
person.biography = self.get_person_biography(person.id)
......@@ -94,19 +94,19 @@ class ImdbBackend(BaseBackend, ICapCinema):
def fill_movie(self, movie, fields):
if 'other_titles' in fields or 'release_date' in fields\
or 'duration' in fields or 'country' in fields\
or 'roles' in fields or 'note' in fields\
or 'thumbnail_url' in fields:
or 'duration' in fields or 'country' in fields\
or 'roles' in fields or 'note' in fields\
or 'thumbnail_url' in fields:
mov = self.get_movie(movie.id)
movie.other_titles = mov.other_titles
movie.release_date = mov.release_date
movie.duration = mov.duration
movie.pitch = mov.pitch
movie.country = mov.country
movie.note = mov.note
movie.roles = mov.roles
movie.short_description= mov.short_description
movie.thumbnail_url = mov.thumbnail_url
movie.other_titles = mov.other_titles
movie.release_date = mov.release_date
movie.duration = mov.duration
movie.pitch = mov.pitch
movie.country = mov.country
movie.note = mov.note
movie.roles = mov.roles
movie.short_description = mov.short_description
movie.thumbnail_url = mov.thumbnail_url
if 'all_release_dates' in fields:
movie.all_release_dates = self.get_movie_releases(movie.id)
......@@ -114,6 +114,6 @@ class ImdbBackend(BaseBackend, ICapCinema):
return movie
OBJECTS = {
Person:fill_person,
Movie:fill_movie
}
Person: fill_person,
Movie: fill_movie
}
......@@ -42,53 +42,55 @@ class ImdbBrowser(BaseBrowser):
'http://www.imdb.com/name/nm[0-9]*/*': PersonPage,
'http://www.imdb.com/name/nm[0-9]*/bio.*': BiographyPage,
'http://www.imdb.com/name/nm[0-9]*/filmo.*': FilmographyPage,
}
}
def iter_movies(self, pattern):
res = self.readurl('http://www.imdb.com/xml/find?json=1&nr=1&tt=on&q=%s' % pattern.encode('utf-8'))
jres = json.loads(res)
for cat in ['title_popular','title_exact','title_approx']:
for cat in ['title_popular', 'title_exact', 'title_approx']:
if cat in jres:
for m in jres[cat]:
tdesc = unicode(m['title_description'])
if '<a' in tdesc and '>' in tdesc:
short_description = u'%s %s'%(tdesc.split('<')[0].strip(', '), tdesc.split('>')[1].split('<')[0])
short_description = u'%s %s' % (tdesc.split('<')[
0].strip(', '), tdesc.split('>')[1].split('<')[0])
else:
short_description = tdesc.strip(', ')
movie = Movie(m['id'],latin2unicode(m['title']))
movie.other_titles = NotLoaded
movie.release_date = NotLoaded
movie.duration = NotLoaded
movie = Movie(m['id'], latin2unicode(m['title']))
movie.other_titles = NotLoaded
movie.release_date = NotLoaded
movie.duration = NotLoaded
movie.short_description = latin2unicode(short_description)
movie.pitch = NotLoaded
movie.country = NotLoaded
movie.note = NotLoaded
movie.roles = NotLoaded
movie.all_release_dates= NotLoaded
movie.thumbnail_url = NotLoaded
movie.pitch = NotLoaded
movie.country = NotLoaded
movie.note = NotLoaded
movie.roles = NotLoaded
movie.all_release_dates = NotLoaded
movie.thumbnail_url = NotLoaded
yield movie
def iter_persons(self, pattern):
res = self.readurl('http://www.imdb.com/xml/find?json=1&nr=1&nm=on&q=%s' % pattern.encode('utf-8'))
jres = json.loads(res)
for cat in ['name_popular','name_exact','name_approx']:
for cat in ['name_popular', 'name_exact', 'name_approx']:
if cat in jres:
for p in jres[cat]:
person = Person(p['id'],latin2unicode(p['name']))
person.real_name = NotLoaded
person.birth_place = NotLoaded
person.birth_date = NotLoaded
person.death_date = NotLoaded
person.gender = NotLoaded
person.nationality = NotLoaded
person.short_biography= NotLoaded
person.short_description= latin2unicode(p['description'])
person.roles = NotLoaded
person.thumbnail_url = NotLoaded
person = Person(p['id'], latin2unicode(p['name']))
person.real_name = NotLoaded
person.birth_place = NotLoaded
person.birth_date = NotLoaded
person.death_date = NotLoaded
person.gender = NotLoaded
person.nationality = NotLoaded
person.short_biography = NotLoaded
person.short_description = latin2unicode(p['description'])
person.roles = NotLoaded
person.thumbnail_url = NotLoaded
yield person
def get_movie(self, id):
res = self.readurl('http://imdbapi.org/?id=%s&type=json&plot=simple&episode=1&lang=en-US&aka=full&release=simple&business=0&tech=0' % id )
res = self.readurl(
'http://imdbapi.org/?id=%s&type=json&plot=simple&episode=1&lang=en-US&aka=full&release=simple&business=0&tech=0' % id)
if res is not None:
jres = json.loads(res)
else:
......@@ -122,7 +124,7 @@ class ImdbBrowser(BaseBrowser):
if 'also_known_as' in jres:
for other_t in jres['also_known_as']:
if 'country' in other_t and 'title' in other_t:
other_titles.append('%s : %s' % (other_t['country'],htmlparser.unescape(other_t['title'])))
other_titles.append('%s : %s' % (other_t['country'], htmlparser.unescape(other_t['title'])))
if 'release_date' in jres:
dstr = str(jres['release_date'])
year = int(dstr[:4])
......@@ -134,31 +136,31 @@ class ImdbBrowser(BaseBrowser):
day = int(dstr[-2:])
if day == 0:
day = 1
release_date = datetime(year,month,day)
release_date = datetime(year, month, day)
if 'country' in jres:
country = u''
for c in jres['country']:
country += '%s, '%c
country += '%s, ' % c
country = country[:-2]
if 'plot_simple' in jres:
pitch = unicode(jres['plot_simple'])
if 'rating' in jres and 'rating_count' in jres:
note = u'%s/10 (%s votes)'%(jres['rating'],jres['rating_count'])
for r in ['actor','director','writer']:
if '%ss'%r in jres:
roles['%s'%r] = list(jres['%ss'%r])
movie = Movie(id,title)
movie.other_titles = other_titles
movie.release_date = release_date
movie.duration = duration
movie.pitch = pitch
movie.country = country
movie.note = note
movie.roles = roles
movie.short_description= short_description
movie.all_release_dates= NotLoaded
movie.thumbnail_url = thumbnail_url
note = u'%s/10 (%s votes)' % (jres['rating'], jres['rating_count'])
for r in ['actor', 'director', 'writer']:
if '%ss' % r in jres:
roles['%s' % r] = list(jres['%ss' % r])
movie = Movie(id, title)
movie.other_titles = other_titles
movie.release_date = release_date
movie.duration = duration
movie.pitch = pitch
movie.country = country
movie.note = note
movie.roles = roles
movie.short_description = short_description
movie.all_release_dates = NotLoaded
movie.thumbnail_url = thumbnail_url
return movie
def get_person(self, id):
......@@ -175,7 +177,7 @@ class ImdbBrowser(BaseBrowser):
return self.page.get_biography()
def iter_movie_persons(self, movie_id, role):
self.location('http://www.imdb.com/title/%s/fullcredits'%movie_id)
self.location('http://www.imdb.com/title/%s/fullcredits' % movie_id)
assert self.is_on_page(MovieCrewPage)
for p in self.page.iter_persons(role):
yield p
......@@ -192,13 +194,13 @@ class ImdbBrowser(BaseBrowser):
yield movie
def iter_movie_persons_ids(self, movie_id):
self.location('http://www.imdb.com/title/%s/fullcredits'%movie_id)
self.location('http://www.imdb.com/title/%s/fullcredits' % movie_id)
assert self.is_on_page(MovieCrewPage)
for person in self.page.iter_persons_ids():
yield person
def get_movie_releases(self,id, country):
self.location('http://www.imdb.com/title/%s/releaseinfo'%id)
def get_movie_releases(self, id, country):
self.location('http://www.imdb.com/title/%s/releaseinfo' % id)
assert self.is_on_page(ReleasePage)
return self.page.get_movie_releases(country)
......@@ -222,5 +224,5 @@ dict_hex = {'&#xE1;': u'á',
def latin2unicode(word):
for key in dict_hex.keys():
word = word.replace(key,dict_hex[key])
word = word.replace(key, dict_hex[key])
return unicode(word)
This diff is collapsed.
......@@ -49,7 +49,7 @@ class IsohuntBackend(BaseBackend, ICapTorrent):
return self.browser.openurl(torrent.url.encode('utf-8')).read()
def iter_torrents(self, pattern):
return self.browser.iter_torrents(pattern.replace(' ','+'))
return self.browser.iter_torrents(pattern.replace(' ', '+'))
def fill_torrent(self, torrent, fields):
if 'description' in fields or 'files' in fields:
......@@ -61,5 +61,5 @@ class IsohuntBackend(BaseBackend, ICapTorrent):
return torrent
OBJECTS = {
Torrent:fill_torrent
Torrent: fill_torrent
}
......@@ -32,9 +32,9 @@ class IsohuntBrowser(BaseBrowser):
ENCODING = 'utf-8'
USER_AGENT = BaseBrowser.USER_AGENTS['wget']
PAGES = {
'https://isohunt.com/torrents/.*iht=-1&ihp=1&ihs1=1&iho1=d' : TorrentsPage,
'https://isohunt.com/torrent_details.*tab=summary' : TorrentPage,
}
'https://isohunt.com/torrents/.*iht=-1&ihp=1&ihs1=1&iho1=d': TorrentsPage,
'https://isohunt.com/torrent_details.*tab=summary': TorrentPage,
}
def home(self):
return self.location('https://isohunt.com')
......
......@@ -73,7 +73,8 @@ class TorrentPage(BasePage):
title = NotAvailable
size = NotAvailable
url = 'https://isohunt.com/download/%s/%s.torrent' % (id, id)
title = unicode(self.parser.select(self.document.getroot(),'head > meta[name=title]',1).attrib.get('content',''))
title = unicode(self.parser.select(
self.document.getroot(), 'head > meta[name=title]', 1).attrib.get('content', ''))
seed = NotAvailable
leech = NotAvailable
tip_id = "none"
......
......@@ -72,5 +72,5 @@ class KickassBackend(BaseBackend, ICapTorrent):
return torrent
OBJECTS = {
Torrent:fill_torrent
Torrent: fill_torrent
}
......@@ -34,7 +34,7 @@ class KickassBrowser(BaseBrowser):
PAGES = {
'http://kat.ph/usearch/.*field=seeders&sorder=desc': TorrentsPage,
'http://kat.ph/.*.html': TorrentPage,
}
}
def home(self):
return self.location('http://kat.ph')
......
......@@ -31,7 +31,7 @@ from weboob.tools.browser import BasePage
from weboob.tools.misc import get_bytes_size
__all__ = ['TorrentsPage','TorrentPage']
__all__ = ['TorrentsPage', 'TorrentPage']
class TorrentsPage(BasePage):
......@@ -53,14 +53,14 @@ class TorrentsPage(BasePage):
.replace('.html', '')
# look for url
for a in self.parser.select(tr,'div.iaconbox a'):
for a in self.parser.select(tr, 'div.iaconbox a'):
href = a.attrib.get('href', '')
if href.startswith('magnet'):
magnet = unicode(href)
elif href.startswith('http'):
url = unicode(href)
elif href.startswith('//'):
url = u'http:%s'%href
url = u'http:%s' % href
size = tr.getchildren()[1].text
u = tr.getchildren()[1].getchildren()[0].text
......@@ -107,16 +107,16 @@ class TorrentPage(BasePage):
leech = 0
title = self.parser.select(self.document.getroot(),
'h1.torrentName span', 1)
'h1.torrentName span', 1)
title = unicode(title.text)
for a in self.parser.select(self.document.getroot(),
'div.downloadButtonGroup a'):
'div.downloadButtonGroup a'):
href = a.attrib.get('href', '')
if href.startswith('magnet'):
magnet = unicode(href)
elif href.startswith('//'):
url = u'http:%s'%href
url = u'http:%s' % href
elif href.startswith('http'):
url = unicode(href)
......@@ -127,7 +127,7 @@ class TorrentPage(BasePage):
# is enough to know if this is the right span
if (span.attrib.get('class', '') == 'folder'
or span.attrib.get('class', '') == 'folderopen') \
and len(span.getchildren()) > 2:
and len(span.getchildren()) > 2:
size = span.getchildren()[1].tail
u = span.getchildren()[2].text
size = float(size.split(': ')[1].replace(',', '.'))
......
......@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.capabilities.recipe import ICapRecipe,Recipe
from weboob.capabilities.recipe import ICapRecipe, Recipe
from weboob.tools.backend import BaseBackend
from .browser import MarmitonBrowser
......@@ -48,16 +48,16 @@ class MarmitonBackend(BaseBackend, ICapRecipe):
def fill_recipe(self, recipe, fields):