2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
8 compat_urllib_parse_urlencode
,
12 get_element_by_attribute
,
20 class MiTeleBaseIE(InfoExtractor
):
21 def _get_player_info(self
, url
, webpage
):
22 player_data
= extract_attributes(self
._search
_regex
(
23 r
'(?s)(<ms-video-player.+?</ms-video-player>)',
24 webpage
, 'ms video player'))
25 video_id
= player_data
['data-media-id']
26 config_url
= compat_urlparse
.urljoin(url
, player_data
['data-config'])
27 config
= self
._download
_json
(
28 config_url
, video_id
, 'Downloading config JSON')
29 mmc_url
= config
['services']['mmc']
33 for m_url
in (mmc_url
, mmc_url
.replace('/flash.json', '/html5.json')):
34 mmc
= self
._download
_json
(
35 m_url
, video_id
, 'Downloading mmc JSON')
37 duration
= int_or_none(mmc
.get('duration'))
38 for location
in mmc
['locations']:
39 gat
= self
._proto
_relative
_url
(location
.get('gat'), 'http:')
40 bas
= location
.get('bas')
41 loc
= location
.get('loc')
42 ogn
= location
.get('ogn')
43 if None in (gat
, bas
, loc
, ogn
):
51 media
= self
._download
_json
(
52 '%s/?%s' % (gat
, compat_urllib_parse_urlencode(token_data
)),
53 video_id
, 'Downloading %s JSON' % location
['loc'])
54 file_
= media
.get('file')
57 ext
= determine_ext(file_
)
59 formats
.extend(self
._extract
_f
4m
_formats
(
60 file_
+ '&hdcore=3.2.0&plugin=aasp-3.2.0.77.18',
61 video_id
, f4m_id
='hds', fatal
=False))
63 formats
.extend(self
._extract
_m
3u8_formats
(
64 file_
, video_id
, 'mp4', 'm3u8_native', m3u8_id
='hls', fatal
=False))
65 self
._sort
_formats
(formats
)
70 'thumbnail': player_data
.get('data-poster') or config
.get('poster', {}).get('imageUrl'),
75 class MiTeleIE(MiTeleBaseIE
):
77 _VALID_URL
= r
'https?://www\.mitele\.es/(?:[^/]+/){3}(?P<id>[^/]+)/'
80 'url': 'http://www.mitele.es/programas-tv/diario-de/la-redaccion/programa-144/',
83 'id': '0NF1jJnxS1Wu3pHrmvFyw2',
84 'display_id': 'programa-144',
86 'title': 'Tor, la web invisible',
87 'description': 'md5:3b6fce7eaa41b2d97358726378d9369f',
88 'series': 'Diario de',
89 'season': 'La redacción',
90 'episode': 'Programa 144',
91 'thumbnail': 're:(?i)^https?://.*\.jpg$',
96 'url': 'http://www.mitele.es/programas-tv/cuarto-milenio/temporada-6/programa-226/',
98 'id': 'eLZSwoEd1S3pVyUm8lc6F',
99 'display_id': 'programa-226',
101 'title': 'Cuarto Milenio - Temporada 6 - Programa 226',
102 'description': 'md5:50daf9fadefa4e62d9fc866d0c015701',
103 'series': 'Cuarto Milenio',
104 'season': 'Temporada 6',
105 'episode': 'Programa 226',
106 'thumbnail': 're:(?i)^https?://.*\.jpg$',
110 'skip_download': True,
114 def _real_extract(self
, url
):
115 display_id
= self
._match
_id
(url
)
117 webpage
= self
._download
_webpage
(url
, display_id
)
119 info
= self
._get
_player
_info
(url
, webpage
)
121 title
= self
._search
_regex
(
122 r
'class="Destacado-text"[^>]*>\s*<strong>([^<]+)</strong>',
123 webpage
, 'title', default
=None)
125 mobj
= re
.search(r
'''(?sx)
126 class="Destacado-text"[^>]*>.*?<h1>\s*
127 <span>(?P<series>[^<]+)</span>\s*
128 <span>(?P<season>[^<]+)</span>\s*
129 <span>(?P<episode>[^<]+)</span>''', webpage
)
130 series
, season
, episode
= mobj
.groups() if mobj
else [None] * 3
134 title
= '%s - %s - %s' % (series
, season
, episode
)
136 title
= remove_start(self
._search
_regex
(
137 r
'<title>([^<]+)</title>', webpage
, 'title'), 'Ver online ')
140 'display_id': display_id
,
142 'description': get_element_by_attribute('class', 'text', webpage
),