Skip to content

Instantly share code, notes, and snippets.

@Mello-Yello
Forked from Tithen-Firion/openload.js
Last active April 9, 2018 10:23
Show Gist options
  • Save Mello-Yello/c5798937d56fc5197c9de6112b748cc6 to your computer and use it in GitHub Desktop.
Save Mello-Yello/c5798937d56fc5197c9de6112b748cc6 to your computer and use it in GitHub Desktop.
Openload: extract download URL using PhantomJS
// 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;
});
};
@naviocean
Copy link

It works fine, thanks fork

@Tithen-Firion
Copy link

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

@necol1
Copy link

necol1 commented Apr 25, 2017

Add userAgent to make it work once again

@byteholding
Copy link

@necol1: Could you give me an example, please?

@necol1
Copy link

necol1 commented Apr 25, 2017

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';

@byteholding
Copy link

Thank You!

@JeelsBoobz
Copy link

Not work anymore :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment