[fktv] Correct spellings
[youtube-dl] / youtube_dl / extractor / fktv.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import (
7     clean_html,
8     determine_ext,
9 )
10
11
12 class FKTVIE(InfoExtractor):
13     IE_NAME = 'fernsehkritik.tv'
14     _VALID_URL = r'http://(?:www\.)?fernsehkritik\.tv/folge-(?P<id>[0-9]+)(?:/.*)?'
15
16     _TEST = {
17         'url': 'http://fernsehkritik.tv/folge-1',
18         'md5': '21f0b0c99bce7d5b524eb1b17b1c6d79',
19         'info_dict': {
20             'id': '1',
21             'ext': 'mp4',
22             'title': 'Folge 1 vom 10. April 2007',
23         },
24     }
25
26     def _real_extract(self, url):
27         episode = self._match_id(url)
28
29         webpage = self._download_webpage('http://fernsehkritik.tv/folge-%s/play' % episode, episode)
30         title = clean_html(self._html_search_regex('<h3>([^<]+?)</h3>', webpage, 'title'))
31         matches = re.search(r'(?s)<video[^>]*poster="([^"]+)"[^>]*>(.*?)</video>', webpage)
32         if matches:
33             poster, sources = matches.groups()
34             urls = re.findall(r'(?s)<source[^>]*src="([^"]+)"[^>]*>', sources)
35             if sources:
36                 formats = [{'url': url, 'format_id': determine_ext(url)} for url in urls]
37                 return {
38                     'id': episode,
39                     'title': title,
40                     'formats': formats,
41                     'thumbnail': poster,
42                 }