[criterion] Simplify and modernize

pull/2/head
Philipp Hagemeister 11 years ago
parent fada438acf
commit 4e415288d7

@ -1,40 +1,43 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals
import re import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import determine_ext
class CriterionIE(InfoExtractor): class CriterionIE(InfoExtractor):
_VALID_URL = r'https?://www\.criterion\.com/films/(\d*)-.+' _VALID_URL = r'https?://www\.criterion\.com/films/(?P<id>[0-9]+)-.+'
_TEST = { _TEST = {
u'url': u'http://www.criterion.com/films/184-le-samourai', 'url': 'http://www.criterion.com/films/184-le-samourai',
u'file': u'184.mp4', 'md5': 'bc51beba55685509883a9a7830919ec3',
u'md5': u'bc51beba55685509883a9a7830919ec3', 'info_dict': {
u'info_dict': { 'id': '184',
u"title": u"Le Samouraï", 'ext': 'mp4',
u"description" : u'md5:a2b4b116326558149bef81f76dcbb93f', 'title': 'Le Samouraï',
'description': 'md5:a2b4b116326558149bef81f76dcbb93f',
} }
} }
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
video_id = mobj.group(1) video_id = mobj.group('id')
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
final_url = self._search_regex(r'so.addVariable\("videoURL", "(.+?)"\)\;', final_url = self._search_regex(
webpage, 'video url') r'so.addVariable\("videoURL", "(.+?)"\)\;', webpage, 'video url')
title = self._html_search_regex(r'<meta content="(.+?)" property="og:title" />', title = self._og_search_title(webpage)
webpage, 'video title') description = self._html_search_regex(
description = self._html_search_regex(r'<meta name="description" content="(.+?)" />', r'<meta name="description" content="(.+?)" />',
webpage, 'video description') webpage, 'video description')
thumbnail = self._search_regex(r'so.addVariable\("thumbnailURL", "(.+?)"\)\;', thumbnail = self._search_regex(
webpage, 'thumbnail url') r'so.addVariable\("thumbnailURL", "(.+?)"\)\;',
webpage, 'thumbnail url')
return {'id': video_id, return {
'url' : final_url, 'id': video_id,
'title': title, 'url': final_url,
'ext': determine_ext(final_url), 'title': title,
'description': description, 'description': description,
'thumbnail': thumbnail, 'thumbnail': thumbnail,
} }

Loading…
Cancel
Save