Fix indents not multiples of four

This commit is contained in:
Laurent Bachelier 2013-03-15 22:46:26 +01:00
commit f37e3c5742
5 changed files with 44 additions and 44 deletions

View file

@ -109,7 +109,7 @@ class VideoPage(BasePage):
raise BrokenPageError('Unable to extract video url') raise BrokenPageError('Unable to extract video url')
flashvars = urllib.unquote(mobj.group(1)) flashvars = urllib.unquote(mobj.group(1))
for key in ['hd1080URL', 'hd720URL', 'hqURL', 'sdURL', 'ldURL', 'video_url']: for key in ['hd1080URL', 'hd720URL', 'hqURL', 'sdURL', 'ldURL', 'video_url']:
if key in flashvars: if key in flashvars:
max_quality = key max_quality = key
break break

View file

@ -28,17 +28,17 @@ __all__ = ['LoginPage']
class LoginPage(BasePage): class LoginPage(BasePage):
def login(self, login, passwd): def login(self, login, passwd):
msgb = self.document.xpath(".//*[@id='message_client']/text()") msgb = self.document.xpath(".//*[@id='message_client']/text()")
msga = ''.join(msgb) msga = ''.join(msgb)
msg = msga.strip("\n") msg = msga.strip("\n")
if "maintenance" in msg: if "maintenance" in msg:
raise BrowserUnavailable(msg) raise BrowserUnavailable(msg)
self.browser.select_form(nr=3) self.browser.select_form(nr=3)
self.browser['login'] = login self.browser['login'] = login
self.browser['passwd'] = passwd self.browser['passwd'] = passwd
self.browser.submit(nologin=True) self.browser.submit(nologin=True)
# vim:ts=4:sw=4 # vim:ts=4:sw=4

View file

@ -42,10 +42,10 @@ __all__ = ['OkCBackend']
def parse_dt(s): def parse_dt(s):
now = datetime.datetime.now() now = datetime.datetime.now()
if s is None: if s is None:
return local2utc(now) return local2utc(now)
if 'minutes ago' in s: if 'minutes ago' in s:
m = int(s.split()[0]) m = int(s.split()[0])
d = now - datetime.timedelta(minutes=m) d = now - datetime.timedelta(minutes=m)
elif u'' in s: elif u'' in s:
# Date in form : "Yesterday 20:45" # Date in form : "Yesterday 20:45"
day, hour = s.split(u'') day, hour = s.split(u'')

View file

@ -27,12 +27,12 @@ __all__ = ['HomePage','SearchPage','SeriePage','SeasonPage']
class HomePage(BasePage): class HomePage(BasePage):
def iter_subtitles(self,language,pattern): def iter_subtitles(self,language,pattern):
self.browser.select_form(nr=0) self.browser.select_form(nr=0)
self.browser['q'] = pattern.encode('utf-8') self.browser['q'] = pattern.encode('utf-8')
self.browser.submit() self.browser.submit()
assert self.browser.is_on_page(SearchPage) assert self.browser.is_on_page(SearchPage)
for subtitle in self.browser.page.iter_subtitles(language): for subtitle in self.browser.page.iter_subtitles(language):
yield subtitle yield subtitle
class SearchPage(BasePage): class SearchPage(BasePage):

View file

@ -28,28 +28,28 @@ LAST_THING_IN_PARENTHESIS = re.compile("\([^)]\)$")
class TranslatePage(BasePage): class TranslatePage(BasePage):
def get_translation(self): def get_translation(self):
# taking the first signification in the case several were found # taking the first signification in the case several were found
for tr in self.document.getiterator('tr'): for tr in self.document.getiterator('tr'):
prev_was_nums1 = False prev_was_nums1 = False
for td in tr.getiterator('td'): for td in tr.getiterator('td'):
if prev_was_nums1: if prev_was_nums1:
result = u''+td.text_content().split(';')[0].strip() result = u''+td.text_content().split(';')[0].strip()
result = LAST_THING_IN_PARENTHESIS.sub("",result) result = LAST_THING_IN_PARENTHESIS.sub("",result)
return result return result
if td.attrib.get('class','') == 'nums1': if td.attrib.get('class','') == 'nums1':
prev_was_nums1 = True prev_was_nums1 = True
# if only one signification is found # if only one signification is found
for div in self.document.getiterator('div'): for div in self.document.getiterator('div'):
if div.attrib.get('class','') == "trans clickable": if div.attrib.get('class','') == "trans clickable":
names = u''+" ".join(div.text_content().split(']')[1].split()[1:]).split(';')[0] names = u''+" ".join(div.text_content().split(']')[1].split()[1:]).split(';')[0]
names = LAST_THING_IN_PARENTHESIS.sub("",names) names = LAST_THING_IN_PARENTHESIS.sub("",names)
return names.strip() return names.strip()
# another numerotation possibility... # another numerotation possibility...
for table in self.document.getiterator('table'): for table in self.document.getiterator('table'):
if table.attrib.get('class','') == "trans clickable": if table.attrib.get('class','') == "trans clickable":
prev_was_roman1 = False prev_was_roman1 = False
for td in table.getiterator('td'): for td in table.getiterator('td'):
if prev_was_roman1: if prev_was_roman1:
return u''+td.text_content().split(';')[0].strip() return u''+td.text_content().split(';')[0].strip()
if td.attrib.get('class','') == 'roman1': if td.attrib.get('class','') == 'roman1':
prev_was_roman1 = True prev_was_roman1 = True