diff options
author | Sergey M․ <dstftw@gmail.com> | 2014-03-29 15:55:03 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2014-03-29 15:55:03 +0700 |
commit | 056b56688a2ee5ba39dd5b2cbb003fd98529180f (patch) | |
tree | da2188f2489625bd2521b8def1e46512cef3e19d /youtube_dl/extractor/ntv.py | |
parent | b17418313f15f030dcc938f5618cdccf55752e39 (diff) |
[ntv] Simplify
Diffstat (limited to 'youtube_dl/extractor/ntv.py')
-rw-r--r-- | youtube_dl/extractor/ntv.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/youtube_dl/extractor/ntv.py b/youtube_dl/extractor/ntv.py index e998d156e..8447a9b86 100644 --- a/youtube_dl/extractor/ntv.py +++ b/youtube_dl/extractor/ntv.py @@ -5,7 +5,7 @@ import re from .common import InfoExtractor from ..utils import ( - RegexNotFoundError, + ExtractorError, unescapeHTML ) @@ -98,16 +98,15 @@ class NTVIE(InfoExtractor): page = self._download_webpage(url, video_id, 'Downloading page') - def extract(patterns, name, page, fatal=False): - for pattern in patterns: - mobj = re.search(pattern, page) - if mobj: - return mobj.group(1) - if fatal: - raise RegexNotFoundError(u'Unable to extract %s' % name) - return None + for pattern in self._VIDEO_ID_REGEXES: + mobj = re.search(pattern, page) + if mobj: + break - 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') title = unescapeHTML(player.find('./data/title').text) |