]>
Commit | Line | Data |
---|---|---|
0de13634 T |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
ca04de46 S |
4 | import re |
5 | ||
56f9c77f S |
6 | from .common import InfoExtractor |
7 | from ..compat import compat_str | |
0de13634 T |
8 | from ..utils import ( |
9 | determine_ext, | |
10 | parse_duration, | |
56f9c77f S |
11 | try_get, |
12 | unified_strdate, | |
0de13634 T |
13 | ) |
14 | ||
15 | ||
16 | class MediasetIE(InfoExtractor): | |
56f9c77f | 17 | _VALID_URL = r'''(?x) |
ca04de46 S |
18 | (?: |
19 | mediaset:| | |
20 | https?:// | |
21 | (?:www\.)?video\.mediaset\.it/ | |
22 | (?: | |
23 | (?:video|on-demand)/(?:[^/]+/)+[^/]+_| | |
24 | player/playerIFrame(?:Twitter)?\.shtml\?.*?\bid= | |
25 | ) | |
26 | )(?P<id>[0-9]+) | |
56f9c77f | 27 | ''' |
0de13634 T |
28 | _TESTS = [{ |
29 | # full episode | |
30 | 'url': 'http://www.video.mediaset.it/video/hello_goodbye/full/quarta-puntata_661824.html', | |
31 | 'md5': '9b75534d42c44ecef7bf1ffeacb7f85d', | |
32 | 'info_dict': { | |
33 | 'id': '661824', | |
34 | 'ext': 'mp4', | |
35 | 'title': 'Quarta puntata', | |
0de13634 | 36 | 'description': 'md5:7183696d6df570e3412a5ef74b27c5e2', |
56f9c77f S |
37 | 'thumbnail': r're:^https?://.*\.jpg$', |
38 | 'duration': 1414, | |
39 | 'creator': 'mediaset', | |
d105a7ed | 40 | 'upload_date': '20161107', |
56f9c77f S |
41 | 'series': 'Hello Goodbye', |
42 | 'categories': ['reality'], | |
43 | }, | |
44 | 'expected_warnings': ['is not a supported codec'], | |
0de13634 T |
45 | }, { |
46 | # clip | |
47 | 'url': 'http://www.video.mediaset.it/video/gogglebox/clip/un-grande-classico-della-commedia-sexy_661680.html', | |
56f9c77f | 48 | 'only_matching': True, |
0de13634 T |
49 | }, { |
50 | # iframe simple | |
51 | 'url': 'http://www.video.mediaset.it/player/playerIFrame.shtml?id=665924&autoplay=true', | |
56f9c77f | 52 | 'only_matching': True, |
0de13634 T |
53 | }, { |
54 | # iframe twitter (from http://www.wittytv.it/se-prima-mi-fidavo-zero/) | |
55 | 'url': 'https://www.video.mediaset.it/player/playerIFrameTwitter.shtml?id=665104&playrelated=false&autoplay=false&related=true&hidesocial=true', | |
56f9c77f | 56 | 'only_matching': True, |
ca04de46 S |
57 | }, { |
58 | 'url': 'mediaset:661824', | |
59 | 'only_matching': True, | |
0de13634 T |
60 | }] |
61 | ||
5d29af3d S |
62 | @staticmethod |
63 | def _extract_urls(webpage): | |
64 | return [ | |
65 | mobj.group('url') | |
66 | for mobj in re.finditer( | |
67 | r'<iframe\b[^>]+\bsrc=(["\'])(?P<url>https?://(?:www\.)?video\.mediaset\.it/player/playerIFrame(?:Twitter)?\.shtml\?.*?\bid=\d+.*?)\1', | |
68 | webpage)] | |
69 | ||
0de13634 T |
70 | def _real_extract(self, url): |
71 | video_id = self._match_id(url) | |
0de13634 | 72 | |
56f9c77f S |
73 | video_list = self._download_json( |
74 | 'http://cdnsel01.mediaset.net/GetCdn.aspx', | |
75 | video_id, 'Downloading video CDN JSON', query={ | |
76 | 'streamid': video_id, | |
77 | 'format': 'json', | |
78 | })['videoList'] | |
0de13634 | 79 | |
56f9c77f S |
80 | formats = [] |
81 | for format_url in video_list: | |
82 | if '.ism' in format_url: | |
83 | formats.extend(self._extract_ism_formats( | |
84 | format_url, video_id, ism_id='mss', fatal=False)) | |
85 | else: | |
86 | formats.append({ | |
87 | 'url': format_url, | |
88 | 'format_id': determine_ext(format_url), | |
89 | }) | |
90 | self._sort_formats(formats) | |
0de13634 | 91 | |
56f9c77f S |
92 | mediainfo = self._download_json( |
93 | 'http://plr.video.mediaset.it/html/metainfo.sjson', | |
94 | video_id, 'Downloading video info JSON', query={ | |
95 | 'id': video_id, | |
96 | })['video'] | |
0de13634 | 97 | |
56f9c77f | 98 | title = mediainfo['title'] |
0de13634 | 99 | |
56f9c77f S |
100 | creator = try_get( |
101 | mediainfo, lambda x: x['brand-info']['publisher'], compat_str) | |
102 | category = try_get( | |
103 | mediainfo, lambda x: x['brand-info']['category'], compat_str) | |
104 | categories = [category] if category else None | |
0de13634 T |
105 | |
106 | return { | |
107 | 'id': video_id, | |
56f9c77f | 108 | 'title': title, |
0de13634 | 109 | 'description': mediainfo.get('short-description'), |
0de13634 T |
110 | 'thumbnail': mediainfo.get('thumbnail'), |
111 | 'duration': parse_duration(mediainfo.get('duration')), | |
56f9c77f | 112 | 'creator': creator, |
d105a7ed | 113 | 'upload_date': unified_strdate(mediainfo.get('production-date')), |
0de13634 | 114 | 'webpage_url': mediainfo.get('url'), |
56f9c77f S |
115 | 'series': mediainfo.get('brand-value'), |
116 | 'categories': categories, | |
117 | 'formats': formats, | |
0de13634 | 118 | } |