]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/sztvhu.py
Imported Upstream version 2013.12.04
[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 u'skip': u'Service temporarily disabled as of 2013-11-20'
20 }
21
22 def _real_extract(self, url):
23 mobj = re.match(self._VALID_URL, url)
24 video_id = mobj.group('id')
25 webpage = self._download_webpage(url, video_id)
26 video_file = self._search_regex(
27 r'file: "...:(.*?)",', webpage, 'video file')
28 title = self._html_search_regex(
29 r'<meta name="title" content="([^"]*?) - [^-]*? - [^-]*?"',
30 webpage, 'video title')
31 description = self._html_search_regex(
32 r'<meta name="description" content="([^"]*)"/>',
33 webpage, 'video description', fatal=False)
34 thumbnail = self._og_search_thumbnail(webpage)
35
36 video_url = 'http://media.sztv.hu/vod/' + video_file
37
38 return {
39 'id': video_id,
40 'url': video_url,
41 'title': title,
42 'ext': determine_ext(video_url),
43 'description': description,
44 'thumbnail': thumbnail,
45 }