views:

26

answers:

1

I have a big problem. I've made a simple Google Chrome plugin (based on the old Youtube Video Downloader) but I have some problems with it. The first problem is that it won't pop up a new save window on click, but opens a new page with the video in the default Chrome player. The second is, that when the user clicks right click-save, they won't get the video name but a standardized name.

Is there any way to make a file save dialog with a specified file save name?

EDIT:

The link is automatically generated based on the Youtube video link, this way:

document.getElementById('watch-description-body').innerHTML+='<button id="download-youtube-video-button" data-button-listener="" data-tooltip-timer="300" class="yt-uix-button yt-uix-tooltip" data-tooltip="Right-click and click Save Link As... to download" type="button">'+'<a href="http://www.youtube.com/get_video?video_id='+video_id+'&amp;t='+t+'=" style="padding: 2px">FLV</a></button>' ;

So basically it ads a button to the existing page, with a specified link:

http://www.youtube.com/get_video?video_id='+video_id+'&amp;t='+t+'=

Where video_id is the Video ID number, and t is the time the player was stopped.

+2  A: 

1) To 'force' a download, rather than a page load you will need to deliver a Content-Disposition: attachment HTTP header.

graphicdivine
2) This also allows you to provide a default filename of your choice: `Content-Disposition: attachment;filename=FunnyKittensLOL.flv`
Ates Goral
And to add this custom header, you may need to proxy the original file through a server (ie. your plug-in may need to have a server-side dependency)
Ates Goral
That made no sense for me, sorry. Could you please tell me where should I put these lines?
fonix232
Although, as far as I know, JavaScript is not going to be able to deliver HTTP headers: you'll need something server-side. ie PHP.
graphicdivine
Start here: http://php.net/manual/en/function.header.php
graphicdivine
Following your edit, I see that you don't control the server from which the download originates, so you won't be able to set the HTTP headers. I don't know what to suggest, then. I suppose this is why the tooltip exists on the button. If it's not your data, you won't be able to control how that data is deliverd, so you'll have to resort to instructing the user how to request it.
graphicdivine
But in the old version of the application, it was saved correctly, with the given video name. So maybe Youtube changed something?And also as the plugin can modify the page itself (so it can add the button) I think it is able to add that PHP code too.
fonix232