Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

videomega.tv is broken #7606

Closed
myvidster opened this issue Nov 22, 2015 · 17 comments
Closed

videomega.tv is broken #7606

myvidster opened this issue Nov 22, 2015 · 17 comments
Labels

Comments

@myvidster
Copy link

@myvidster myvidster commented Nov 22, 2015

For videomega.tv a 100Kb file is downloaded and not the actual video.

/usr/local/bin/youtube-dl -o /root/tmp/debug.mp4 http://videomega.tv/?ref=83yVRkJym44myJkRVy38

[VideoMega] 83yVRkJym44myJkRVy38: Downloading webpage
[download] Destination: /root/tmp/debug.mp4
[download] 100% of 103.59KiB in 00:00

@dstftw dstftw added the broken-IE label Nov 22, 2015
@alex-krestin
Copy link

@alex-krestin alex-krestin commented Nov 24, 2015

Videomega encrypts link to real video file. I don't know how it can be bypassed in python, but in JS you need first extract eval function from videomega iframe page and then run it to get real link.

var webpage = ... ;                     // load iframe html

var regex = /(eval[^<]+)/;              // create regex
var str = regex.exec(webpage)[1];       // extract eval function
str = str.replace(/\$\("\d"\).\d/, ""); // replace jquery reference in code 
                                        // (otherwise we will get an error)

var res = eval(str);                    // evaluate extracted function

console.log(res);                       // show link to download ^_^
@myvidster
Copy link
Author

@myvidster myvidster commented Nov 25, 2015

I decoded the mp4 found in the eval function and the video still will not download.

eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return'\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\b'+e(c)+'\b','g'),k[c])}}return p}('$("5").6("4","3://0.1.2.7/8/d.e?c=b&9=a-f");',16,16,'ab1|cdn|vizplay|http|src|video|attr|org|v|hash|0eOZNdBc9Q|OqWQxdqzJoKTxFx8E7Y0PQ|st|fb2ffbadf624a7cca80efd808f7747c2|mp4|476ZsZ5u7Tw'.split('|'),0,{}))

http://abo.cdn.vizplay.org/v/bd2182bbdc9b0b17e8b15d9409b96ace.mp4?st=Gw32g3PLy-M5j64J--mu6Q&hash=iTrJH53mORTGdybgXfHzKQ

@alex-krestin
Copy link

@alex-krestin alex-krestin commented Nov 25, 2015

Can you post here original link from where you're trying to get download link?

@myvidster
Copy link
Author

@myvidster myvidster commented Nov 25, 2015

@alex-krestin
Copy link

@alex-krestin alex-krestin commented Nov 25, 2015

Perfectly downloaded by my script. I'm currently develop an addon for Mozilla Firefox so the syntax is a little different than the clear JS. You need to do this steps to get a link:

// 1) load original page html 
var content = ... ; 
// 2) extract valid link 
var videomegaUrlRegex = /(https?:\/\/(www\.)?videomega\.tv\/(view|iframe|cdn)\.php\?ref=([A-Za-z0-9]+))/;
var iframeUrl = videomegaUrlRegex.exec(content)[1];
// 3) send GET request to this link with next header (the site isn't important):
headers: { "Referer": "http://google.com/"},
// 4) get response html and extract eval expression
var iframeHtml = ...;
var regex = /(eval[^<]+)/;
var str = regex.exec(iframeHtml )[1];
str = str.replace(/\$\("\d"\).\d/, ""); // replace jquery reference
// 5) evaluate this string to get a download link
var downloadLink =  eval(str);
// 5) do something with this link
@myvidster
Copy link
Author

@myvidster myvidster commented Nov 25, 2015

Interesting, my download link works in Firefox and not in Chrome. Before I was using chrome to download the url. With that said, the URL is bound to the IP so I converted the code to php and attempted to fetch and pipe the download from my dev server with no luck. Hopefully someone can fix youtube-dl.

@alex-krestin
Copy link

@alex-krestin alex-krestin commented Nov 25, 2015

Chrome opens link as a media and you need to press Ctrl + S to download file.

@myvidster
Copy link
Author

@myvidster myvidster commented Nov 25, 2015

Great tip! Is anyone working on fixing youtube-dl, it still only downloads a 100kbs file.

@Tek9x
Copy link

@Tek9x Tek9x commented Dec 5, 2015

when i try to get the info , it gives me the black video that sounds like people in the backround and not the url link , i can get the url of the video in c# if i sniff http and grab it there but i am trying to do it all in python with youtube-dl. instead of grabbing the real link from c# and then download via python. this is what i am getting back http://abo.cdn.vizplay.org/v/1/aaaa1e04c23889aaec7251ca54fc1a8a.mp4?st=16EAWN6461t1mpoVWHru_w&hash=aYpJoz7HKPj_QA8n4QSfNg black video instead of real video. here is the real video link i can grab using my c# code but id rather do it all in python. -snipped url-

what i do in c# i use the fiddler core api to sniff traffic to grab the url of the video the downside is that since i am not so good at c# i still have to manually go to the page of the video i want to download :(

@alex-krestin
Copy link

@alex-krestin alex-krestin commented Dec 5, 2015

I think it's not possible to do with youtube-dl unless developers didn't add dependency for PyExecJS or another library to evaluate JS expression. And I don't know how it can be useful if only this site requires it.

@myvidster
Copy link
Author

@myvidster myvidster commented Dec 5, 2015

Other tube sites that uses JS eval.
powvideo.net
flashx.tv
videowood.tv

@Tek9x
Copy link

@Tek9x Tek9x commented Dec 5, 2015

ok so this is really ugly but i took what alex said and put it into python and came up with

import requests
import re
import js2py

header = {"Referer": "http://google.com/"}
videomegaUrlRegex = '(https?:\/\/(www\.)?videomega\.tv\/(view|iframe|cdn)\.php\?ref=([A-Za-z0-9]+))'
findeval = '(eval[^<]+)'

purl = requests.get('video_link_here')
link = re.findall(videomegaUrlRegex, purl.content)[0]
url = link[0]
print url

durl = requests.get(url, headers=header)
eV = re.findall(findeval, durl.content)[0]

print eV

rr = '(\$\("\d"\).\d)'

js = re.sub(rr, '', eV)

downloadURL = js2py.eval_js(js)

print downloadURL

it works perfectly , thank you alex for making me teach myself , this code is quick and dirty so all by means feel free to clean it up. this website came in handy https://regex101.com/

@dban0001
Copy link

@dban0001 dban0001 commented Dec 26, 2015

Can someone add this to youtube-dl with a pull request?

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Feb 26, 2016

Videomega, at least http://videomega.tv/?ref=83yVRkJym44myJkRVy38, uses the same obfuscation technique as iQiyi. It can be handled with pure Python. It's not a good idea to use external libraries, especially dangerous eval().

@yan12125 yan12125 closed this in e4fc8d2 Feb 26, 2016
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Feb 26, 2016

This site will work again in the next version. Thanks everyone that provides ideas.

remitamine referenced this issue Feb 26, 2016
@wahiba2
Copy link

@wahiba2 wahiba2 commented Sep 9, 2016

i have the same problem on streaming film
when click play sow me 404 not found

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Sep 10, 2016

@wahiba2 Please open a new issue and paste a concrete video URL instead of the homepage of a website.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants
@dstftw @yan12125 @alex-krestin @myvidster @dban0001 @Tek9x @wahiba2 and others
You can’t perform that action at this time.