]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/servus.py
Import Upstream version 2020.01.24
[youtubedl] / youtube_dl / extractor / servus.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7
8
9 class ServusIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?servus\.com/(?:(?:at|de)/p/[^/]+|tv/videos)/(?P<id>[aA]{2}-\w+|\d+-\d+)'
11 _TESTS = [{
12 'url': 'https://www.servus.com/de/p/Die-Gr%C3%BCnen-aus-Sicht-des-Volkes/AA-1T6VBU5PW1W12/',
13 'md5': '3e1dd16775aa8d5cbef23628cfffc1f4',
14 'info_dict': {
15 'id': 'AA-1T6VBU5PW1W12',
16 'ext': 'mp4',
17 'title': 'Die Grünen aus Sicht des Volkes',
18 'description': 'md5:1247204d85783afe3682644398ff2ec4',
19 'thumbnail': r're:^https?://.*\.jpg',
20 }
21 }, {
22 'url': 'https://www.servus.com/at/p/Wie-das-Leben-beginnt/1309984137314-381415152/',
23 'only_matching': True,
24 }, {
25 'url': 'https://www.servus.com/tv/videos/aa-1t6vbu5pw1w12/',
26 'only_matching': True,
27 }, {
28 'url': 'https://www.servus.com/tv/videos/1380889096408-1235196658/',
29 'only_matching': True,
30 }]
31
32 def _real_extract(self, url):
33 video_id = self._match_id(url).upper()
34 webpage = self._download_webpage(url, video_id)
35
36 title = self._search_regex(
37 (r'videoLabel\s*=\s*(["\'])(?P<title>(?:(?!\1).)+)\1',
38 r'<h\d+[^>]+\bclass=["\']heading--(?:one|two)["\'][^>]*>(?P<title>[^<]+)'),
39 webpage, 'title', default=None,
40 group='title') or self._og_search_title(webpage)
41 title = re.sub(r'\s*-\s*Servus TV\s*$', '', title)
42 description = self._og_search_description(webpage)
43 thumbnail = self._og_search_thumbnail(webpage)
44
45 formats = self._extract_m3u8_formats(
46 'https://stv.rbmbtnx.net/api/v1/manifests/%s.m3u8' % video_id,
47 video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls')
48 self._sort_formats(formats)
49
50 return {
51 'id': video_id,
52 'title': title,
53 'description': description,
54 'thumbnail': thumbnail,
55 'formats': formats,
56 }