puls4.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. import re
  5. class Puls4IE(InfoExtractor):
  6. _VALID_URL = r'https?://www.puls4.com/video/.+?/play/(?P<id>[0-9]+)'
  7. _TESTS = [{
  8. 'url': 'http://www.puls4.com/video/pro-und-contra/play/2716816',
  9. 'md5': '49f6a6629747eeec43cef6a46b5df81d',
  10. 'info_dict': {
  11. 'id': '2716816',
  12. 'ext': 'mp4',
  13. 'title': 'Pro und Contra vom 23.02.2015'}},
  14. {
  15. 'url': 'http://www.puls4.com/video/kult-spielfilme/play/1298106',
  16. 'md5': '6a48316c8903ece8dab9b9a7bf7a59ec',
  17. 'info_dict': {
  18. 'id': '1298106',
  19. 'ext': 'mp4',
  20. 'title': 'Lucky Fritz'}}
  21. ]
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id)
  25. # if fsk-button
  26. real_url = self._html_search_regex(r'\"fsk-button\".+?href=\"([^"]+)',
  27. webpage, 'fsk_button', default=None)
  28. if real_url:
  29. webpage = self._download_webpage(real_url, video_id)
  30. title = self._html_search_regex(
  31. r'<div id="bg_brandableContent">.+?<h1>(.+?)</h1>',
  32. webpage, 'title', flags=re.DOTALL)
  33. sd_url = self._html_search_regex(
  34. r'{\"url\":\"([^"]+?)\",\"hd\":false',
  35. webpage, 'sd_url').replace('\\', '')
  36. formats = [{'format_id': 'sd', 'url': sd_url, 'quality': -2}]
  37. hd_url = self._html_search_regex(
  38. r'{\"url\":\"([^"]+?)\",\"hd\":true',
  39. webpage, 'hd_url', default=None)
  40. if hd_url:
  41. hd_url = hd_url.replace('\\', '')
  42. formats.append({'format_id': 'hd', 'url': hd_url, 'quality': -1})
  43. return {
  44. 'id': video_id,
  45. 'title': title,
  46. 'formats': formats,
  47. 'ext': 'mp4'
  48. }