]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/played.py
Merge pull request #8061 from dstftw/introduce-chapter-and-series-fields
[yt-dlp.git] / youtube_dl / extractor / played.py
CommitLineData
5aa38e75
CR
1# coding: utf-8
2from __future__ import unicode_literals
3
4import re
5aa38e75
CR
5import os.path
6
7from .common import InfoExtractor
5c2266df 8from ..compat import compat_urllib_parse
1cc79574
PH
9from ..utils import (
10 ExtractorError,
5c2266df 11 sanitized_Request,
1cc79574 12)
5aa38e75
CR
13
14
15class 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
CR
42
43 post = compat_urllib_parse.urlencode(data)
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 }