youtube-dl/youtube_dl/extractor/sztvhu.py

45 lines
1.7 KiB
Python
Raw Normal View History

2013-10-14 11:07:47 +00:00
# -*- coding: utf-8 -*-
import re
from .common import InfoExtractor
from ..utils import determine_ext
2013-10-14 23:33:20 +00:00
2013-10-14 11:07:47 +00:00
class SztvHuIE(InfoExtractor):
2013-10-14 23:33:20 +00:00
_VALID_URL = r'(?:http://)?(?:(?:www\.)?sztv\.hu|www\.tvszombathely\.hu)/(?:[^/]+)/.+-(?P<id>[0-9]+)'
2013-10-14 11:07:47 +00:00
_TEST = {
u'url': u'http://sztv.hu/hirek/cserkeszek-nepszerusitettek-a-kornyezettudatos-eletmodot-a-savaria-teren-20130909',
2013-10-14 23:33:20 +00:00
u'file': u'20130909.mp4',
u'md5': u'a6df607b11fb07d0e9f2ad94613375cb',
2013-10-14 11:07:47 +00:00
u'info_dict': {
u"title": u"Cserkészek népszerűsítették a környezettudatos életmódot a Savaria téren",
2013-10-14 23:33:20 +00:00
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...',
2013-10-14 11:07:47 +00:00
}
}
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
2013-10-14 23:33:20 +00:00
video_id = mobj.group('id')
webpage = self._download_webpage(url, video_id)
video_file = self._search_regex(
r'file: "...:(.*?)",', webpage, 'video file')
title = self._html_search_regex(
2013-10-15 06:22:59 +00:00
r'<meta name="title" content="([^"]*?) - [^-]*? - [^-]*?"',
2013-10-14 23:33:20 +00:00
webpage, 'video title')
description = self._html_search_regex(
r'<meta name="description" content="([^"]*)"/>',
webpage, 'video description', fatal=False)
2013-10-14 11:07:47 +00:00
thumbnail = self._og_search_thumbnail(webpage)
2013-10-14 23:33:20 +00:00
video_url = 'http://media.sztv.hu/vod/' + video_file
2013-10-14 11:07:47 +00:00
2013-10-14 23:33:20 +00:00
return {
'id': video_id,
'url': video_url,
'title': title,
'ext': determine_ext(video_url),
'description': description,
'thumbnail': thumbnail,
}