]>
Commit | Line | Data |
---|---|---|
cfd7f2a6 | 1 | from .common import InfoExtractor |
cfd7f2a6 S |
2 | from ..utils import ( |
3 | determine_ext, | |
7c60c33e | 4 | int_or_none, |
3052a30d | 5 | url_or_none, |
cfd7f2a6 S |
6 | ) |
7 | ||
8 | ||
9 | class APAIE(InfoExtractor): | |
7c60c33e | 10 | _VALID_URL = r'(?P<base_url>https?://[^/]+\.apa\.at)/embed/(?P<id>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})' |
bfd973ec | 11 | _EMBED_REGEX = [r'<iframe[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//[^/]+\.apa\.at/embed/[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}.*?)\1'] |
cfd7f2a6 S |
12 | _TESTS = [{ |
13 | 'url': 'http://uvp.apa.at/embed/293f6d17-692a-44e3-9fd5-7b178f3a1029', | |
14 | 'md5': '2b12292faeb0a7d930c778c7a5b4759b', | |
15 | 'info_dict': { | |
7c60c33e | 16 | 'id': '293f6d17-692a-44e3-9fd5-7b178f3a1029', |
cfd7f2a6 | 17 | 'ext': 'mp4', |
7c60c33e | 18 | 'title': '293f6d17-692a-44e3-9fd5-7b178f3a1029', |
cfd7f2a6 | 19 | 'thumbnail': r're:^https?://.*\.jpg$', |
cfd7f2a6 S |
20 | }, |
21 | }, { | |
22 | 'url': 'https://uvp-apapublisher.sf.apa.at/embed/2f94e9e6-d945-4db2-9548-f9a41ebf7b78', | |
23 | 'only_matching': True, | |
24 | }, { | |
25 | 'url': 'http://uvp-rma.sf.apa.at/embed/70404cca-2f47-4855-bbb8-20b1fae58f76', | |
26 | 'only_matching': True, | |
27 | }, { | |
28 | 'url': 'http://uvp-kleinezeitung.sf.apa.at/embed/f1c44979-dba2-4ebf-b021-e4cf2cac3c81', | |
29 | 'only_matching': True, | |
30 | }] | |
31 | ||
cfd7f2a6 | 32 | def _real_extract(self, url): |
5ad28e7f | 33 | mobj = self._match_valid_url(url) |
7c60c33e | 34 | video_id, base_url = mobj.group('id', 'base_url') |
cfd7f2a6 | 35 | |
7c60c33e | 36 | webpage = self._download_webpage( |
37 | '%s/player/%s' % (base_url, video_id), video_id) | |
cfd7f2a6 S |
38 | |
39 | jwplatform_id = self._search_regex( | |
40 | r'media[iI]d\s*:\s*["\'](?P<id>[a-zA-Z0-9]{8})', webpage, | |
41 | 'jwplatform id', default=None) | |
42 | ||
43 | if jwplatform_id: | |
44 | return self.url_result( | |
45 | 'jwplatform:' + jwplatform_id, ie='JWPlatform', | |
46 | video_id=video_id) | |
47 | ||
7c60c33e | 48 | def extract(field, name=None): |
49 | return self._search_regex( | |
50 | r'\b%s["\']\s*:\s*(["\'])(?P<value>(?:(?!\1).)+)\1' % field, | |
51 | webpage, name or field, default=None, group='value') | |
52 | ||
53 | title = extract('title') or video_id | |
54 | description = extract('description') | |
55 | thumbnail = extract('poster', 'thumbnail') | |
cfd7f2a6 S |
56 | |
57 | formats = [] | |
7c60c33e | 58 | for format_id in ('hls', 'progressive'): |
59 | source_url = url_or_none(extract(format_id)) | |
3052a30d | 60 | if not source_url: |
cfd7f2a6 S |
61 | continue |
62 | ext = determine_ext(source_url) | |
63 | if ext == 'm3u8': | |
64 | formats.extend(self._extract_m3u8_formats( | |
65 | source_url, video_id, 'mp4', entry_protocol='m3u8_native', | |
66 | m3u8_id='hls', fatal=False)) | |
67 | else: | |
7c60c33e | 68 | height = int_or_none(self._search_regex( |
69 | r'(\d+)\.mp4', source_url, 'height', default=None)) | |
cfd7f2a6 S |
70 | formats.append({ |
71 | 'url': source_url, | |
7c60c33e | 72 | 'format_id': format_id, |
73 | 'height': height, | |
cfd7f2a6 | 74 | }) |
cfd7f2a6 | 75 | |
cfd7f2a6 S |
76 | return { |
77 | 'id': video_id, | |
7c60c33e | 78 | 'title': title, |
79 | 'description': description, | |
cfd7f2a6 S |
80 | 'thumbnail': thumbnail, |
81 | 'formats': formats, | |
82 | } |