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.

285 lines
11 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from hashlib import sha1
  5. from .common import InfoExtractor
  6. from ..utils import (
  7. compat_urllib_parse,
  8. unified_strdate,
  9. )
  10. class ProSiebenSat1IE(InfoExtractor):
  11. IE_NAME = 'prosiebensat1'
  12. IE_DESC = 'ProSiebenSat.1 Digital'
  13. _VALID_URL = r'https?://(?:www\.)?(?:(?:prosieben|prosiebenmaxx|sixx|sat1|kabeleins|ran|the-voice-of-germany)\.de|fem\.com)/(?P<id>.+)'
  14. _TESTS = [
  15. {
  16. 'url': 'http://www.prosieben.de/tv/circus-halligalli/videos/218-staffel-2-episode-18-jahresrueckblick-ganze-folge',
  17. 'info_dict': {
  18. 'id': '2104602',
  19. 'ext': 'mp4',
  20. 'title': 'Staffel 2, Episode 18 - Jahresrückblick',
  21. 'description': 'md5:8733c81b702ea472e069bc48bb658fc1',
  22. 'upload_date': '20131231',
  23. 'duration': 5845.04,
  24. },
  25. 'params': {
  26. # rtmp download
  27. 'skip_download': True,
  28. },
  29. },
  30. {
  31. 'url': 'http://www.prosieben.de/videokatalog/Gesellschaft/Leben/Trends/video-Lady-Umstyling-f%C3%BCr-Audrina-Rebekka-Audrina-Fergen-billig-aussehen-Battal-Modica-700544.html',
  32. 'info_dict': {
  33. 'id': '2570327',
  34. 'ext': 'mp4',
  35. 'title': 'Lady-Umstyling für Audrina',
  36. 'description': 'md5:4c16d0c17a3461a0d43ea4084e96319d',
  37. 'upload_date': '20131014',
  38. 'duration': 606.76,
  39. },
  40. 'params': {
  41. # rtmp download
  42. 'skip_download': True,
  43. },
  44. 'skip': 'Seems to be broken',
  45. },
  46. {
  47. 'url': 'http://www.prosiebenmaxx.de/tv/experience/video/144-countdown-fuer-die-autowerkstatt-ganze-folge',
  48. 'info_dict': {
  49. 'id': '2429369',
  50. 'ext': 'mp4',
  51. 'title': 'Countdown für die Autowerkstatt',
  52. 'description': 'md5:809fc051a457b5d8666013bc40698817',
  53. 'upload_date': '20140223',
  54. 'duration': 2595.04,
  55. },
  56. 'params': {
  57. # rtmp download
  58. 'skip_download': True,
  59. },
  60. },
  61. {
  62. 'url': 'http://www.sixx.de/stars-style/video/sexy-laufen-in-ugg-boots-clip',
  63. 'info_dict': {
  64. 'id': '2904997',
  65. 'ext': 'mp4',
  66. 'title': 'Sexy laufen in Ugg Boots',
  67. 'description': 'md5:edf42b8bd5bc4e5da4db4222c5acb7d6',
  68. 'upload_date': '20140122',
  69. 'duration': 245.32,
  70. },
  71. 'params': {
  72. # rtmp download
  73. 'skip_download': True,
  74. },
  75. },
  76. {
  77. 'url': 'http://www.sat1.de/film/der-ruecktritt/video/im-interview-kai-wiesinger-clip',
  78. 'info_dict': {
  79. 'id': '2906572',
  80. 'ext': 'mp4',
  81. 'title': 'Im Interview: Kai Wiesinger',
  82. 'description': 'md5:e4e5370652ec63b95023e914190b4eb9',
  83. 'upload_date': '20140225',
  84. 'duration': 522.56,
  85. },
  86. 'params': {
  87. # rtmp download
  88. 'skip_download': True,
  89. },
  90. },
  91. {
  92. 'url': 'http://www.kabeleins.de/tv/rosins-restaurants/videos/jagd-auf-fertigkost-im-elsthal-teil-2-ganze-folge',
  93. 'info_dict': {
  94. 'id': '2992323',
  95. 'ext': 'mp4',
  96. 'title': 'Jagd auf Fertigkost im Elsthal - Teil 2',
  97. 'description': 'md5:2669cde3febe9bce13904f701e774eb6',
  98. 'upload_date': '20140225',
  99. 'duration': 2410.44,
  100. },
  101. 'params': {
  102. # rtmp download
  103. 'skip_download': True,
  104. },
  105. },
  106. {
  107. 'url': 'http://www.ran.de/fussball/bundesliga/video/schalke-toennies-moechte-raul-zurueck-ganze-folge',
  108. 'info_dict': {
  109. 'id': '3004256',
  110. 'ext': 'mp4',
  111. 'title': 'Schalke: Tönnies möchte Raul zurück',
  112. 'description': 'md5:4b5b271d9bcde223b54390754c8ece3f',
  113. 'upload_date': '20140226',
  114. 'duration': 228.96,
  115. },
  116. 'params': {
  117. # rtmp download
  118. 'skip_download': True,
  119. },
  120. },
  121. {
  122. 'url': 'http://www.the-voice-of-germany.de/video/31-andreas-kuemmert-rocket-man-clip',
  123. 'info_dict': {
  124. 'id': '2572814',
  125. 'ext': 'mp4',
  126. 'title': 'Andreas Kümmert: Rocket Man',
  127. 'description': 'md5:6ddb02b0781c6adf778afea606652e38',
  128. 'upload_date': '20131017',
  129. 'duration': 469.88,
  130. },
  131. 'params': {
  132. # rtmp download
  133. 'skip_download': True,
  134. },
  135. },
  136. {
  137. 'url': 'http://www.fem.com/wellness/videos/wellness-video-clip-kurztripps-zum-valentinstag.html',
  138. 'info_dict': {
  139. 'id': '2156342',
  140. 'ext': 'mp4',
  141. 'title': 'Kurztrips zum Valentinstag',
  142. 'description': 'md5:8ba6301e70351ae0bedf8da00f7ba528',
  143. 'upload_date': '20130206',
  144. 'duration': 307.24,
  145. },
  146. 'params': {
  147. # rtmp download
  148. 'skip_download': True,
  149. },
  150. },
  151. ]
  152. _CLIPID_REGEXES = [
  153. r'"clip_id"\s*:\s+"(\d+)"',
  154. r'clipid: "(\d+)"',
  155. r'clip[iI]d=(\d+)',
  156. ]
  157. _TITLE_REGEXES = [
  158. r'<h2 class="subtitle" itemprop="name">\s*(.+?)</h2>',
  159. r'<header class="clearfix">\s*<h3>(.+?)</h3>',
  160. r'<!-- start video -->\s*<h1>(.+?)</h1>',
  161. r'<h1 class="att-name">\s*(.+?)</h1>',
  162. ]
  163. _DESCRIPTION_REGEXES = [
  164. r'<p itemprop="description">\s*(.+?)</p>',
  165. r'<div class="videoDecription">\s*<p><strong>Beschreibung</strong>: (.+?)</p>',
  166. r'<div class="g-plusone" data-size="medium"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>',
  167. r'<p class="att-description">\s*(.+?)\s*</p>',
  168. ]
  169. _UPLOAD_DATE_REGEXES = [
  170. r'<meta property="og:published_time" content="(.+?)">',
  171. r'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration"',
  172. r'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr',
  173. r'<span style="padding-left: 4px;line-height:20px; color:#404040">(\d{2}\.\d{2}\.\d{4})</span>',
  174. r'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>',
  175. ]
  176. def _real_extract(self, url):
  177. mobj = re.match(self._VALID_URL, url)
  178. video_id = mobj.group('id')
  179. page = self._download_webpage(url, video_id, 'Downloading page')
  180. clip_id = self._html_search_regex(self._CLIPID_REGEXES, page, 'clip id')
  181. access_token = 'testclient'
  182. client_name = 'kolibri-1.2.5'
  183. client_location = url
  184. videos_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos?%s' % compat_urllib_parse.urlencode({
  185. 'access_token': access_token,
  186. 'client_location': client_location,
  187. 'client_name': client_name,
  188. 'ids': clip_id,
  189. })
  190. videos = self._download_json(videos_api_url, clip_id, 'Downloading videos JSON')
  191. duration = float(videos[0]['duration'])
  192. source_ids = [source['id'] for source in videos[0]['sources']]
  193. source_ids_str = ','.join(map(str, source_ids))
  194. g = '01!8d8F_)r9]4s[qeuXfP%'
  195. client_id = g[:2] + sha1(''.join([clip_id, g, access_token, client_location, g, client_name])
  196. .encode('utf-8')).hexdigest()
  197. sources_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources?%s' % (clip_id, compat_urllib_parse.urlencode({
  198. 'access_token': access_token,
  199. 'client_id': client_id,
  200. 'client_location': client_location,
  201. 'client_name': client_name,
  202. }))
  203. sources = self._download_json(sources_api_url, clip_id, 'Downloading sources JSON')
  204. server_id = sources['server_id']
  205. client_id = g[:2] + sha1(''.join([g, clip_id, access_token, server_id,
  206. client_location, source_ids_str, g, client_name])
  207. .encode('utf-8')).hexdigest()
  208. url_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources/url?%s' % (clip_id, compat_urllib_parse.urlencode({
  209. 'access_token': access_token,
  210. 'client_id': client_id,
  211. 'client_location': client_location,
  212. 'client_name': client_name,
  213. 'server_id': server_id,
  214. 'source_ids': source_ids_str,
  215. }))
  216. urls = self._download_json(url_api_url, clip_id, 'Downloading urls JSON')
  217. title = self._html_search_regex(self._TITLE_REGEXES, page, 'title')
  218. description = self._html_search_regex(self._DESCRIPTION_REGEXES, page, 'description', fatal=False)
  219. thumbnail = self._og_search_thumbnail(page)
  220. upload_date = unified_strdate(self._html_search_regex(
  221. self._UPLOAD_DATE_REGEXES, page, 'upload date', fatal=False))
  222. formats = []
  223. urls_sources = urls['sources']
  224. if isinstance(urls_sources, dict):
  225. urls_sources = urls_sources.values()
  226. def fix_bitrate(bitrate):
  227. return bitrate / 1000 if bitrate % 1000 == 0 else bitrate
  228. for source in urls_sources:
  229. protocol = source['protocol']
  230. if protocol == 'rtmp' or protocol == 'rtmpe':
  231. mobj = re.search(r'^(?P<url>rtmpe?://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', source['url'])
  232. if not mobj:
  233. continue
  234. formats.append({
  235. 'url': mobj.group('url'),
  236. 'app': mobj.group('app'),
  237. 'play_path': mobj.group('playpath'),
  238. 'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf',
  239. 'page_url': 'http://www.prosieben.de',
  240. 'vbr': fix_bitrate(source['bitrate']),
  241. 'ext': 'mp4',
  242. 'format_id': '%s_%s' % (source['cdn'], source['bitrate']),
  243. })
  244. else:
  245. formats.append({
  246. 'url': source['url'],
  247. 'vbr': fix_bitrate(source['bitrate']),
  248. })
  249. self._sort_formats(formats)
  250. return {
  251. 'id': clip_id,
  252. 'title': title,
  253. 'description': description,
  254. 'thumbnail': thumbnail,
  255. 'upload_date': upload_date,
  256. 'duration': duration,
  257. 'formats': formats,
  258. }