diff --git a/modules/attilasub/pages.py b/modules/attilasub/pages.py index 6828b25f..c8a1fc0d 100644 --- a/modules/attilasub/pages.py +++ b/modules/attilasub/pages.py @@ -63,6 +63,7 @@ class SubtitlesPage(BasePage): url = unicode('http://davidbillemont3.free.fr/%s' % href) subtitle = Subtitle(id, name) subtitle.url = url + subtitle.ext = url.split('.')[-1] subtitle.language = unicode('fr') subtitle.nb_cd = nb_cd subtitle.description = NotAvailable @@ -106,6 +107,7 @@ class SubtitlesPage(BasePage): id = unicode('%s|%s' % (self.browser.geturl().split('/')[-1], href)) subtitle = Subtitle(id, name) subtitle.url = url + subtitle.ext = url.split('.')[-1] subtitle.language = unicode('fr') subtitle.nb_cd = nb_cd subtitle.description = NotAvailable diff --git a/modules/opensubtitles/pages.py b/modules/opensubtitles/pages.py index d3058eb9..586f34ba 100644 --- a/modules/opensubtitles/pages.py +++ b/modules/opensubtitles/pages.py @@ -17,6 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . +import re from weboob.capabilities.subtitle import Subtitle from weboob.capabilities.base import NotAvailable, NotLoaded @@ -109,6 +110,11 @@ class SubtitlePage(BasePage): father = self.parser.select(self.document.getroot(), 'a#app_link', 1).getparent() a = self.parser.select(father, 'a')[1] id = a.attrib.get('href', '').split('/')[-1] + m = re.match('Download \((\w+)\)', self.parser.tocleanstring(a)) + if m: + ext = m.group(1) + else: + ext = u'zip' url = unicode('http://www.opensubtitles.org/subtitleserve/sub/%s' % id) link = self.parser.select(self.document.getroot(), 'link[rel=bookmark]', 1) title = unicode(link.attrib.get('title', '')) @@ -126,6 +132,7 @@ class SubtitlePage(BasePage): subtitle = Subtitle(id, name) subtitle.url = url + subtitle.ext = ext for lshort, llong in LANGUAGE_CONV.items(): if lang == llong: lang = unicode(lshort) diff --git a/modules/tvsubtitles/pages.py b/modules/tvsubtitles/pages.py index 0e640150..c7610baa 100644 --- a/modules/tvsubtitles/pages.py +++ b/modules/tvsubtitles/pages.py @@ -17,6 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . +import re from weboob.capabilities.subtitle import Subtitle from weboob.tools.browser import BasePage @@ -95,8 +96,16 @@ class SeasonPage(BasePage): desc = u"files :\n" desc += file_names + m = re.match('(.*?)\.(\w+)$', name) + if m: + name = m.group(1) + ext = m.group(2) + else: + ext = 'zip' + subtitle = Subtitle(id, name) subtitle.url = url + subtitle.ext = ext subtitle.language = lang subtitle.nb_cd = nb_cd subtitle.description = desc diff --git a/weboob/capabilities/subtitle.py b/weboob/capabilities/subtitle.py index 2436a5ac..3b3e0da5 100644 --- a/weboob/capabilities/subtitle.py +++ b/weboob/capabilities/subtitle.py @@ -38,6 +38,7 @@ class Subtitle(CapBaseObject): Subtitle object. """ name = StringField('Name of subtitle') + ext = StringField('Extension of file') url = StringField('Direct url to subtitle file') nb_cd = IntField('Number of cd or files') language = StringField('Language of the subtitle') @@ -47,7 +48,6 @@ class Subtitle(CapBaseObject): CapBaseObject.__init__(self, id) self.name = name - class ICapSubtitle(IBaseCap): """ Subtitle providers.