]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/fktv.py
Add bug number that we are closing.
[youtubedl] / youtube_dl / extractor / fktv.py
1 import re
2 import random
3 import json
4
5 from .common import InfoExtractor
6 from ..utils import (
7 determine_ext,
8 get_element_by_id,
9 clean_html,
10 )
11
12
13 class FKTVIE(InfoExtractor):
14 IE_NAME = u'fernsehkritik.tv'
15 _VALID_URL = r'(?:http://)?(?:www\.)?fernsehkritik.tv/folge-(?P<ep>[0-9]+)(?:/.*)?'
16
17 _TEST = {
18 u'url': u'http://fernsehkritik.tv/folge-1',
19 u'file': u'00011.flv',
20 u'info_dict': {
21 u'title': u'Folge 1 vom 10. April 2007',
22 u'description': u'md5:fb4818139c7cfe6907d4b83412a6864f',
23 },
24 }
25
26 def _real_extract(self, url):
27 mobj = re.match(self._VALID_URL, url)
28 episode = int(mobj.group('ep'))
29
30 server = random.randint(2, 4)
31 video_thumbnail = 'http://fernsehkritik.tv/images/magazin/folge%d.jpg' % episode
32 start_webpage = self._download_webpage('http://fernsehkritik.tv/folge-%d/Start' % episode,
33 episode)
34 playlist = self._search_regex(r'playlist = (\[.*?\]);', start_webpage,
35 u'playlist', flags=re.DOTALL)
36 files = json.loads(re.sub('{[^{}]*?}', '{}', playlist))
37 # TODO: return a single multipart video
38 videos = []
39 for i, _ in enumerate(files, 1):
40 video_id = '%04d%d' % (episode, i)
41 video_url = 'http://dl%d.fernsehkritik.tv/fernsehkritik%d%s.flv' % (server, episode, '' if i == 1 else '-%d' % i)
42 video_title = 'Fernsehkritik %d.%d' % (episode, i)
43 videos.append({
44 'id': video_id,
45 'url': video_url,
46 'ext': determine_ext(video_url),
47 'title': clean_html(get_element_by_id('eptitle', start_webpage)),
48 'description': clean_html(get_element_by_id('contentlist', start_webpage)),
49 'thumbnail': video_thumbnail
50 })
51 return videos
52
53
54 class FKTVPosteckeIE(InfoExtractor):
55 IE_NAME = u'fernsehkritik.tv:postecke'
56 _VALID_URL = r'(?:http://)?(?:www\.)?fernsehkritik.tv/inline-video/postecke.php\?(.*&)?ep=(?P<ep>[0-9]+)(&|$)'
57 _TEST = {
58 u'url': u'http://fernsehkritik.tv/inline-video/postecke.php?iframe=true&width=625&height=440&ep=120',
59 u'file': u'0120.flv',
60 u'md5': u'262f0adbac80317412f7e57b4808e5c4',
61 u'info_dict': {
62 u"title": u"Postecke 120"
63 }
64 }
65
66 def _real_extract(self, url):
67 mobj = re.match(self._VALID_URL, url)
68 episode = int(mobj.group('ep'))
69
70 server = random.randint(2, 4)
71 video_id = '%04d' % episode
72 video_url = 'http://dl%d.fernsehkritik.tv/postecke/postecke%d.flv' % (server, episode)
73 video_title = 'Postecke %d' % episode
74 return {
75 'id': video_id,
76 'url': video_url,
77 'ext': determine_ext(video_url),
78 'title': video_title,
79 }