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.

282 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': 'Romantischer Kurztrip zum Valentinstag? Wir verraten, was sich hier wirklich lohnt.',
  143. 'duration': 307.24,
  144. },
  145. 'params': {
  146. # rtmp download
  147. 'skip_download': True,
  148. },
  149. },
  150. ]
  151. _CLIPID_REGEXES = [
  152. r'"clip_id"\s*:\s+"(\d+)"',
  153. r'clipid: "(\d+)"',
  154. r'clip[iI]d=(\d+)',
  155. ]
  156. _TITLE_REGEXES = [
  157. r'<h2 class="subtitle" itemprop="name">\s*(.+?)</h2>',
  158. r'<header class="clearfix">\s*<h3>(.+?)</h3>',
  159. r'<!-- start video -->\s*<h1>(.+?)</h1>',
  160. r'<h1 class="att-name">\s*(.+?)</h1>',
  161. ]
  162. _DESCRIPTION_REGEXES = [
  163. r'<p itemprop="description">\s*(.+?)</p>',
  164. r'<div class="videoDecription">\s*<p><strong>Beschreibung</strong>: (.+?)</p>',
  165. r'<div class="g-plusone" data-size="medium"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>',
  166. r'<p class="att-description">\s*(.+?)\s*</p>',
  167. ]
  168. _UPLOAD_DATE_REGEXES = [
  169. r'<meta property="og:published_time" content="(.+?)">',
  170. r'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration"',
  171. r'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr',
  172. r'<span style="padding-left: 4px;line-height:20px; color:#404040">(\d{2}\.\d{2}\.\d{4})</span>',
  173. r'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>',
  174. ]
  175. def _real_extract(self, url):
  176. video_id = self._match_id(url)
  177. webpage = self._download_webpage(url, video_id)
  178. clip_id = self._html_search_regex(self._CLIPID_REGEXES, webpage, 'clip id')
  179. access_token = 'testclient'
  180. client_name = 'kolibri-1.2.5'
  181. client_location = url
  182. videos_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos?%s' % compat_urllib_parse.urlencode({
  183. 'access_token': access_token,
  184. 'client_location': client_location,
  185. 'client_name': client_name,
  186. 'ids': clip_id,
  187. })
  188. videos = self._download_json(videos_api_url, clip_id, 'Downloading videos JSON')
  189. duration = float(videos[0]['duration'])
  190. source_ids = [source['id'] for source in videos[0]['sources']]
  191. source_ids_str = ','.join(map(str, source_ids))
  192. g = '01!8d8F_)r9]4s[qeuXfP%'
  193. client_id = g[:2] + sha1(''.join([clip_id, g, access_token, client_location, g, client_name])
  194. .encode('utf-8')).hexdigest()
  195. sources_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources?%s' % (clip_id, compat_urllib_parse.urlencode({
  196. 'access_token': access_token,
  197. 'client_id': client_id,
  198. 'client_location': client_location,
  199. 'client_name': client_name,
  200. }))
  201. sources = self._download_json(sources_api_url, clip_id, 'Downloading sources JSON')
  202. server_id = sources['server_id']
  203. client_id = g[:2] + sha1(''.join([g, clip_id, access_token, server_id,
  204. client_location, source_ids_str, g, client_name])
  205. .encode('utf-8')).hexdigest()
  206. url_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources/url?%s' % (clip_id, compat_urllib_parse.urlencode({
  207. 'access_token': access_token,
  208. 'client_id': client_id,
  209. 'client_location': client_location,
  210. 'client_name': client_name,
  211. 'server_id': server_id,
  212. 'source_ids': source_ids_str,
  213. }))
  214. urls = self._download_json(url_api_url, clip_id, 'Downloading urls JSON')
  215. title = self._html_search_regex(self._TITLE_REGEXES, webpage, 'title')
  216. description = self._html_search_regex(self._DESCRIPTION_REGEXES, webpage, 'description', fatal=False)
  217. thumbnail = self._og_search_thumbnail(webpage)
  218. upload_date = unified_strdate(self._html_search_regex(
  219. self._UPLOAD_DATE_REGEXES, webpage, 'upload date', default=None))
  220. formats = []
  221. urls_sources = urls['sources']
  222. if isinstance(urls_sources, dict):
  223. urls_sources = urls_sources.values()
  224. def fix_bitrate(bitrate):
  225. return (bitrate // 1000) if bitrate % 1000 == 0 else bitrate
  226. for source in urls_sources:
  227. protocol = source['protocol']
  228. if protocol == 'rtmp' or protocol == 'rtmpe':
  229. mobj = re.search(r'^(?P<url>rtmpe?://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', source['url'])
  230. if not mobj:
  231. continue
  232. formats.append({
  233. 'url': mobj.group('url'),
  234. 'app': mobj.group('app'),
  235. 'play_path': mobj.group('playpath'),
  236. 'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf',
  237. 'page_url': 'http://www.prosieben.de',
  238. 'vbr': fix_bitrate(source['bitrate']),
  239. 'ext': 'mp4',
  240. 'format_id': '%s_%s' % (source['cdn'], source['bitrate']),
  241. })
  242. else:
  243. formats.append({
  244. 'url': source['url'],
  245. 'vbr': fix_bitrate(source['bitrate']),
  246. })
  247. self._sort_formats(formats)
  248. return {
  249. 'id': clip_id,
  250. 'title': title,
  251. 'description': description,
  252. 'thumbnail': thumbnail,
  253. 'upload_date': upload_date,
  254. 'duration': duration,
  255. 'formats': formats,
  256. }