[ntv] Simplify
This commit is contained in:
parent
b17418313f
commit
056b56688a
1 changed files with 9 additions and 10 deletions
|
@ -5,7 +5,7 @@ import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
RegexNotFoundError,
|
ExtractorError,
|
||||||
unescapeHTML
|
unescapeHTML
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -98,16 +98,15 @@ class NTVIE(InfoExtractor):
|
||||||
|
|
||||||
page = self._download_webpage(url, video_id, 'Downloading page')
|
page = self._download_webpage(url, video_id, 'Downloading page')
|
||||||
|
|
||||||
def extract(patterns, name, page, fatal=False):
|
for pattern in self._VIDEO_ID_REGEXES:
|
||||||
for pattern in patterns:
|
|
||||||
mobj = re.search(pattern, page)
|
mobj = re.search(pattern, page)
|
||||||
if mobj:
|
if mobj:
|
||||||
return mobj.group(1)
|
break
|
||||||
if fatal:
|
|
||||||
raise RegexNotFoundError(u'Unable to extract %s' % name)
|
|
||||||
return None
|
|
||||||
|
|
||||||
video_id = extract(self._VIDEO_ID_REGEXES, 'video id', page, fatal=True)
|
if not mobj:
|
||||||
|
raise ExtractorError('No media links available for %s' % video_id)
|
||||||
|
|
||||||
|
video_id = mobj.group(1)
|
||||||
|
|
||||||
player = self._download_xml('http://www.ntv.ru/vi%s/' % video_id, video_id, 'Downloading video XML')
|
player = self._download_xml('http://www.ntv.ru/vi%s/' % video_id, video_id, 'Downloading video XML')
|
||||||
title = unescapeHTML(player.find('./data/title').text)
|
title = unescapeHTML(player.find('./data/title').text)
|
||||||
|
|
Loading…
Reference in a new issue