Unify coding cookie
[youtube-dl] / youtube_dl / extractor / sztvhu.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6
7 class SztvHuIE(InfoExtractor):
8     _VALID_URL = r'https?://(?:(?:www\.)?sztv\.hu|www\.tvszombathely\.hu)/(?:[^/]+)/.+-(?P<id>[0-9]+)'
9     _TEST = {
10         'url': 'http://sztv.hu/hirek/cserkeszek-nepszerusitettek-a-kornyezettudatos-eletmodot-a-savaria-teren-20130909',
11         'md5': 'a6df607b11fb07d0e9f2ad94613375cb',
12         'info_dict': {
13             'id': '20130909',
14             'ext': 'mp4',
15             'title': 'Cserkészek népszerűsítették a környezettudatos életmódot a Savaria téren',
16             'description': 'A zöld nap játékos ismeretterjesztő programjait a Magyar Cserkész Szövetség szervezte, akik az ország nyolc városában adják át tudásukat az érdeklődőknek. A PET...',
17         },
18     }
19
20     def _real_extract(self, url):
21         video_id = self._match_id(url)
22         webpage = self._download_webpage(url, video_id)
23         video_file = self._search_regex(
24             r'file: "...:(.*?)",', webpage, 'video file')
25         title = self._html_search_regex(
26             r'<meta name="title" content="([^"]*?) - [^-]*? - [^-]*?"',
27             webpage, 'video title')
28         description = self._html_search_regex(
29             r'<meta name="description" content="([^"]*)"/>',
30             webpage, 'video description', fatal=False)
31         thumbnail = self._og_search_thumbnail(webpage)
32
33         video_url = 'http://media.sztv.hu/vod/' + video_file
34
35         return {
36             'id': video_id,
37             'url': video_url,
38             'title': title,
39             'description': description,
40             'thumbnail': thumbnail,
41         }