add attribute 'ext'

This commit is contained in:
Romain Bignon 2013-07-27 13:32:11 +02:00
commit 6c0e9e34a2
4 changed files with 19 additions and 1 deletions

View file

@ -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

View file

@ -17,6 +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/>.
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)

View file

@ -17,6 +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/>.
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

View file

@ -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.