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

[Feature request] Download button #83

Closed
narcolepticinsomniac opened this issue Aug 4, 2018 · 32 comments
Closed

[Feature request] Download button #83

narcolepticinsomniac opened this issue Aug 4, 2018 · 32 comments
Labels
enhancement Improvement of an existing feature

Comments

@narcolepticinsomniac
Copy link

I know it's as simple as right-click/save-as, but a download button would be a good look. Tbh, I don't even recall the last time I downloaded a YT vid, but seeing the option when YT goes out of their way to make it difficult is pretty satisfying.

I've played around a little with userscripts, and the best I could do was utilize GM_download, which converts to a blob. It works, but it'll be slow with larger files, and probably has limits size-wise. Most places I searched, the more reliable method consistently suggested would be on your end, using PHP.

@dimqua
Copy link
Contributor

dimqua commented Aug 4, 2018

Should be also possible to download a video in selected quality (resolution and format).

@elypter
Copy link

elypter commented Sep 4, 2018

it should be a setting for the admin so he can decide for his mirror.

@omarroth
Copy link
Contributor

omarroth commented Sep 4, 2018

I'm not quite sure what you mean @elypter, you'll have to clarify. As an update to this, I plan on adding a download button similar to Hooktube's, where you can select one of the streams to download. I'm also looking into automatically muxing video and audio for 1080p and above, although that will require the client to have JS enabled.

@elypter
Copy link

elypter commented Sep 4, 2018

i meant that someone who wants to use the source to host this project himself then that person should have the choice to add a download button or not. i personally would love to have a download button but some people might not be comfortable with it.

@omarroth
Copy link
Contributor

omarroth commented Sep 5, 2018

That's an interesting thought. I'm wondering why someone would be uncomfortable with having a download button? It would serve the same files provided used by the player, and if they're hosting it they can always just pull out the code that provides the button.

@elypter
Copy link

elypter commented Sep 5, 2018

in some peoples mind streaming and downloading are fundamentally different things, especially for politicians, although it is basically the same. i just think it is better turn those things into settings so you can update easily. its not a big deal, just a something that came to mind.

@ghost
Copy link

ghost commented Nov 6, 2018

I created a userscript for Tampermonkey called Invidious Downloader which adds a download button next to the listen mode button. It requires Tampermonkey because of GM_download not existing in Greasemonkey and the one in Violentmonkey doesn't work with EventListeners.

@dimqua
Copy link
Contributor

dimqua commented Nov 6, 2018

@erupete does it work for DASH videos, e.g. 1080p ones?

@ghost
Copy link

ghost commented Nov 6, 2018

@dimqua not at the moment, only audio files and pre-muxed videos

@omarroth
Copy link
Contributor

omarroth commented Nov 7, 2018

Looks good! Added to the list of extensions with 3a44cfd. The issue with DASH videos was the main delay in why this hasn't been added to the site itself. My plan is to use something like videojs/mux.js to combine the separate streams in the browser so that users don't need to use an external tool (e.g. ffmpeg).

@omarroth omarroth added the enhancement Improvement of an existing feature label Nov 18, 2018
@mmarfil
Copy link

mmarfil commented Jan 20, 2019

@omarroth comimg here to give my 👍 too. I'd love to have an option to download either the mp3 or pre-muxed videos so I can listen/watch offline on my mobile device while on the go. Thanks for building Invidious by the way!

@omarroth
Copy link
Contributor

omarroth commented Jan 24, 2019

Added with fb535ad.

Unfortunately there's no way (that I've found) to mux the audio and video streams in the browser in a way that can be downloaded by user. Currently you can download video-only, audio-only, or any of the pre-muxed versions. The default filename of the download is the same as the default template for youtube-dl, #{title}-#{id}.#{ext}, although currently ext will always be mp4. I expect this to be fixed soon.

This functionality relies on proxying videos through the site, so it's another test for how much bandwidth would likely be used for #34. Since the videos themselves are proxied, you should also be able to download videos that have region-blocks, see #92.

You will also likely need to do a hard refresh to pull updated versions of default.css and watch.js.

@dimqua
Copy link
Contributor

dimqua commented Jan 24, 2019

@omarroth is it possible to implement this feature without proxying videos? And since the videos are proxied, can't them be pre-muxed on Invidious instance?

@omarroth
Copy link
Contributor

omarroth commented Jan 24, 2019

CORS prevents loading resources directly from YouTube. As far as I am aware, the only way to implement this feature is by proxying everything.

I would rather not mux them server-side, since it's generally quite CPU and memory intensive.

@dimqua
Copy link
Contributor

dimqua commented Jan 24, 2019

@omarroth does CloudTube and HookTube proxying them too?

@elypter
Copy link

elypter commented Jan 24, 2019

could it work if both files were downloaded to localstorage and then merged? i think that is how those downloads on mega.nz work

@omarroth
Copy link
Contributor

See a similar conversation on proxying in #177, which also links to explanations on how FreeTube and CloudTube do things.

HookTube now uses the embedded player after receiving a C&D from YouTube, so there's no need for it to proxy anything. It also never appeared to support higher than 720p, see the FAQ page at https://hooktube.com for an explanation why.

There's a difference between merging two chunks of data and muxing them in the way that is required here. I have yet to find a solution that is able to do that. MediaSources come very close, but they unfortunately are not able to extend to this use case, see w3c/media-source#209.

@dimqua
Copy link
Contributor

dimqua commented Jan 25, 2019

@omarroth well, if CloudTube's approach isn't ideal for playing DASH videos, it probably doesn't mean it's bad for downloading them, right?

@omarroth
Copy link
Contributor

I'm not quite sure what you're asking, but as far as I know it isn't possible to use that approach for downloading videos, since browsers have stricter controls on downloading media than they do on playing it.

@omarroth
Copy link
Contributor

Since the original functionality has been implemented I'm going to close this. For pre-muxed versions or any extensions to this functionality I would recommend opening a new issue.

@dimqua
Copy link
Contributor

dimqua commented Feb 5, 2019

as far as I know it isn't possible to use that approach for downloading videos

Ah, my bad, I thought CloudTube allows to download videos, but it doesn't.

But if I use Invidious with JS disabled, I can download videos (up to 720p) using direct links:

But I can't do the same using the 'Download' button. Also the button does not work without JS at all.

@omarroth
Copy link
Contributor

Removed JS from download button with 1692f76. It now proxies the direct links with Content-Disposition: attachment; filename=#{title}-#{id}.mp4.

@narcolepticinsomniac
Copy link
Author

Why are src URLs obfuscated now? I had a simple little script to set a referrer policy so I could have a download button which opens the src URL, and triggers automatic downloads based on the referrer. Just noticed that it stopped working, and after checking why, I'm obviously getting no referrer because of this new redirect. What was the point of this?

@omarroth
Copy link
Contributor

Would you mind clarifying or providing the script you're using? Are you referring to /latest_version or something else?

@narcolepticinsomniac
Copy link
Author

Are you referring to /latest_version

Yeah. Used to be just a regular googlevideo src URL, because I was able to pass a referrer before the redirect was added.

Script relies on a userstyle as well:

https://pastebin.com/zC7t4qGS
https://pastebin.com/PRpYmG8s

@narcolepticinsomniac
Copy link
Author

Download button is for embeds only, obviously.

@omarroth
Copy link
Contributor

The reason /latest_version is used is because googlevideo links expire after 6 hours, which creates issues when leaving the player idle (see #276). Additionally, in the case where an invalid URL is encountered, the player can reload to receive a fresh URL, for example when a server is unavailable or tries to serve an incomplete file.

Assuming you have an id and itag, you can use /latest_version?download_widget={"id":"#{id}","itag":"#{itag}","title":"#{desired title}"}, which will add Content-Disposition: to trigger download automatically.

@narcolepticinsomniac
Copy link
Author

Guess those are some good reasons. I must not have tried to download anything in a while if that wasn't a recent change. The method I was using was super simple and used to work. I don't really know how to implement the workaround you're suggesting.

@narcolepticinsomniac
Copy link
Author

Assuming you have an id and itag, you can use...

I did try this briefly previously, but I used the exact syntax provided in the example, minus the curly brackets where I inserted the correct strings. Wasn't working, so I got irritated and gave up on it. Finally got around to giving it another try, and removing the hashtags makes it work as advertised. Probably should've figured that just by looking at it. Anyway, cool feature, and thanks for the heads up.

@narcolepticinsomniac
Copy link
Author

Assuming you have an id and itag, you can use...

I'm getting "Administrator has disabled this endpoint" now.

@narcolepticinsomniac
Copy link
Author

@omarroth What's the word on this? Did you disable it intentionally, or can it be fixed?

@omarroth
Copy link
Contributor

See #883. It's been disabled intentionally. I'll look into providing them in a way that doesn't use as much bandwidth.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

5 participants