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