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.

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