[nintendo] Improve playlist extraction (Closes #9986)

This commit is contained in:
Sergey M․ 2016-07-17 00:01:25 +07:00
parent a2f9ca1e67
commit 49bc16b95e
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D

View file

@ -1,13 +1,15 @@
# coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
from .common import InfoExtractor
from .ooyala import OoyalaIE
import re import re
from .common import InfoExtractor
from .ooyala import OoyalaIE
from ..utils import unescapeHTML
class NintendoIE(InfoExtractor): class NintendoIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?nintendo\.com/games/detail/(?P<id>[\w-]+)' _VALID_URL = r'https?://(?:www\.)?nintendo\.com/games/detail/(?P<id>[^/?#&]+)'
_TESTS = [{ _TESTS = [{
'url': 'http://www.nintendo.com/games/detail/yEiAzhU2eQI1KZ7wOHhngFoAHc1FpHwj', 'url': 'http://www.nintendo.com/games/detail/yEiAzhU2eQI1KZ7wOHhngFoAHc1FpHwj',
'info_dict': { 'info_dict': {
@ -24,24 +26,21 @@ class NintendoIE(InfoExtractor):
'url': 'http://www.nintendo.com/games/detail/tokyo-mirage-sessions-fe-wii-u', 'url': 'http://www.nintendo.com/games/detail/tokyo-mirage-sessions-fe-wii-u',
'info_dict': { 'info_dict': {
'id': 'tokyo-mirage-sessions-fe-wii-u', 'id': 'tokyo-mirage-sessions-fe-wii-u',
'title': 'Tokyo Mirage Sessions ♯FE',
}, },
'params': { 'playlist_count': 3,
'skip_download': True,
},
'add_ie': ['Ooyala'],
'playlist_count': 4,
}] }]
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) page_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
ooyala_codes = re.findall( webpage = self._download_webpage(url, page_id)
r'data-video-code=(["\'])(?P<code>.+?)\1',
webpage)
entries = [] entries = [
for ooyala_code in ooyala_codes: OoyalaIE._build_url_result(m.group('code'))
entries.append(OoyalaIE._build_url_result(ooyala_code[1])) for m in re.finditer(
r'class=(["\'])embed-video\1[^>]+data-video-code=(["\'])(?P<code>(?:(?!\2).)+)\2',
webpage)]
return self.playlist_result(entries, video_id, self._og_search_title(webpage)) return self.playlist_result(
entries, page_id, unescapeHTML(self._og_search_title(webpage, fatal=False)))