]>
Commit | Line | Data |
---|---|---|
5aa38e75 CR |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
5aa38e75 CR |
5 | import os.path |
6 | ||
7 | from .common import InfoExtractor | |
1cc79574 PH |
8 | from ..utils import ( |
9 | ExtractorError, | |
5c2266df | 10 | sanitized_Request, |
6e6bc8da | 11 | urlencode_postdata, |
1cc79574 | 12 | ) |
5aa38e75 CR |
13 | |
14 | ||
15 | class PlayedIE(InfoExtractor): | |
16 | IE_NAME = 'played.to' | |
38c4d41b | 17 | _VALID_URL = r'https?://(?:www\.)?played\.to/(?P<id>[a-zA-Z0-9_-]+)' |
5aa38e75 CR |
18 | |
19 | _TEST = { | |
20 | 'url': 'http://played.to/j2f2sfiiukgt', | |
21 | 'md5': 'c2bd75a368e82980e7257bf500c00637', | |
22 | 'info_dict': { | |
23 | 'id': 'j2f2sfiiukgt', | |
24 | 'ext': 'flv', | |
25 | 'title': 'youtube-dl_test_video.mp4', | |
26 | }, | |
62420c73 | 27 | 'skip': 'Removed for copyright infringement.', # oh wow |
5aa38e75 CR |
28 | } |
29 | ||
30 | def _real_extract(self, url): | |
38c4d41b | 31 | video_id = self._match_id(url) |
5aa38e75 | 32 | orig_webpage = self._download_webpage(url, video_id) |
76630645 S |
33 | |
34 | m_error = re.search( | |
35 | r'(?s)Reason for deletion:.*?<b class="err"[^>]*>(?P<msg>[^<]+)</b>', orig_webpage) | |
36 | if m_error: | |
37 | raise ExtractorError(m_error.group('msg'), expected=True) | |
38 | ||
f8da79f8 | 39 | data = self._hidden_inputs(orig_webpage) |
5aa38e75 | 40 | |
38c4d41b | 41 | self._sleep(2, video_id) |
5aa38e75 | 42 | |
6e6bc8da | 43 | post = urlencode_postdata(data) |
5aa38e75 CR |
44 | headers = { |
45 | b'Content-Type': b'application/x-www-form-urlencoded', | |
46 | } | |
5c2266df | 47 | req = sanitized_Request(url, post, headers) |
5aa38e75 CR |
48 | webpage = self._download_webpage( |
49 | req, video_id, note='Downloading video page ...') | |
50 | ||
51 | title = os.path.splitext(data['fname'])[0] | |
52 | ||
53 | video_url = self._search_regex( | |
54 | r'file: "?(.+?)",', webpage, 'video URL') | |
55 | ||
56 | return { | |
57 | 'id': video_id, | |
58 | 'title': title, | |
59 | 'url': video_url, | |
38c4d41b | 60 | } |