]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/servus.py
[ChangeLog] Actualize
[youtube-dl.git] / 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'''(?x)
11                     https?://
12                         (?:www\.)?
13                         (?:
14                             servus\.com/(?:(?:at|de)/p/[^/]+|tv/videos)|
15                             servustv\.com/videos
16                         )
17                         /(?P<id>[aA]{2}-\w+|\d+-\d+)
18                     '''
19     _TESTS = [{
20         # new URL schema
21         'url': 'https://www.servustv.com/videos/aa-1t6vbu5pw1w12/',
22         'md5': '3e1dd16775aa8d5cbef23628cfffc1f4',
23         'info_dict': {
24             'id': 'AA-1T6VBU5PW1W12',
25             'ext': 'mp4',
26             'title': 'Die GrĂ¼nen aus Sicht des Volkes',
27             'description': 'md5:1247204d85783afe3682644398ff2ec4',
28             'thumbnail': r're:^https?://.*\.jpg',
29         }
30     }, {
31         # old URL schema
32         'url': 'https://www.servus.com/de/p/Die-Gr%C3%BCnen-aus-Sicht-des-Volkes/AA-1T6VBU5PW1W12/',
33         'only_matching': True,
34     }, {
35         'url': 'https://www.servus.com/at/p/Wie-das-Leben-beginnt/1309984137314-381415152/',
36         'only_matching': True,
37     }, {
38         'url': 'https://www.servus.com/tv/videos/aa-1t6vbu5pw1w12/',
39         'only_matching': True,
40     }, {
41         'url': 'https://www.servus.com/tv/videos/1380889096408-1235196658/',
42         'only_matching': True,
43     }]
44
45     def _real_extract(self, url):
46         video_id = self._match_id(url).upper()
47         webpage = self._download_webpage(url, video_id)
48
49         title = self._search_regex(
50             (r'videoLabel\s*=\s*(["\'])(?P<title>(?:(?!\1).)+)\1',
51              r'<h\d+[^>]+\bclass=["\']heading--(?:one|two)["\'][^>]*>(?P<title>[^<]+)'),
52             webpage, 'title', default=None,
53             group='title') or self._og_search_title(webpage)
54         title = re.sub(r'\s*-\s*Servus TV\s*$', '', title)
55         description = self._og_search_description(webpage)
56         thumbnail = self._og_search_thumbnail(webpage)
57
58         formats = self._extract_m3u8_formats(
59             'https://stv.rbmbtnx.net/api/v1/manifests/%s.m3u8' % video_id,
60             video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls')
61         self._sort_formats(formats)
62
63         return {
64             'id': video_id,
65             'title': title,
66             'description': description,
67             'thumbnail': thumbnail,
68             'formats': formats,
69         }