diff options
author | Sergey M․ <dstftw@gmail.com> | 2016-01-23 00:04:33 +0600 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2016-01-23 00:04:33 +0600 |
commit | 10677ece81b7ed05bb84a0dbaf5bd237107eeb62 (patch) | |
tree | d3240ade485c6a5847cbd4bcc9262795d939d67d /youtube_dl/extractor/trollvids.py | |
parent | d570746e45cff3c0f89654bf748e44a5da75a924 (diff) |
[nuevo] Simplify nuevo extractors (Closes #7728)
Diffstat (limited to 'youtube_dl/extractor/trollvids.py')
-rw-r--r-- | youtube_dl/extractor/trollvids.py | 55 |
1 files changed, 21 insertions, 34 deletions
diff --git a/youtube_dl/extractor/trollvids.py b/youtube_dl/extractor/trollvids.py index e4fe620f7..d239949a6 100644 --- a/youtube_dl/extractor/trollvids.py +++ b/youtube_dl/extractor/trollvids.py @@ -1,49 +1,36 @@ # encoding: utf-8 from __future__ import unicode_literals -from .nuevo import NuevoBaseIE - -from ..compat import ( - compat_urllib_parse_unquote -) - import re +from .nuevo import NuevoBaseIE + class TrollvidsIE(NuevoBaseIE): - _VALID_URL = r'http://(?:www\.)?trollvids\.com/+video/+(?P<id>[0-9]+)/+(?P<title>[^?&]+)' + _VALID_URL = r'http://(?:www\.)?trollvids\.com/video/(?P<id>\d+)/(?P<display_id>[^/?#&]+)' IE_NAME = 'trollvids' + _TEST = { + 'url': 'http://trollvids.com/video/2349002/%E3%80%90MMD-R-18%E3%80%91%E3%82%AC%E3%83%BC%E3%83%AB%E3%83%95%E3%83%AC%E3%83%B3%E3%83%89-carrymeoff', + 'md5': '1d53866b2c514b23ed69e4352fdc9839', + 'info_dict': { + 'id': '2349002', + 'ext': 'mp4', + 'title': '【MMD R-18】ガールフレンド carry_me_off', + 'age_limit': 18, + 'duration': 216.78, + }, + } def _real_extract(self, url): - match = re.match(self._VALID_URL, url) - - video_id = match.group('id') - raw_video_title = match.group('title') - url = 'http://trollvids.com/video/%s/%s' % (video_id, raw_video_title) - config_url = 'http://trollvids.com/nuevo/player/config.php?v=%s' % video_id - - info = self._extract_nuevo(config_url, video_id) + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group('id') + display_id = mobj.group('display_id') + info = self._extract_nuevo( + 'http://trollvids.com/nuevo/player/config.php?v=%s' % video_id, + video_id) info.update({ - 'webpage_url': url, + 'display_id': display_id, 'age_limit': 18 }) - - if 'title' not in info: - info['title'] = compat_urllib_parse_unquote(raw_video_title) - return info - - _TESTS = [ - { - 'url': 'http://trollvids.com/video/2349002/%E3%80%90MMD-R-18%E3%80%91%E3%82%AC%E3%83%BC%E3%83%AB%E3%83%95%E3%83%AC%E3%83%B3%E3%83%89-carrymeoff', - 'md5': '1d53866b2c514b23ed69e4352fdc9839', - 'info_dict': { - 'id': '2349002', - 'ext': 'mp4', - 'title': "【MMD R-18】ガールフレンド carry_me_off", - 'age_limit': 18, - 'duration': 216.78, - }, - }, - ] |