[expotv] Improve extraction and update test

This commit is contained in:
Sergey M․ 2016-08-13 16:29:05 +07:00
parent acfccacad5
commit e97c55ee6a
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -1,7 +1,5 @@
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 (
int_or_none, int_or_none,
@ -12,23 +10,22 @@ from ..utils import (
class ExpoTVIE(InfoExtractor): class ExpoTVIE(InfoExtractor):
_VALID_URL = r'https?://www\.expotv\.com/videos/[^?#]*/(?P<id>[0-9]+)($|[?#])' _VALID_URL = r'https?://www\.expotv\.com/videos/[^?#]*/(?P<id>[0-9]+)($|[?#])'
_TEST = { _TEST = {
'url': 'http://www.expotv.com/videos/reviews/1/24/LinneCardscom/17561', 'url': 'http://www.expotv.com/videos/reviews/3/40/NYX-Butter-lipstick/667916',
'md5': '2985e6d7a392b2f7a05e0ca350fe41d0', 'md5': 'fe1d728c3a813ff78f595bc8b7a707a8',
'info_dict': { 'info_dict': {
'id': '17561', 'id': '667916',
'ext': 'mp4', 'ext': 'mp4',
'upload_date': '20060212', 'title': 'NYX Butter Lipstick Little Susie',
'title': 'My Favorite Online Scrapbook Store', 'description': 'Goes on like butter, but looks better!',
'view_count': int,
'description': 'You\'ll find most everything you need at this virtual store front.',
'uploader': 'Anna T.',
'thumbnail': 're:^https?://.*\.jpg$', 'thumbnail': 're:^https?://.*\.jpg$',
'uploader': 'Stephanie S.',
'upload_date': '20150520',
'view_count': int,
} }
} }
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('id')
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
player_key = self._search_regex( player_key = self._search_regex(
@ -66,7 +63,7 @@ class ExpoTVIE(InfoExtractor):
fatal=False) fatal=False)
upload_date = unified_strdate(self._search_regex( upload_date = unified_strdate(self._search_regex(
r'<h5>Reviewed on ([0-9/.]+)</h5>', webpage, 'upload date', r'<h5>Reviewed on ([0-9/.]+)</h5>', webpage, 'upload date',
fatal=False)) fatal=False), day_first=False)
return { return {
'id': video_id, 'id': video_id,