]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/fktv.py
Merge remote-tracking branch 'rupertbaxter2/master'
[yt-dlp.git] / youtube_dl / extractor / fktv.py
CommitLineData
bf7aa630
PH
1from __future__ import unicode_literals
2
c5e743f6
JMF
3import re
4import random
5import json
71c107fc 6
7from .common import InfoExtractor
8from ..utils import (
c5e743f6
JMF
9 get_element_by_id,
10 clean_html,
71c107fc 11)
12
c5e743f6 13
71c107fc 14class FKTVIE(InfoExtractor):
bf7aa630 15 IE_NAME = 'fernsehkritik.tv'
bd6b25ce 16 _VALID_URL = r'http://(?:www\.)?fernsehkritik\.tv/folge-(?P<id>[0-9]+)(?:/.*)?'
71c107fc 17
c5e743f6 18 _TEST = {
bf7aa630
PH
19 'url': 'http://fernsehkritik.tv/folge-1',
20 'info_dict': {
21 'id': '00011',
22 'ext': 'flv',
23 'title': 'Folge 1 vom 10. April 2007',
24 'description': 'md5:fb4818139c7cfe6907d4b83412a6864f',
c5e743f6
JMF
25 },
26 }
27
28 def _real_extract(self, url):
bd6b25ce 29 episode = int(self._match_id(url))
c5e743f6 30
bd6b25ce
PH
31 video_thumbnail = 'http://fernsehkritik.tv/images/magazin/folge%s.jpg' % episode
32 start_webpage = self._download_webpage('http://fernsehkritik.tv/folge-%s/Start' % episode,
9e1a5b84 33 episode)
c5e743f6 34 playlist = self._search_regex(r'playlist = (\[.*?\]);', start_webpage,
9e1a5b84 35 'playlist', flags=re.DOTALL)
c5e743f6 36 files = json.loads(re.sub('{[^{}]*?}', '{}', playlist))
bd6b25ce 37
71c107fc 38 videos = []
c5e743f6 39 for i, _ in enumerate(files, 1):
71c107fc 40 video_id = '%04d%d' % (episode, i)
bd6b25ce 41 video_url = 'http://fernsehkritik.tv/js/directme.php?file=%s%s.flv' % (episode, '' if i == 1 else '-%d' % i)
71c107fc 42 videos.append({
bd6b25ce 43 'ext': 'flv',
c5e743f6
JMF
44 'id': video_id,
45 'url': video_url,
c5e743f6
JMF
46 'title': clean_html(get_element_by_id('eptitle', start_webpage)),
47 'description': clean_html(get_element_by_id('contentlist', start_webpage)),
71c107fc 48 'thumbnail': video_thumbnail
49 })
bd6b25ce
PH
50 return {
51 '_type': 'multi_video',
52 'entries': videos,
53 'id': 'folge-%s' % episode,
54 }
71c107fc 55
c5e743f6 56
71c107fc 57class FKTVPosteckeIE(InfoExtractor):
bf7aa630
PH
58 IE_NAME = 'fernsehkritik.tv:postecke'
59 _VALID_URL = r'http://(?:www\.)?fernsehkritik\.tv/inline-video/postecke\.php\?(.*&)?ep=(?P<ep>[0-9]+)(&|$)'
71c107fc 60 _TEST = {
bf7aa630
PH
61 'url': 'http://fernsehkritik.tv/inline-video/postecke.php?iframe=true&width=625&height=440&ep=120',
62 'md5': '262f0adbac80317412f7e57b4808e5c4',
63 'info_dict': {
64 'id': '0120',
65 'ext': 'flv',
66 'title': 'Postecke 120',
71c107fc 67 }
68 }
69
c5e743f6 70 def _real_extract(self, url):
71c107fc 71 mobj = re.match(self._VALID_URL, url)
72 episode = int(mobj.group('ep'))
c5e743f6
JMF
73
74 server = random.randint(2, 4)
71c107fc 75 video_id = '%04d' % episode
76 video_url = 'http://dl%d.fernsehkritik.tv/postecke/postecke%d.flv' % (server, episode)
77 video_title = 'Postecke %d' % episode
c5e743f6 78 return {
bf7aa630
PH
79 'id': video_id,
80 'url': video_url,
81 'title': video_title,
c5e743f6 82 }