From 94f4ea447530e9cc6a87922c26e7cb9508978d3a Mon Sep 17 00:00:00 2001 From: pnc Date: Fri, 8 Jan 2016 09:58:41 +0100 Subject: [PATCH] [videa] Add new extractor --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/videa.py | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 youtube_dl/extractor/videa.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index a9d23b8f4..f411b5e1b 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -788,6 +788,7 @@ from .vgtv import ( from .vh1 import VH1IE from .vice import ViceIE from .viddler import ViddlerIE +from .videa import VideaIE from .videodetective import VideoDetectiveIE from .videofyme import VideofyMeIE from .videomega import VideoMegaIE diff --git a/youtube_dl/extractor/videa.py b/youtube_dl/extractor/videa.py new file mode 100644 index 000000000..9c128164e --- /dev/null +++ b/youtube_dl/extractor/videa.py @@ -0,0 +1,55 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..compat import ( + compat_urllib_parse, +) + +class VideaIE(InfoExtractor): + _VALID_URL = r'https?://videa\.hu/videok/(.+?)/?(?P\d+)' + IE_NAME = 'videa.hu' + + _TEST = { + 'url': 'http://videa.hu/videok/kreativ/igy-lehet-nekimenni-a-hosegnek-ballon-hoseg-CZqIVSVYfJKf9bHC', + 'md5': 'e9a24350bbd485746d23519319949e72', + 'info_dict': { + 'id': 'CZqIVSVYfJKf9bHC', + 'ext': '1150387', + 'title': 'Így lehet nekimenni a hőségnek', + 'description': '', + 'uploader': 'viktoratakarító', + } + } + + def _real_extract(self, url): + + # the last part of the slug is the real video hash id + video_id = self._search_regex(r'([A-Za-z0-9]+)$', url, 'video id') + + info_data = compat_urllib_parse.urlencode({ + 'format': 'json', + 'url': url, + }) + + # access the oembed data for video infos + info = self._download_json( + 'http://videa.hu/oembed/?url=%s&format=json' % info_data, url, 'Downloading video info') + + # get the player xmldata for the video file url + flvplayer = self._download_xml( + 'http://videa.hu/flvplayer_get_video_xml.php?v=%s' % video_id, 'Downloading player datas') + + duration = flvplayer.find('./video/duration').text; + values = flvplayer.find('./video/versions').text; + for elem in flvplayer.findall('video/versions/version'): + video_url = elem.get('video_url') + + return { + 'id': video_id, + 'title': info['title'], + 'url': video_url, + 'thumbnail': info['thumbnail_url'], + 'description': '', + 'uploader': info['author_name'], + } \ No newline at end of file