Skip to content

Instantly share code, notes, and snippets.

Last active November 20, 2021 15:14
Show Gist options
  • Save Tithen-Firion/8b3921d745131837519d5c5b95b86440 to your computer and use it in GitHub Desktop.
Save Tithen-Firion/8b3921d745131837519d5c5b95b86440 to your computer and use it in GitHub Desktop.
Openload: extract download URL using PhantomJS
// Usage: phantomjs openload.js <video_url>
// if that doesn't work try: phantomjs --ssl-protocol=any 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');
match = system.args[1].match(
if(match === null) {
console.error('Could not find video ID in provided URL');
id = match[1];
// thanks @Mello-Yello :)
page.onInitialized = function() {
page.evaluate(function() {
delete window._phantom;
delete window.callPhantom;
page.settings.userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36";'' + id + '/', function(status) {
var info = page.evaluate(function() {
return {
decoded_id: document.getElementById('streamuri').innerHTML,
title: document.querySelector('meta[name="og:title"],'
+ 'meta[name=description]').content
var url = '' + info.decoded_id + '?mime=true';
console.log(url + separator + info.title);
Copy link

gonubana commented Jan 17, 2018

It seems like it does not work anymore even after running
sed -e "32 s/getElementById..streamur./querySelector('*[id^=streamur]/"
on this openload.js file.

I'm of course getting a similar link to " | bunny HTTP/1.1" but GETting this link only gets me a "HTTP/1.1 400 Bad Request" type response.

Is this only me or they somehow changed something else somewhere.

Copy link

@gonubana just tested and
curl -L -k -o <filename> <generated URL>
works perfectly fine.

Copy link

Just read 4 comments above before saying "it doesn't work".

Copy link

I don't think it is working anymore
TypeError: null is not an object (evaluating 'document.getElementById('streamuri').innerHTML')


Copy link

Not work anymore :(

Copy link

#streamuri and #streamurl have been empty for a couple of weeks now.

Copy link

Did anyone find a solution for this?

Copy link

This is the current magic:
console.log('' + page.content.match(/\w+\d+\d+.\d+.\d+.\d+~\w+/)[0] + '?mime=true');

Copy link

feryw commented Jul 17, 2018

it should be
console.log('' + page.content.match(/\w+~\d+~\d+.\d+.\d+.\d+~\w+/)[0] + '?mime=true');
for more clear

Copy link

Since there is a domain, regex should be

And, i was looking into the deobfuscated jsnice code of the source and i saw this line

if ("toString" in sin && sin.toString().indexOf("[native code") != -1 && document.getElementById.toString().indexOf("[native code") == -1 || window.callPhantom || /Phantom/.test(navigator.userAgent) || window.__phantomas || next() || window.domAutomation || window.webdriver || document.documentElement.getAttribute("webdriver"))

I guess there is some anti-measure phantomjs in the site, but aparently its not working, because @gonubana comment does captures the download URL...

Copy link

feryw commented Jul 18, 2018

reduce regex complexity
console.log('' + page.content.match(/\w+~\d+~[\d\.]+~\w+/)[0] + '?mime=true');

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