]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vodlocker.py
Tidy up the changelog.
[youtubedl] / youtube_dl / extractor / vodlocker.py
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..compat import (
6 compat_urllib_parse,
7 compat_urllib_request,
8 )
9
10
11 class VodlockerIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?vodlocker\.com/(?P<id>[0-9a-zA-Z]+)(?:\..*?)?'
13
14 _TESTS = [{
15 'url': 'http://vodlocker.com/e8wvyzz4sl42',
16 'md5': 'ce0c2d18fa0735f1bd91b69b0e54aacf',
17 'info_dict': {
18 'id': 'e8wvyzz4sl42',
19 'ext': 'mp4',
20 'title': 'Germany vs Brazil',
21 'thumbnail': 're:http://.*\.jpg',
22 },
23 }]
24
25 def _real_extract(self, url):
26 video_id = self._match_id(url)
27 webpage = self._download_webpage(url, video_id)
28
29 fields = self._hidden_inputs(webpage)
30
31 if fields['op'] == 'download1':
32 self._sleep(3, video_id) # they do detect when requests happen too fast!
33 post = compat_urllib_parse.urlencode(fields)
34 req = compat_urllib_request.Request(url, post)
35 req.add_header('Content-type', 'application/x-www-form-urlencoded')
36 webpage = self._download_webpage(
37 req, video_id, 'Downloading video page')
38
39 title = self._search_regex(
40 r'id="file_title".*?>\s*(.*?)\s*<(?:br|span)', webpage, 'title')
41 thumbnail = self._search_regex(
42 r'image:\s*"(http[^\"]+)",', webpage, 'thumbnail')
43 url = self._search_regex(
44 r'file:\s*"(http[^\"]+)",', webpage, 'file url')
45
46 formats = [{
47 'format_id': 'sd',
48 'url': url,
49 }]
50
51 return {
52 'id': video_id,
53 'title': title,
54 'thumbnail': thumbnail,
55 'formats': formats,
56 }