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.

296 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/yep/one-piece/video/148-folge-48-gold-rogers-heimat-ganze-folge',
  50. 'info_dict': {
  51. 'id': '2437108',
  52. 'ext': 'mp4',
  53. 'title': 'Folge 48: Gold Rogers Heimat',
  54. 'description': 'Ruffy erreicht die Insel, auf der der berühmte Gold Roger lebte und hingerichtet wurde.',
  55. 'upload_date': '20140226',
  56. 'duration': 1401.48,
  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. ]
  158. _TITLE_REGEXES = [
  159. r'<h2 class="subtitle" itemprop="name">\s*(.+?)</h2>',
  160. r'<header class="clearfix">\s*<h3>(.+?)</h3>',
  161. r'<!-- start video -->\s*<h1>(.+?)</h1>',
  162. r'<div class="ep-femvideos-pi4-video-txt">\s*<h2>(.+?)</h2>',
  163. ]
  164. _DESCRIPTION_REGEXES = [
  165. r'<p itemprop="description">\s*(.+?)</p>',
  166. r'<div class="videoDecription">\s*<p><strong>Beschreibung</strong>: (.+?)</p>',
  167. r'<div class="g-plusone" data-size="medium"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>',
  168. r'<p>(.+?)</p>\s*<div class="ep-femvideos-pi4-video-footer">',
  169. ]
  170. _UPLOAD_DATE_REGEXES = [
  171. r'<meta property="og:published_time" content="(.+?)">',
  172. r'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration"',
  173. r'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr',
  174. r'<span style="padding-left: 4px;line-height:20px; color:#404040">(\d{2}\.\d{2}\.\d{4})</span>',
  175. r'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>',
  176. ]
  177. def _real_extract(self, url):
  178. mobj = re.match(self._VALID_URL, url)
  179. video_id = mobj.group('id')
  180. page = self._download_webpage(url, video_id, 'Downloading page')
  181. def extract(patterns, name, page, fatal=False):
  182. for pattern in patterns:
  183. mobj = re.search(pattern, page)
  184. if mobj:
  185. return clean_html(mobj.group(1))
  186. if fatal:
  187. raise RegexNotFoundError(u'Unable to extract %s' % name)
  188. return None
  189. clip_id = extract(self._CLIPID_REGEXES, 'clip id', page, fatal=True)
  190. access_token = 'testclient'
  191. client_name = 'kolibri-1.2.5'
  192. client_location = url
  193. videos_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos?%s' % compat_urllib_parse.urlencode({
  194. 'access_token': access_token,
  195. 'client_location': client_location,
  196. 'client_name': client_name,
  197. 'ids': clip_id,
  198. })
  199. videos = self._download_json(videos_api_url, clip_id, 'Downloading videos JSON')
  200. duration = float(videos[0]['duration'])
  201. source_ids = [source['id'] for source in videos[0]['sources']]
  202. source_ids_str = ','.join(map(str, source_ids))
  203. g = '01!8d8F_)r9]4s[qeuXfP%'
  204. client_id = g[:2] + sha1(''.join([clip_id, g, access_token, client_location, g, client_name])
  205. .encode('utf-8')).hexdigest()
  206. sources_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources?%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. }))
  212. sources = self._download_json(sources_api_url, clip_id, 'Downloading sources JSON')
  213. server_id = sources['server_id']
  214. client_id = g[:2] + sha1(''.join([g, clip_id, access_token, server_id,
  215. client_location, source_ids_str, g, client_name])
  216. .encode('utf-8')).hexdigest()
  217. url_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources/url?%s' % (clip_id, compat_urllib_parse.urlencode({
  218. 'access_token': access_token,
  219. 'client_id': client_id,
  220. 'client_location': client_location,
  221. 'client_name': client_name,
  222. 'server_id': server_id,
  223. 'source_ids': source_ids_str,
  224. }))
  225. urls = self._download_json(url_api_url, clip_id, 'Downloading urls JSON')
  226. title = extract(self._TITLE_REGEXES, 'title', page, fatal=True)
  227. description = extract(self._DESCRIPTION_REGEXES, 'description', page)
  228. thumbnail = self._og_search_thumbnail(page)
  229. upload_date = extract(self._UPLOAD_DATE_REGEXES, 'upload date', page)
  230. if upload_date:
  231. upload_date = unified_strdate(upload_date)
  232. formats = []
  233. urls_sources = urls['sources']
  234. if isinstance(urls_sources, dict):
  235. urls_sources = urls_sources.values()
  236. def fix_bitrate(bitrate):
  237. return bitrate / 1000 if bitrate % 1000 == 0 else bitrate
  238. for source in urls_sources:
  239. protocol = source['protocol']
  240. if protocol == 'rtmp' or protocol == 'rtmpe':
  241. mobj = re.search(r'^(?P<url>rtmpe?://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', source['url'])
  242. if not mobj:
  243. continue
  244. formats.append({
  245. 'url': mobj.group('url'),
  246. 'app': mobj.group('app'),
  247. 'play_path': mobj.group('playpath'),
  248. 'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf',
  249. 'page_url': 'http://www.prosieben.de',
  250. 'vbr': fix_bitrate(source['bitrate']),
  251. 'ext': 'mp4',
  252. 'format_id': '%s_%s' % (source['cdn'], source['bitrate']),
  253. })
  254. else:
  255. formats.append({
  256. 'url': source['url'],
  257. 'vbr': fix_bitrate(source['bitrate']),
  258. })
  259. self._sort_formats(formats)
  260. return {
  261. 'id': clip_id,
  262. 'title': title,
  263. 'description': description,
  264. 'thumbnail': thumbnail,
  265. 'upload_date': upload_date,
  266. 'duration': duration,
  267. 'formats': formats,
  268. }