]>
Commit | Line | Data |
---|---|---|
bf7aa630 PH |
1 | from __future__ import unicode_literals |
2 | ||
c5e743f6 JMF |
3 | import re |
4 | import random | |
5 | import json | |
71c107fc | 6 | |
7 | from .common import InfoExtractor | |
8 | from ..utils import ( | |
c5e743f6 JMF |
9 | get_element_by_id, |
10 | clean_html, | |
71c107fc | 11 | ) |
12 | ||
c5e743f6 | 13 | |
71c107fc | 14 | class FKTVIE(InfoExtractor): |
bf7aa630 PH |
15 | IE_NAME = 'fernsehkritik.tv' |
16 | _VALID_URL = r'http://(?:www\.)?fernsehkritik\.tv/folge-(?P<ep>[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): | |
71c107fc | 29 | mobj = re.match(self._VALID_URL, url) |
30 | episode = int(mobj.group('ep')) | |
c5e743f6 JMF |
31 | |
32 | server = random.randint(2, 4) | |
71c107fc | 33 | video_thumbnail = 'http://fernsehkritik.tv/images/magazin/folge%d.jpg' % episode |
c5e743f6 JMF |
34 | start_webpage = self._download_webpage('http://fernsehkritik.tv/folge-%d/Start' % episode, |
35 | episode) | |
36 | playlist = self._search_regex(r'playlist = (\[.*?\]);', start_webpage, | |
bf7aa630 | 37 | 'playlist', flags=re.DOTALL) |
c5e743f6 JMF |
38 | files = json.loads(re.sub('{[^{}]*?}', '{}', playlist)) |
39 | # TODO: return a single multipart video | |
71c107fc | 40 | videos = [] |
c5e743f6 | 41 | for i, _ in enumerate(files, 1): |
71c107fc | 42 | video_id = '%04d%d' % (episode, i) |
c5e743f6 | 43 | video_url = 'http://dl%d.fernsehkritik.tv/fernsehkritik%d%s.flv' % (server, episode, '' if i == 1 else '-%d' % i) |
71c107fc | 44 | videos.append({ |
c5e743f6 JMF |
45 | 'id': video_id, |
46 | 'url': video_url, | |
c5e743f6 JMF |
47 | 'title': clean_html(get_element_by_id('eptitle', start_webpage)), |
48 | 'description': clean_html(get_element_by_id('contentlist', start_webpage)), | |
71c107fc | 49 | 'thumbnail': video_thumbnail |
50 | }) | |
51 | return videos | |
52 | ||
c5e743f6 | 53 | |
71c107fc | 54 | class FKTVPosteckeIE(InfoExtractor): |
bf7aa630 PH |
55 | IE_NAME = 'fernsehkritik.tv:postecke' |
56 | _VALID_URL = r'http://(?:www\.)?fernsehkritik\.tv/inline-video/postecke\.php\?(.*&)?ep=(?P<ep>[0-9]+)(&|$)' | |
71c107fc | 57 | _TEST = { |
bf7aa630 PH |
58 | 'url': 'http://fernsehkritik.tv/inline-video/postecke.php?iframe=true&width=625&height=440&ep=120', |
59 | 'md5': '262f0adbac80317412f7e57b4808e5c4', | |
60 | 'info_dict': { | |
61 | 'id': '0120', | |
62 | 'ext': 'flv', | |
63 | 'title': 'Postecke 120', | |
71c107fc | 64 | } |
65 | } | |
66 | ||
c5e743f6 | 67 | def _real_extract(self, url): |
71c107fc | 68 | mobj = re.match(self._VALID_URL, url) |
69 | episode = int(mobj.group('ep')) | |
c5e743f6 JMF |
70 | |
71 | server = random.randint(2, 4) | |
71c107fc | 72 | video_id = '%04d' % episode |
73 | video_url = 'http://dl%d.fernsehkritik.tv/postecke/postecke%d.flv' % (server, episode) | |
74 | video_title = 'Postecke %d' % episode | |
c5e743f6 | 75 | return { |
bf7aa630 PH |
76 | 'id': video_id, |
77 | 'url': video_url, | |
78 | 'title': video_title, | |
c5e743f6 | 79 | } |