YePpHa / YouTubeCenter

YouTube Center is a userscript designed to expand the functionality of YouTube. It includes the ability to download the video you're watching, auto selecting your preferred video quality and much more.
MIT License
2.89k stars 520 forks source link

change audiofile name from videoplayback to the actual title[question] #1414

Open rollator opened 9 years ago

rollator commented 9 years ago

Hey there

I just read the Download:Audio page and wasn't sure if YouTubeCenter isn't able to change to title so something meaningful out of technical impossibility or because it just have not been implementet (yet?). Since I'm fairly inexperienced concerning JavaScript I was curious if this was a technical limitation I did a quick search and found this question in stackoverflow which implies that is impossible to do this client side: http://stackoverflow.com/questions/10049259/change-name-of-download-in-javascript In contrary I found another thread which implies it is possible: http://stackoverflow.com/questions/23806020/how-to-change-a-file-name-and-download-it-when-a-button-is-clicked-using-javascr So if I understood it correctly, changing the filename is impossible, however you could hack a workaround which downloads the file to a variable(I think bytearray) and then saves the variable as a file from JavaScript where you can obviously name it however you like(perhaps title.strangeYoutubeFormat?). So it boils down to two questions: Just from the technical standpoint: Would it be possible to implement? If so, could we expect it some day?

YePpHa commented 9 years ago

I am already using the HTML5 attribute download, but YouTube sends the Content-Disposition: HTTP header. This overrides the download attribute and the filename will not be changed (specs).

The older formats (non-DASH) can be given a title param in the URL and it will change the filename to the value of that param. However, this has not been added to the DASH formats.

The only thing that can make it possible to set a custom filename is to make YouTube Center download the file itself, which is not the greatest idea as it has to download the file into memory first, before it can prompt you to save the file.