how to intercept flash contents requests - javascript

I am writing a small JavaScript to download videos from a site. The site doesn't contain the link to the file to played. It downloads a flash file from which the flash file requests a URL to the file on remote server.
So finally when embedded flash opens a URL, how can we intercept/capture the URL request?

It's impossible to intercept any content from Browser Plugins through JavaScript, since you don't have full access of Web Browser API (the case of embedded JavaScript via script tags or bookmarklet).
If you make Firefox extension, you can act like Firebug or DownthemAll (Media-Sniffing mode, see https://github.com/nmaier/DownThemAll/blob/master/modules/support/contenthandling.jsm)
There only one alternative. Reverse engineering location of video, for example read flashvars, but some website like youtube are more complicated.

Related

How do I automate opening and downloading a webpage?

There is a website that has an HTML <video> element in it when loaded, however this element isn't present if I just download it with wget, so I guess it gets loaded by a script that's only ran when the page is opened in a browser. I need the video's direct link, in an automated fashion.
Could you please tell me if I have the right idea, and if there is a possible solution? Could I for example run a browser from the command line, let it load the page and all of the referenced content, then save the .html file?
You could use headless Chrome, potentially with Puppeteer scripting for that.
Though, depending on the details, there may be easier options that would get you what you need. It sounds like you're currently trying to scrape a third party website using wget. Instead of, or in addition to, requesting the .html content with wget, you could request the relevant javascript file and then extract the video url from there.

xmlHttpRequest to a flash Website

I am using javascript to do XMLHTTP Requests (GET) calls, and I want to get the content of the Flash website, but when I do xmlhttpRequest to that website I get flash error saying:
"This content requires the Adobe Flash Player."
can some one help me in this, I really do not have any more information about it to share :( , just a simple XMLHTTP REQUEST.
(and its not about CORS, I have already fixed that)
I get flash error saying: "This content requires the Adobe Flash
Player."
That's not a Flash error. Check the source code of the html, I bet that "error" is just text written as alternative / placeholder text when Flash embed is not displaying (ie: not covering the same text).
Why can't you scrape this Flash content with XMLHTTP request?...
Flash files are actually compiled applications, not a text document like some .JS or .HTML files. You have to run the application within its required operating system (in this case, the installed FlashPlayer plugin). Until then you have no "content" to scrape.
What can you do?...
Depends what you want to scrape. For example with some Flash-based Weather App, the daily updates must be coming from somewhere like a JSON or XML file so really, to get today's weather details you simply check the JSON file (input) not scrape the SWF (output).
Apply this logic together with your browser's Developer Tools to see what other files are listed after SWF load. Maybe they actually hold the data you need...?
If the content is hard-coded into the Flash file then you'll have to go into the bytes of SWF to extract it (no longer about XMLHTTP requests). Here's a blog article from some who wanted to extract images from swf, maybe it can help you with hints.

How does Spotify mask the audio URL and also prevent download of song mp3

I'm looking to mask the audio playing on my site so people can't download the audio files and also don't know what the url for the actual file (mp3) is
Simple answer,
YOU CAN'T
If they are listening to your audio, they have it already
You can slow them down but can't stop them.
The only thing you can do is obfuscate the process. But why bother at all?
The browsers were designed to: Serve content - which means give the content to the user. To show you how easy it is, here's how I usually grab video/audios on virtually any streaming site:
Prepare the network tab of your preferred browser debugger and let the video/audio load. Then look for it in the loaded resources. Videos are usually streamed in .flv or .mp4, and audio in .mp3. When you spot the url, open a new tab/window and open the link there. The browser will then download the file.

javascript to discover .flv url from any embedded flash video?

Is there any javascript library out there that can find the url to the flash video file (.flv) on current page where it has an embedded flash video player? Ex. opens collegehumor.com video link, shows flash video url.
I have been looking through codes from chrome extensions which discovers flash video links for download but no dice.
Browser extensions can look into Flash internals and monitor your HTTP activity to see where data is being pulled from, however Javascript running in the document does not have permission to read either of those.
Some Flash apps expose some of their internals to Javascript, but they need to specifically write in that functionality, and for third parties this would be documented, presumably as an API. As far as I can tell, collegehumor doesn't provide any of that.

Programmatically call a firefox extension from javascript

I have seen this excellent firefox extension, Screengrab!. It takes a "picture" of the web page and copies it to the clipboard or saves it to a png file. I need to do so, but with a new web page, from an url I have in javascript. I can open the web page in a new window, but then I have to call the extension -not to press the control- and saves the page once the page is fully loaded.
Is it possible?
I am pretty certain that it is not possible to access any Firefox add-on through web page content. This could create privacy and/or security issues within the Firefox browser (as the user has never given you permission to access such content on their machine). For this reason, I believe Firefox add-ons run in an entirely different JavaScript context, thereby making this entirely impossible.
However, as Dmitriy's answer states, there are server-side workarounds that can be performed.
Does not look like ScreenGrab has any javascript API.
There is a PHP solution for Saving Web Page as Image.
If you need to do it from JavaScript (from client side) - you can:
Step 1: Create a PHP server app that does the trick (see the link), and that accepts JSONP call.
Step 2: Create a client side page (JavaScript) that will send a JSONP request to that PHP script. See my answer here, that will help you to create such request.

Categories

Resources