1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from .kaltura import KalturaIE
15 class AZMedienBaseIE(InfoExtractor):
16 def _kaltura_video(self, partner_id, entry_id):
17 return self.url_result(
18 'kaltura:%s:%s' % (partner_id, entry_id), ie=KalturaIE.ie_key(),
22 class AZMedienIE(AZMedienBaseIE):
23 IE_DESC = 'AZ Medien videos'
34 /[0-9]+-episode-[^/\#]+
36 /[0-9]+-segment-(?:[^/\#]+\#)?|
46 'url': 'http://www.telezueri.ch/62-show-zuerinews/13772-episode-sonntag-18-dezember-2016/32419-segment-massenabweisungen-beim-hiltl-club-wegen-pelzboom',
50 'title': 'Massenabweisungen beim Hiltl Club wegen Pelzboom',
51 'description': 'md5:9ea9dd1b159ad65b36ddcf7f0d7c76a8',
52 'uploader_id': 'TeleZ?ri',
53 'upload_date': '20161218',
54 'timestamp': 1482084490,
57 'skip_download': True,
60 # URL with 'segment' and fragment:
61 'url': 'http://www.telebaern.tv/118-show-news/14240-episode-dienstag-17-januar-2017/33666-segment-achtung-gefahr#zu-wenig-pflegerinnen-und-pfleger',
64 # URL with 'episode' and fragment:
65 'url': 'http://www.telem1.ch/47-show-sonntalk/13986-episode-soldaten-fuer-grenzschutz-energiestrategie-obama-bilanz#soldaten-fuer-grenzschutz-energiestrategie-obama-bilanz',
68 # URL with 'show' and fragment:
69 'url': 'http://www.telezueri.ch/66-show-sonntalk#burka-plakate-trump-putin-china-besuch',
73 def _real_extract(self, url):
74 video_id = self._match_id(url)
76 webpage = self._download_webpage(url, video_id)
78 partner_id = self._search_regex(
79 r'<script[^>]+src=["\'](?:https?:)?//(?:[^/]+\.)?kaltura\.com(?:/[^/]+)*/(?:p|partner_id)/([0-9]+)',
80 webpage, 'kaltura partner id')
81 entry_id = self._html_search_regex(
82 r'<a[^>]+data-id=(["\'])(?P<id>(?:(?!\1).)+)\1[^>]+data-slug=["\']%s'
83 % re.escape(video_id), webpage, 'kaltura entry id', group='id')
85 return self._kaltura_video(partner_id, entry_id)
88 class AZMedienPlaylistIE(AZMedienBaseIE):
89 IE_DESC = 'AZ Medien playlists'
105 /[0-9]+-episode-[^/\#]+
112 'url': 'http://www.telebaern.tv/118-show-news/13735-episode-donnerstag-15-dezember-2016',
114 'id': '118-show-news/13735-episode-donnerstag-15-dezember-2016',
115 'title': 'News - Donnerstag, 15. Dezember 2016',
120 'url': 'http://www.telem1.ch/258-themen-tele-m1-classics',
122 'id': '258-themen-tele-m1-classics',
123 'title': 'Tele M1 Classics',
125 'playlist_mincount': 15,
127 # URL with 'topic', contains nested playlists
128 'url': 'http://www.telezueri.ch/219-topic-aera-trump-hat-offiziell-begonnen',
129 'only_matching': True,
131 # URL with 'show' only
132 'url': 'http://www.telezueri.ch/86-show-talktaeglich',
133 'only_matching': True
136 def _real_extract(self, url):
137 show_id = self._match_id(url)
138 webpage = self._download_webpage(url, show_id)
142 partner_id = self._search_regex(
143 r'src=["\'](?:https?:)?//(?:[^/]+\.)kaltura\.com/(?:[^/]+/)*(?:p|partner_id)/(\d+)',
144 webpage, 'kaltura partner id', default=None)
148 self._kaltura_video(partner_id, m.group('id'))
149 for m in re.finditer(
150 r'data-id=(["\'])(?P<id>(?:(?!\1).)+)\1', webpage)]
154 self.url_result(m.group('url'), ie=AZMedienIE.ie_key())
155 for m in re.finditer(
156 r'<a[^>]+data-real=(["\'])(?P<url>http.+?)\1', webpage)]
160 # May contain nested playlists (e.g. [1]) thus no explicit
162 # 1. http://www.telezueri.ch/219-topic-aera-trump-hat-offiziell-begonnen)
163 self.url_result(urljoin(url, m.group('url')))
164 for m in re.finditer(
165 r'<a[^>]+name=[^>]+href=(["\'])(?P<url>/.+?)\1', webpage)]
167 title = self._search_regex(
168 r'episodeShareTitle\s*=\s*(["\'])(?P<title>(?:(?!\1).)+)\1',
170 default=strip_or_none(get_element_by_id(
171 'video-title', webpage)), group='title')
173 return self.playlist_result(entries, show_id, title)
176 class AZMedienShowPlaylistIE(AZMedienBaseIE):
177 IE_DESC = 'AZ Medien Show playlists'
178 _VALID_URL = r'''(?x)
196 'url': 'http://www.telezueri.ch/all-episodes/astrotalk',
198 'id': 'telezueri.ch/all-episodes/astrotalk',
199 'title': 'TeleZüri: AstroTalk - alle episoden',
200 'description': 'md5:4c0f7e7d741d906004266e295ceb4a26',
202 'playlist_mincount': 13,
204 'skip_download': True,
208 def _real_extract(self, url):
209 playlist_id = self._match_id(url)
210 webpage = self._download_webpage(url, playlist_id)
211 episodes = get_element_by_class('search-mobile-box', webpage)
212 entries = [self.url_result(
213 urljoin(url, m.group('url'))) for m in re.finditer(
214 r'<a[^>]+href=(["\'])(?P<url>.+?)\1', episodes)]
215 title = self._og_search_title(webpage)
216 description = self._og_search_description(webpage)
217 return self.playlist_result(
219 playlist_id=playlist_id,
220 playlist_title=title,
221 playlist_description=description)