suboob+attilasub works
This commit is contained in:
parent
591db5c1be
commit
95d4f67630
5 changed files with 80 additions and 13 deletions
|
|
@ -39,8 +39,8 @@ class AttilasubBackend(BaseBackend, ICapSubtitle):
|
|||
def create_default_browser(self):
|
||||
return self.create_browser()
|
||||
|
||||
#def get_subtitle(self, id):
|
||||
# return self.browser.get_subtitle(id)
|
||||
def get_subtitle(self, id):
|
||||
return self.browser.get_subtitle(id)
|
||||
|
||||
def get_subtitle_file(self, id):
|
||||
subtitle = self.browser.get_subtitle(id)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,8 @@ class AttilasubBrowser(BaseBrowser):
|
|||
assert self.is_on_page(SearchPage)
|
||||
return self.page.iter_subtitles(pattern)
|
||||
|
||||
#def get_torrent(self, id):
|
||||
# self.location('http://kat.ph/%s.html' % id)
|
||||
# assert self.is_on_page(TorrentPage)
|
||||
# return self.page.get_torrent(id)
|
||||
def get_subtitle(self, id):
|
||||
url_end = id.split('|')[0]
|
||||
self.location('http://davidbillemont3.free.fr/%s' % url_end)
|
||||
assert self.is_on_page(SubtitlesPage)
|
||||
return self.page.get_subtitle(id)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ __all__ = ['SubtitlesPage','SearchPage']
|
|||
class SearchPage(BasePage):
|
||||
def iter_subtitles(self,pattern):
|
||||
fontresult = self.parser.select(self.document.getroot(),'div.search-results font.search-results')
|
||||
# for each result in freefind, explore the page to iter subtitles
|
||||
# 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','')
|
||||
|
|
@ -49,6 +49,30 @@ class SearchPage(BasePage):
|
|||
|
||||
|
||||
class SubtitlesPage(BasePage):
|
||||
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)
|
||||
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()
|
||||
|
||||
traduced_title_words = traduced_title.split()
|
||||
original_title_words = original_title.split()
|
||||
|
||||
# this is to trash special spacing chars
|
||||
traduced_title = " ".join(traduced_title_words)
|
||||
original_title = " ".join(original_title_words)
|
||||
|
||||
name = "%s (%s)"%(original_title,traduced_title)
|
||||
url = "http://davidbillemont3.free.fr/%s"%href
|
||||
subtitle = Subtitle(id,name)
|
||||
subtitle.url = url
|
||||
subtitle.fps = 0
|
||||
subtitle.description = "no desc"
|
||||
return subtitle
|
||||
|
||||
def iter_subtitles(self,pattern):
|
||||
pattern = pattern.strip().replace('+',' ')
|
||||
pattern_words = pattern.split()
|
||||
|
|
@ -76,8 +100,12 @@ class SubtitlesPage(BasePage):
|
|||
traduced_title = " ".join(traduced_title_words)
|
||||
original_title = " ".join(original_title_words)
|
||||
|
||||
title = "%s (%s)"%(original_title,traduced_title)
|
||||
subtitle = Subtitle(title,title)
|
||||
subtitle.url = self.parser.select(cols[3],'a',1).attrib.get('href','')
|
||||
name = "%s (%s)"%(original_title,traduced_title)
|
||||
href = self.parser.select(cols[3],'a',1).attrib.get('href','')
|
||||
url = "http://davidbillemont3.free.fr/%s"%href
|
||||
id = "%s|%s"%(self.browser.geturl().split('/')[-1],href)
|
||||
subtitle = Subtitle(id,name)
|
||||
subtitle.url = url
|
||||
subtitle.fps = 0
|
||||
subtitle.description = "no desc"
|
||||
yield subtitle
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue