]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/primesharetv.py
debian/README.source: Update steps used to create new release.
[youtubedl] / youtube_dl / extractor / primesharetv.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import (
5 ExtractorError,
6 sanitized_Request,
7 urlencode_postdata,
8 )
9
10
11 class PrimeShareTVIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?primeshare\.tv/download/(?P<id>[\da-zA-Z]+)'
13
14 _TEST = {
15 'url': 'http://primeshare.tv/download/238790B611',
16 'md5': 'b92d9bf5461137c36228009f31533fbc',
17 'info_dict': {
18 'id': '238790B611',
19 'ext': 'mp4',
20 'title': 'Public Domain - 1960s Commercial - Crest Toothpaste-YKsuFona',
21 },
22 }
23
24 def _real_extract(self, url):
25 video_id = self._match_id(url)
26
27 webpage = self._download_webpage(url, video_id)
28
29 if '>File not exist<' in webpage:
30 raise ExtractorError('Video %s does not exist' % video_id, expected=True)
31
32 fields = self._hidden_inputs(webpage)
33
34 headers = {
35 'Referer': url,
36 'Content-Type': 'application/x-www-form-urlencoded',
37 }
38
39 wait_time = int(self._search_regex(
40 r'var\s+cWaitTime\s*=\s*(\d+)',
41 webpage, 'wait time', default=7)) + 1
42 self._sleep(wait_time, video_id)
43
44 req = sanitized_Request(
45 url, urlencode_postdata(fields), headers)
46 video_page = self._download_webpage(
47 req, video_id, 'Downloading video page')
48
49 video_url = self._search_regex(
50 r"url\s*:\s*'([^']+\.primeshare\.tv(?::443)?/file/[^']+)'",
51 video_page, 'video url')
52
53 title = self._html_search_regex(
54 r'<h1>Watch\s*(?:&nbsp;)?\s*\((.+?)(?:\s*\[\.\.\.\])?\)\s*(?:&nbsp;)?\s*<strong>',
55 video_page, 'title')
56
57 return {
58 'id': video_id,
59 'url': video_url,
60 'title': title,
61 'ext': 'mp4',
62 }