]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/sztvhu.py
Imported Upstream version 2013.10.23
[youtubedl] / youtube_dl / extractor / sztvhu.py
1 # -*- coding: utf-8 -*-
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import determine_ext
7
8
9 class SztvHuIE(InfoExtractor):
10 _VALID_URL = r'(?:http://)?(?:(?:www\.)?sztv\.hu|www\.tvszombathely\.hu)/(?:[^/]+)/.+-(?P<id>[0-9]+)'
11 _TEST = {
12 u'url': u'http://sztv.hu/hirek/cserkeszek-nepszerusitettek-a-kornyezettudatos-eletmodot-a-savaria-teren-20130909',
13 u'file': u'20130909.mp4',
14 u'md5': u'a6df607b11fb07d0e9f2ad94613375cb',
15 u'info_dict': {
16 u"title": u"Cserkészek népszerűsítették a környezettudatos életmódot a Savaria téren",
17 u"description": u'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...',
18 }
19 }
20
21 def _real_extract(self, url):
22 mobj = re.match(self._VALID_URL, url)
23 video_id = mobj.group('id')
24 webpage = self._download_webpage(url, video_id)
25 video_file = self._search_regex(
26 r'file: "...:(.*?)",', webpage, 'video file')
27 title = self._html_search_regex(
28 r'<meta name="title" content="([^"]*?) - [^-]*? - [^-]*?"',
29 webpage, 'video title')
30 description = self._html_search_regex(
31 r'<meta name="description" content="([^"]*)"/>',
32 webpage, 'video description', fatal=False)
33 thumbnail = self._og_search_thumbnail(webpage)
34
35 video_url = 'http://media.sztv.hu/vod/' + video_file
36
37 return {
38 'id': video_id,
39 'url': video_url,
40 'title': title,
41 'ext': determine_ext(video_url),
42 'description': description,
43 'thumbnail': thumbnail,
44 }