[ro220] Fix broken extractor and modernize (#4054)

This commit is contained in:
Naglis Jonaitis 2014-10-30 01:42:52 +02:00
parent feb74960eb
commit b8a618f898

View file

@ -1,43 +1,43 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import compat_urllib_parse_unquote
clean_html,
compat_parse_qs,
)
class Ro220IE(InfoExtractor): class Ro220IE(InfoExtractor):
IE_NAME = '220.ro' IE_NAME = '220.ro'
_VALID_URL = r'(?x)(?:https?://)?(?:www\.)?220\.ro/(?P<category>[^/]+)/(?P<shorttitle>[^/]+)/(?P<video_id>[^/]+)' _VALID_URL = r'(?x)(?:https?://)?(?:www\.)?220\.ro/(?P<category>[^/]+)/(?P<shorttitle>[^/]+)/(?P<id>[^/]+)'
_TEST = { _TEST = {
"url": "http://www.220.ro/sport/Luati-Le-Banii-Sez-4-Ep-1/LYV6doKo7f/", 'url': 'http://www.220.ro/sport/Luati-Le-Banii-Sez-4-Ep-1/LYV6doKo7f/',
'file': 'LYV6doKo7f.mp4',
'md5': '03af18b73a07b4088753930db7a34add', 'md5': '03af18b73a07b4088753930db7a34add',
'info_dict': { 'info_dict': {
"title": "Luati-le Banii sez 4 ep 1", 'id': 'LYV6doKo7f',
"description": "re:^Iata-ne reveniti dupa o binemeritata vacanta\. +Va astept si pe Facebook cu pareri si comentarii.$", 'ext': 'mp4',
'title': 'Luati-le Banii sez 4 ep 1',
'description': 're:^Iata-ne reveniti dupa o binemeritata vacanta\. +Va astept si pe Facebook cu pareri si comentarii.$',
} }
} }
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) video_id = self._match_id(url)
video_id = mobj.group('video_id')
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
flashVars_str = self._search_regex( url = compat_urllib_parse_unquote(self._search_regex(
r'<param name="flashVars" value="([^"]+)"', r'(?s)clip\s*:\s*{.*?url\s*:\s*\'([^\']+)\'', webpage, 'url'))
webpage, 'flashVars') title = self._og_search_title(webpage)
flashVars = compat_parse_qs(flashVars_str) description = self._og_search_description(webpage)
thumbnail = self._og_search_thumbnail(webpage)
formats = [{
'format_id': 'sd',
'url': url,
'ext': 'mp4',
}]
return { return {
'_type': 'video',
'id': video_id, 'id': video_id,
'ext': 'mp4', 'formats': formats,
'url': flashVars['videoURL'][0], 'title': title,
'title': flashVars['title'][0], 'description': description,
'description': clean_html(flashVars['desc'][0]), 'thumbnail': thumbnail,
'thumbnail': flashVars['preview'][0],
} }