]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ruhd.py
55b58e5e6c09af2d211edaba256ad2ebce2a958d
[youtubedl] / youtube_dl / extractor / ruhd.py
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7
8
9 class RUHDIE(InfoExtractor):
10 _VALID_URL = r'http://(?:www\.)?ruhd\.ru/play\.php\?vid=(?P<id>\d+)'
11 _TEST = {
12 'url': 'http://www.ruhd.ru/play.php?vid=207',
13 'md5': 'd1a9ec4edf8598e3fbd92bb16072ba83',
14 'info_dict': {
15 'id': '207',
16 'ext': 'divx',
17 'title': 'КОТ бааааам',
18 'description': 'классный кот)',
19 'thumbnail': 're:^http://.*\.jpg$',
20 }
21 }
22
23 def _real_extract(self, url):
24 mobj = re.match(self._VALID_URL, url)
25 video_id = mobj.group('id')
26
27 webpage = self._download_webpage(url, video_id)
28
29 video_url = self._html_search_regex(
30 r'<param name="src" value="([^"]+)"', webpage, 'video url')
31 title = self._html_search_regex(
32 r'<title>([^<]+)&nbsp;&nbsp; RUHD.ru - Видео Высокого качества №1 в России!</title>', webpage, 'title')
33 description = self._html_search_regex(
34 r'(?s)<div id="longdesc">(.+?)<span id="showlink">', webpage, 'description', fatal=False)
35 thumbnail = self._html_search_regex(
36 r'<param name="previewImage" value="([^"]+)"', webpage, 'thumbnail', fatal=False)
37 if thumbnail:
38 thumbnail = 'http://www.ruhd.ru' + thumbnail
39
40 return {
41 'id': video_id,
42 'url': video_url,
43 'title': title,
44 'description': description,
45 'thumbnail': thumbnail,
46 }