-
-
Save Mello-Yello/c5798937d56fc5197c9de6112b748cc6 to your computer and use it in GitHub Desktop.
Openload: extract download URL using PhantomJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: phantomjs openload.js <video_url> | |
var separator = ' | '; | |
var page = require('webpage').create(), | |
system = require('system'), | |
id, match; | |
if(system.args.length < 2) { | |
console.error('No URL provided'); | |
phantom.exit(1); | |
} | |
match = system.args[1].match( | |
/https?:\/\/(?:openload\.(?:co|io)|oload\.tv)\/(?:f|embed)\/([\w\-]+)/); | |
if(match === null) { | |
console.error('Could not find video ID in provided URL'); | |
phantom.exit(2); | |
} | |
id = match[1]; | |
page.open('https://openload.co/embed/' + id + '/', function(status) { | |
var info = page.evaluate(function() { | |
return { | |
decoded_id: document.getElementById('streamurl').innerHTML, | |
title: document.querySelector('meta[name="og:title"],' | |
+ 'meta[name=description]').content | |
}; | |
}); | |
var url = 'https://openload.co/stream/' + info.decoded_id + '?mime=true'; | |
console.log(url + separator + info.title); | |
phantom.exit(); | |
}); | |
page.onInitialized = function() { | |
page.evaluate(function() { | |
delete window.callPhantom; | |
delete window._phantom; | |
}); | |
}; |
Heh, I've been trying with some complex solutions and finally decided to try deleting those variables. Now I checked my Gist and saw somebody did it already. Great job! :D
Add userAgent to make it work once again
@necol1: Could you give me an example, please?
Before page.open add
page.settings.userAgent = 'Mozilla/5.0 (Linux; Android 6.0; LENNY3 Build/MRA58K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.132 Mobile Safari/537.36';
Thank You!
Not work anymore :(
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It works fine, thanks fork