You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
6.0 KiB

Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
  1. from __future__ import unicode_literals
  2. import time
  3. import hmac
  4. from .common import InfoExtractor
  5. from ..compat import (
  6. compat_str,
  7. compat_urllib_parse,
  8. )
  9. from ..utils import (
  10. int_or_none,
  11. float_or_none,
  12. sanitized_Request,
  13. xpath_text,
  14. ExtractorError,
  15. )
  16. class AtresPlayerIE(InfoExtractor):
  17. _VALID_URL = r'https?://(?:www\.)?atresplayer\.com/television/[^/]+/[^/]+/[^/]+/(?P<id>.+?)_\d+\.html'
  18. _NETRC_MACHINE = 'atresplayer'
  19. _TESTS = [
  20. {
  21. 'url': 'http://www.atresplayer.com/television/programas/el-club-de-la-comedia/temporada-4/capitulo-10-especial-solidario-nochebuena_2014122100174.html',
  22. 'md5': 'efd56753cda1bb64df52a3074f62e38a',
  23. 'info_dict': {
  24. 'id': 'capitulo-10-especial-solidario-nochebuena',
  25. 'ext': 'mp4',
  26. 'title': 'Especial Solidario de Nochebuena',
  27. 'description': 'md5:e2d52ff12214fa937107d21064075bf1',
  28. 'duration': 5527.6,
  29. 'thumbnail': 're:^https?://.*\.jpg$',
  30. },
  31. },
  32. {
  33. 'url': 'http://www.atresplayer.com/television/series/el-secreto-de-puente-viejo/el-chico-de-los-tres-lunares/capitulo-977-29-12-14_2014122400174.html',
  34. 'only_matching': True,
  35. },
  36. ]
  37. _USER_AGENT = 'Dalvik/1.6.0 (Linux; U; Android 4.3; GT-I9300 Build/JSS15J'
  38. _MAGIC = 'QWtMLXs414Yo+c#_+Q#K@NN)'
  39. _TIMESTAMP_SHIFT = 30000
  40. _TIME_API_URL = 'http://servicios.atresplayer.com/api/admin/time.json'
  41. _URL_VIDEO_TEMPLATE = 'https://servicios.atresplayer.com/api/urlVideo/{1}/{0}/{1}|{2}|{3}.json'
  42. _PLAYER_URL_TEMPLATE = 'https://servicios.atresplayer.com/episode/getplayer.json?episodePk=%s'
  43. _EPISODE_URL_TEMPLATE = 'http://www.atresplayer.com/episodexml/%s'
  44. _LOGIN_URL = 'https://servicios.atresplayer.com/j_spring_security_check'
  45. def _real_initialize(self):
  46. self._login()
  47. def _login(self):
  48. (username, password) = self._get_login_info()
  49. if username is None:
  50. return
  51. login_form = {
  52. 'j_username': username,
  53. 'j_password': password,
  54. }
  55. request = sanitized_Request(
  56. self._LOGIN_URL, compat_urllib_parse.urlencode(login_form).encode('utf-8'))
  57. request.add_header('Content-Type', 'application/x-www-form-urlencoded')
  58. response = self._download_webpage(
  59. request, None, 'Logging in as %s' % username)
  60. error = self._html_search_regex(
  61. r'(?s)<ul class="list_error">(.+?)</ul>', response, 'error', default=None)
  62. if error:
  63. raise ExtractorError(
  64. 'Unable to login: %s' % error, expected=True)
  65. def _real_extract(self, url):
  66. video_id = self._match_id(url)
  67. webpage = self._download_webpage(url, video_id)
  68. episode_id = self._search_regex(
  69. r'episode="([^"]+)"', webpage, 'episode id')
  70. timestamp = int_or_none(self._download_webpage(
  71. self._TIME_API_URL,
  72. video_id, 'Downloading timestamp', fatal=False), 1000, time.time())
  73. timestamp_shifted = compat_str(timestamp + self._TIMESTAMP_SHIFT)
  74. token = hmac.new(
  75. self._MAGIC.encode('ascii'),
  76. (episode_id + timestamp_shifted).encode('utf-8')
  77. ).hexdigest()
  78. formats = []
  79. for fmt in ['windows', 'android_tablet']:
  80. request = sanitized_Request(
  81. self._URL_VIDEO_TEMPLATE.format(fmt, episode_id, timestamp_shifted, token))
  82. request.add_header('User-Agent', self._USER_AGENT)
  83. fmt_json = self._download_json(
  84. request, video_id, 'Downloading %s video JSON' % fmt)
  85. result = fmt_json.get('resultDes')
  86. if result.lower() != 'ok':
  87. raise ExtractorError(
  88. '%s returned error: %s' % (self.IE_NAME, result), expected=True)
  89. for format_id, video_url in fmt_json['resultObject'].items():
  90. if format_id == 'token' or not video_url.startswith('http'):
  91. continue
  92. if video_url.endswith('/Manifest'):
  93. if 'geodeswowsmpra3player' in video_url:
  94. f4m_path = video_url.split('smil:', 1)[-1].split('free_', 1)[0]
  95. f4m_url = 'http://drg.antena3.com/{0}hds/es/sd.f4m'.format(f4m_path)
  96. # this videos are protected by DRM, the f4m downloader doesn't support them
  97. continue
  98. else:
  99. f4m_url = video_url[:-9] + '/manifest.f4m'
  100. formats.extend(self._extract_f4m_formats(f4m_url, video_id))
  101. else:
  102. formats.append({
  103. 'url': video_url,
  104. 'format_id': 'android-%s' % format_id,
  105. 'preference': 1,
  106. })
  107. self._sort_formats(formats)
  108. player = self._download_json(
  109. self._PLAYER_URL_TEMPLATE % episode_id,
  110. episode_id)
  111. path_data = player.get('pathData')
  112. episode = self._download_xml(
  113. self._EPISODE_URL_TEMPLATE % path_data,
  114. video_id, 'Downloading episode XML')
  115. duration = float_or_none(xpath_text(
  116. episode, './media/asset/info/technical/contentDuration', 'duration'))
  117. art = episode.find('./media/asset/info/art')
  118. title = xpath_text(art, './name', 'title')
  119. description = xpath_text(art, './description', 'description')
  120. thumbnail = xpath_text(episode, './media/asset/files/background', 'thumbnail')
  121. subtitles = {}
  122. subtitle_url = xpath_text(episode, './media/asset/files/subtitle', 'subtitle')
  123. if subtitle_url:
  124. subtitles['es'] = [{
  125. 'ext': 'srt',
  126. 'url': subtitle_url,
  127. }]
  128. return {
  129. 'id': video_id,
  130. 'title': title,
  131. 'description': description,
  132. 'thumbnail': thumbnail,
  133. 'duration': duration,
  134. 'formats': formats,
  135. 'subtitles': subtitles,
  136. }