]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/freespeech.py
Imported Upstream version 2014.11.21
[youtubedl] / youtube_dl / extractor / freespeech.py
1 from __future__ import unicode_literals
2
3 import re
4 import json
5
6 from .common import InfoExtractor
7
8
9 class FreespeechIE(InfoExtractor):
10 IE_NAME = 'freespeech.org'
11 _VALID_URL = r'https://www\.freespeech\.org/video/(?P<title>.+)'
12 _TEST = {
13 'add_ie': ['Youtube'],
14 'url': 'https://www.freespeech.org/video/obama-romney-campaign-colorado-ahead-debate-0',
15 'info_dict': {
16 'id': 'poKsVCZ64uU',
17 'ext': 'mp4',
18 'title': 'Obama, Romney Campaign in Colorado Ahead of Debate',
19 'description': 'Obama, Romney Campaign in Colorado Ahead of Debate',
20 'uploader': 'freespeechtv',
21 'uploader_id': 'freespeechtv',
22 'upload_date': '20121002',
23 },
24 }
25
26 def _real_extract(self, url):
27 mobj = re.match(self._VALID_URL, url)
28 title = mobj.group('title')
29 webpage = self._download_webpage(url, title)
30 info_json = self._search_regex(r'jQuery.extend\(Drupal.settings, ({.*?})\);', webpage, 'info')
31 info = json.loads(info_json)
32
33 return {
34 '_type': 'url',
35 'url': info['jw_player']['basic_video_node_player']['file'],
36 'ie_key': 'Youtube',
37 }