2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from .kaltura import KalturaIE
16 class AZMedienBaseIE(InfoExtractor):
17 def _kaltura_video(self, partner_id, entry_id):
18 return self.url_result(
19 'kaltura:%s:%s' % (partner_id, entry_id), ie=KalturaIE.ie_key(),
23 class AZMedienIE(AZMedienBaseIE):
24 IE_DESC = 'AZ Medien videos'
35 /[0-9]+-episode-[^/\#]+
37 /[0-9]+-segment-(?:[^/\#]+\#)?|
47 'url': 'http://www.telezueri.ch/62-show-zuerinews/13772-episode-sonntag-18-dezember-2016/32419-segment-massenabweisungen-beim-hiltl-club-wegen-pelzboom',
51 'title': 'Massenabweisungen beim Hiltl Club wegen Pelzboom',
52 'description': 'md5:9ea9dd1b159ad65b36ddcf7f0d7c76a8',
53 'uploader_id': 'TeleZ?ri',
54 'upload_date': '20161218',
55 'timestamp': 1482084490,
58 'skip_download': True,
61 # URL with 'segment' and fragment:
62 'url': 'http://www.telebaern.tv/118-show-news/14240-episode-dienstag-17-januar-2017/33666-segment-achtung-gefahr#zu-wenig-pflegerinnen-und-pfleger',
65 # URL with 'episode' and fragment:
66 'url': 'http://www.telem1.ch/47-show-sonntalk/13986-episode-soldaten-fuer-grenzschutz-energiestrategie-obama-bilanz#soldaten-fuer-grenzschutz-energiestrategie-obama-bilanz',
69 # URL with 'show' and fragment:
70 'url': 'http://www.telezueri.ch/66-show-sonntalk#burka-plakate-trump-putin-china-besuch',
74 def _real_extract(self, url):
75 video_id = self._match_id(url)
77 webpage = self._download_webpage(url, video_id)
79 partner_id = self._search_regex(
80 r'<script[^>]+src=["\'](?:https?:)?//(?:[^/]+\.)?kaltura\.com(?:/[^/]+)*/(?:p|partner_id)/([0-9]+)',
81 webpage, 'kaltura partner id')
82 entry_id = self._html_search_regex(
83 r'<a[^>]+data-id=(["\'])(?P<id>(?:(?!\1).)+)\1[^>]+data-slug=["\']%s'
84 % re.escape(video_id), webpage, 'kaltura entry id', group='id')
86 return self._kaltura_video(partner_id, entry_id)
89 class AZMedienPlaylistIE(AZMedienBaseIE):
90 IE_DESC = 'AZ Medien playlists'
106 /[0-9]+-episode-[^/\#]+
113 'url': 'http://www.telebaern.tv/118-show-news/13735-episode-donnerstag-15-dezember-2016',
115 'id': '118-show-news/13735-episode-donnerstag-15-dezember-2016',
116 'title': 'News - Donnerstag, 15. Dezember 2016',
121 'url': 'http://www.telem1.ch/258-themen-tele-m1-classics',
123 'id': '258-themen-tele-m1-classics',
124 'title': 'Tele M1 Classics',
126 'playlist_mincount': 15,
128 # URL with 'topic', contains nested playlists
129 'url': 'http://www.telezueri.ch/219-topic-aera-trump-hat-offiziell-begonnen',
130 'only_matching': True,
132 # URL with 'show' only
133 'url': 'http://www.telezueri.ch/86-show-talktaeglich',
134 'only_matching': True
137 def _real_extract(self, url):
138 show_id = self._match_id(url)
139 webpage = self._download_webpage(url, show_id)
143 partner_id = self._search_regex(
144 r'src=["\'](?:https?:)?//(?:[^/]+\.)kaltura\.com/(?:[^/]+/)*(?:p|partner_id)/(\d+)',
145 webpage, 'kaltura partner id', default=None)
149 self._kaltura_video(partner_id, m.group('id'))
150 for m in re.finditer(
151 r'data-id=(["\'])(?P<id>(?:(?!\1).)+)\1', webpage)]
155 self.url_result(m.group('url'), ie=AZMedienIE.ie_key())
156 for m in re.finditer(
157 r'<a[^>]+data-real=(["\'])(?P<url>http.+?)\1', webpage)]
161 # May contain nested playlists (e.g. [1]) thus no explicit
163 # 1. http://www.telezueri.ch/219-topic-aera-trump-hat-offiziell-begonnen)
164 self.url_result(urljoin(url, m.group('url')))
165 for m in re.finditer(
166 r'<a[^>]+name=[^>]+href=(["\'])(?P<url>/.+?)\1', webpage)]
168 title = self._search_regex(
169 r'episodeShareTitle\s*=\s*(["\'])(?P<title>(?:(?!\1).)+)\1',
171 default=strip_or_none(get_element_by_id(
172 'video-title', webpage)), group='title')
174 return self.playlist_result(entries, show_id, title)
177 class AZMedienShowPlaylistIE(AZMedienBaseIE):
178 IE_DESC = 'AZ Medien show playlists'
179 _VALID_URL = r'''(?x)
195 'url': 'http://www.telezueri.ch/all-episodes/astrotalk',
198 'title': 'TeleZüri: AstroTalk - alle episoden',
199 'description': 'md5:4c0f7e7d741d906004266e295ceb4a26',
201 'playlist_mincount': 13,
204 def _real_extract(self, url):
205 playlist_id = self._match_id(url)
206 webpage = self._download_webpage(url, playlist_id)
207 episodes = get_element_by_class('search-mobile-box', webpage)
208 entries = [self.url_result(
209 urljoin(url, m.group('url'))) for m in re.finditer(
210 r'<a[^>]+href=(["\'])(?P<url>(?:(?!\1).)+)\1', episodes)]
211 title = self._og_search_title(webpage, fatal=False)
212 description = self._og_search_description(webpage)
213 return self.playlist_result(entries, playlist_id, title, description)