netzkino.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. clean_html,
  4. int_or_none,
  5. js_to_json,
  6. parse_iso8601,
  7. )
  8. class NetzkinoIE(InfoExtractor):
  9. _WORKING = False
  10. _VALID_URL = r'https?://(?:www\.)?netzkino\.de/\#!/[^/]+/(?P<id>[^/]+)'
  11. _TESTS = [{
  12. 'url': 'https://www.netzkino.de/#!/scifikino/rakete-zum-mond',
  13. 'md5': '92a3f8b76f8d7220acce5377ea5d4873',
  14. 'info_dict': {
  15. 'id': 'rakete-zum-mond',
  16. 'ext': 'mp4',
  17. 'title': 'Rakete zum Mond \u2013 Jules Verne',
  18. 'description': 'md5:f0a8024479618ddbfa450ff48ffa6c60',
  19. 'upload_date': '20120813',
  20. 'thumbnail': r're:https?://.*\.jpg$',
  21. 'timestamp': 1344858571,
  22. 'age_limit': 12,
  23. },
  24. 'params': {
  25. 'skip_download': 'Download only works from Germany',
  26. },
  27. }, {
  28. 'url': 'https://www.netzkino.de/#!/filme/dr-jekyll-mrs-hyde-2',
  29. 'md5': 'c7728b2dadd04ff6727814847a51ef03',
  30. 'info_dict': {
  31. 'id': 'dr-jekyll-mrs-hyde-2',
  32. 'ext': 'mp4',
  33. 'title': 'Dr. Jekyll & Mrs. Hyde 2',
  34. 'description': 'md5:c2e9626ebd02de0a794b95407045d186',
  35. 'upload_date': '20190130',
  36. 'thumbnail': r're:https?://.*\.jpg$',
  37. 'timestamp': 1548849437,
  38. 'age_limit': 18,
  39. },
  40. 'params': {
  41. 'skip_download': 'Download only works from Germany',
  42. },
  43. }]
  44. def _real_extract(self, url):
  45. mobj = self._match_valid_url(url)
  46. video_id = mobj.group('id')
  47. api_url = f'https://api.netzkino.de.simplecache.net/capi-2.0a/movies/{video_id}.json?d=www'
  48. info = self._download_json(api_url, video_id)
  49. custom_fields = info['custom_fields']
  50. production_js = self._download_webpage(
  51. 'http://www.netzkino.de/beta/dist/production.min.js', video_id,
  52. note='Downloading player code')
  53. avo_js = self._search_regex(
  54. r'var urlTemplate=(\{.*?"\})',
  55. production_js, 'URL templates')
  56. templates = self._parse_json(
  57. avo_js, video_id, transform_source=js_to_json)
  58. suffix = {
  59. 'hds': '.mp4/manifest.f4m',
  60. 'hls': '.mp4/master.m3u8',
  61. 'pmd': '.mp4',
  62. }
  63. film_fn = custom_fields['Streaming'][0]
  64. formats = [{
  65. 'format_id': key,
  66. 'ext': 'mp4',
  67. 'url': tpl.replace('{}', film_fn) + suffix[key],
  68. } for key, tpl in templates.items()]
  69. return {
  70. 'id': video_id,
  71. 'formats': formats,
  72. 'title': info['title'],
  73. 'age_limit': int_or_none(custom_fields.get('FSK')[0]),
  74. 'timestamp': parse_iso8601(info.get('date'), delimiter=' '),
  75. 'description': clean_html(info.get('content')),
  76. 'thumbnail': info.get('thumbnail'),
  77. }