2 from __future__ import unicode_literals
9 from .common import InfoExtractor
18 class OpenloadIE(InfoExtractor):
19 _VALID_URL = r'https?://(?:openload\.(?:co|io)|oload\.tv)/(?:f|embed)/(?P<id>[a-zA-Z0-9-_]+)'
22 'url': 'https://openload.co/f/kUEfGclsU9o',
23 'md5': 'bf1c059b004ebc7a256f89408e65c36e',
27 'title': 'skyrim_no-audio_1080.mp4',
28 'thumbnail': r're:^https?://.*\.jpg$',
31 'url': 'https://openload.co/embed/rjC09fkPLYs',
36 'thumbnail': r're:^https?://.*\.jpg$',
44 'skip_download': True, # test subtitles only
47 'url': 'https://openload.co/embed/kUEfGclsU9o/skyrim_no-audio_1080.mp4',
48 'only_matching': True,
50 'url': 'https://openload.io/f/ZAn6oz-VZGE/',
51 'only_matching': True,
53 'url': 'https://openload.co/f/_-ztPaZtMhM/',
54 'only_matching': True,
56 # unavailable via https://openload.co/f/Sxz5sADo82g/, different layout
58 'url': 'https://openload.co/embed/Sxz5sADo82g/',
59 'only_matching': True,
61 'url': 'https://oload.tv/embed/KnG-kKZdcfY/',
62 'only_matching': True,
65 _PHANTOMJS_SCRIPT = r'''
66 phantom.onError = function(msg, trace) {
67 var msgStack = ['PHANTOM ERROR: ' + msg];
68 if(trace && trace.length) {
69 msgStack.push('TRACE:');
70 trace.forEach(function(t) {
71 msgStack.push(' -> ' + (t.file || t.sourceURL) + ': ' + t.line
72 + (t.function ? ' (in function ' + t.function +')' : ''));
75 console.error(msgStack.join('\n'));
78 var page = require('webpage').create();
79 page.settings.resourceTimeout = 10000;
80 page.onInitialized = function() {
81 page.evaluate(function() {
82 delete window._phantom;
83 delete window.callPhantom;
86 page.open('https://openload.co/embed/%s/', function(status) {
87 var info = page.evaluate(function() {
89 decoded_id: document.getElementById('streamurl').innerHTML,
90 title: document.querySelector('meta[name="og:title"],'
91 + 'meta[name=description]').content
94 console.log(info.decoded_id + ' ' + info.title);
99 def _extract_urls(webpage):
101 r'<iframe[^>]+src=["\']((?:https?://)?(?:openload\.(?:co|io)|oload\.tv)/embed/[a-zA-Z0-9-_]+)',
104 def _real_extract(self, url):
105 exe = check_executable('phantomjs', ['-v'])
107 raise ExtractorError('PhantomJS executable not found in PATH, '
108 'download it from http://phantomjs.org',
111 video_id = self._match_id(url)
112 url = 'https://openload.co/embed/%s/' % video_id
113 webpage = self._download_webpage(url, video_id)
115 if 'File not found' in webpage or 'deleted by the owner' in webpage:
116 raise ExtractorError('File not found', expected=True, video_id=video_id)
118 script_file = tempfile.NamedTemporaryFile(mode='w', delete=False)
120 # write JS script to file and close it
122 script_file.write(self._PHANTOMJS_SCRIPT % video_id)
124 self.to_screen('%s: Decoding video ID with PhantomJS' % video_id)
126 p = subprocess.Popen([exe, '--ssl-protocol=any', script_file.name],
127 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
128 output, err = p.communicate()
129 if p.returncode != 0:
130 raise ExtractorError('Decoding failed\n:'
131 + encodeArgument(err))
133 decoded_id, title = encodeArgument(output).strip().split(' ', 1)
135 os.remove(script_file.name)
137 video_url = 'https://openload.co/stream/%s?mime=true' % decoded_id
139 entries = self._parse_html5_media_entries(url, webpage, video_id)
140 entry = entries[0] if entries else {}
141 subtitles = entry.get('subtitles')
146 'thumbnail': entry.get('thumbnail') or self._og_search_thumbnail(webpage, default=None),
148 # Seems all videos have extensions in their titles
149 'ext': determine_ext(title, 'mp4'),
150 'subtitles': subtitles,