1 from __future__
import unicode_literals
5 from .once
import OnceIE
7 compat_urllib_parse_unquote
,
16 class GameSpotIE(OnceIE
):
17 _VALID_URL
= r
'https?://(?:www\.)?gamespot\.com/.*-(?P<id>\d+)/?'
19 'url': 'http://www.gamespot.com/videos/arma-3-community-guide-sitrep-i/2300-6410818/',
20 'md5': 'b2a30deaa8654fcccd43713a6b6a4825',
22 'id': 'gs-2300-6410818',
24 'title': 'Arma 3 - Community Guide: SITREP I',
25 'description': 'Check out this video where some of the basics of Arma 3 is explained.',
28 'url': 'http://www.gamespot.com/videos/the-witcher-3-wild-hunt-xbox-one-now-playing/2300-6424837/',
30 'id': 'gs-2300-6424837',
32 'title': 'The Witcher 3: Wild Hunt [Xbox ONE] - Now Playing',
33 'description': 'Join us as we take a look at the early hours of The Witcher 3: Wild Hunt and more.',
37 def _real_extract(self
, url
):
38 page_id
= self
._match
_id
(url
)
39 webpage
= self
._download
_webpage
(url
, page_id
)
40 data_video_json
= self
._search
_regex
(
41 r
'data-video=["\'](.*?
)["\']', webpage, 'data video')
42 data_video = self._parse_json(unescapeHTML(data_video_json), page_id)
43 streams = data_video['videoStreams']
47 f4m_url = streams.get('f4m_stream')
49 manifest_url = f4m_url
50 formats.extend(self._extract_f4m_formats(
51 f4m_url + '?hdcore=3.7.0', page_id, f4m_id='hds', fatal=False))
52 m3u8_url = streams.get('m3u8_stream')
54 manifest_url = m3u8_url
55 m3u8_formats = self._extract_m3u8_formats(
56 m3u8_url, page_id, 'mp4', 'm3u8_native',
57 m3u8_id='hls', fatal=False)
58 formats.extend(m3u8_formats)
59 progressive_url = dict_get(
60 streams, ('progressive_hd', 'progressive_high', 'progressive_low'))
61 if progressive_url and manifest_url:
62 qualities_basename = self._search_regex(
64 manifest_url, 'qualities basename', default=None)
65 if qualities_basename:
66 QUALITIES_RE = r'((,\d+)+,?)'
67 qualities = self._search_regex(
68 QUALITIES_RE, qualities_basename,
69 'qualities', default=None)
71 qualities = list(map(lambda q: int(q), qualities.strip(',').split(',')))
73 http_template = re.sub(QUALITIES_RE, r'%d', qualities_basename)
74 http_url_basename = url_basename(progressive_url)
76 self._sort_formats(m3u8_formats)
77 m3u8_formats = list(filter(
78 lambda f: f.get('vcodec') != 'none' and f.get('resolution') != 'multiple',
80 if len(qualities) == len(m3u8_formats):
81 for q, m3u8_format in zip(qualities, m3u8_formats):
82 f = m3u8_format.copy()
84 'url': progressive_url.replace(
85 http_url_basename, http_template % q),
86 'format_id': f['format_id'].replace('hls', 'http'),
93 'url': progressive_url.replace(
94 http_url_basename, http_template % q),
96 'format_id': 'http-%d' % q,
100 onceux_json = self._search_regex(
101 r'data-onceux-options=["\'](.*?
)["\']', webpage, 'data video', default=None)
103 onceux_url = self._parse_json(unescapeHTML(onceux_json), page_id).get('metadataUri')
105 formats.extend(self._extract_once_formats(re.sub(
106 r'https?://[^/]+', 'http://once.unicornmedia.com', onceux_url).replace('ads/vmap/', '')))
109 for quality in ['sd', 'hd']:
110 # It's actually a link to a flv file
111 flv_url = streams.get('f4m_{0}'.format(quality))
112 if flv_url is not None:
116 'format_id': quality,
118 self._sort_formats(formats)
121 'id': data_video['guid'],
122 'display_id': page_id,
123 'title': compat_urllib_parse_unquote(data_video['title']),
125 'description': self._html_search_meta('description', webpage),
126 'thumbnail': self._og_search_thumbnail(webpage),