Download YouTube Videos as MP4
Posted by:
guest
Date: June 28, 2017 12:45PM
Any ideas how to make "Download YouTube Videos as MP4" work?
https://github.com/gantt/downloadyoutube
It's an userjs, works in Firefox, Chrome, Opera, Safari
It has to somehow also work in K-Meleon...
Any tips how? Rodocop, as a pro you should know!
Thanks
Re: Download YouTube Videos as MP4
Date: August 06, 2017 08:58PM
Updated file as of 2021-03-04 placements, macro bug and restore 1.x functionality
Old news:
- Updated file as of 2021-02-27 placements and some additions
- Updated file as of 2020-12-08 changes on User Interaction and script
- Updated file as of 2020-11-26 back to 2020-11-07 with a warning
- Updated file as of 2020-11-25 parsing change
- Updated file as of 2020-11-07 to add a warning if the JavaScript file can't be found and to show an information box when there isn't any available download by YouTube policies
- Updated file as of 2020-07-12 some changes here and there to add the new formats with the open version of the h.265 codec, AV1, that, if enabled through the .js script file will be shown as MP4/AV1; and a little style change
- Updated file as of 2020-06-30 for a change in JSON parsing when JavaScript is disabled on K-meleon
- Updated file as of 2020-03-10 fix for the file size guessing
- Updated file as of 2020-03-06 cause the whole YouTube interface change
- Updated file as of 2020-01-25 as YouTube Code has changed
From now, even if this is intended for K-meleon, if someone was using it on another browser you must know that won't be compatible anymore. I removed a lot of unnecessary code to run on K-meleon
- Updated file as of 2019-08-07 as YouTube Code has changed
Details on macro and script:
Read the instructions in KMM file for updating script file, folders it uses and file names to adopt.
This release does only need to uncompress to macros Root folder. No renaming needs.
If this macro/script can't find any downloadable resource it won't show any download link. This can happen with flagged content, as, for example, copyrighted content.
For further details on the script configuration, open the JS file and read it or refer to GitHub page (dead original page).
Note: the macro reads the JS file each time a YouTube video page loads. I did this because the JS file is configurable, so if you change something you can enjoy it without restarting K-meleon.
The drawback is that it would make a 36KB hard disk read each time a YouTube video loads (example: youtube.com/watch?v=videocode).
Due to that JS file size...., the macro is only compatible with 75.0 and above. Since 2020-01-25 should be compatible with even 1.x.
Edited 21 time(s). Last edit at 03/04/2021 10:48PM by JohnHell.
Attachments:
Download YouTube Videos as MP4.zip (9.3 KB)
Re: Download YouTube Videos as MP4
Date: August 11, 2017 03:26PM
The macro works for me, too. However, while some of the videos download properly, others immediately start playing in the browser's HTML5 player instead of being downloaded, and I can't successfully save them that way. I generally leave HTML5 enabled; would it help if I disabled it for use with this macro? In that case, if the video opened in my offline media player I could save a copy from there.
---
Gerry
Re: Download YouTube Videos as MP4
Date: August 11, 2017 03:42PM
Quote
foliator
The macro works for me, too. However, while some of the videos download properly, others immediately start playing in the browser's HTML5 player instead of being downloaded, and I can't successfully save them that way. I generally leave HTML5 enabled; would it help if I disabled it for use with this macro? In that case, if the video opened in my offline media player I could save a copy from there.
I can't answer to that. Or I browse with JavaScript disabled, so doesn't play, or I have webm format support disabled from preferences so YouTube player encounters an error and doesn't play it.
I just made the macro to make use of the script. Beyond that, I don't know what could be the reason the script doesn't work if the video already plays. Haven't tested and, anyway, is beyond this macro functionality.
Re: Download YouTube Videos as MP4
Date: August 11, 2017 03:59PM
OK, looks like I've answered my own question. :lol: I tried toggling HTML5 off just before clicking on the download link. It worked perfectly. Staying on the same video, I then toggled HTML5 back on and started the download again; as I expected, it opened in the HTML5 player.
Now I'm going to try inserting the HTML5 Disabled statements at the very top of the download macro; maybe it will disable HTML5 automatically prior to the download. Then I can always toggle HTML5 back on later.
---
Gerry
Re: Download YouTube Videos as MP4
Date: August 11, 2017 04:11PM
Quote
foliator
Now I'm going to try inserting the HTML5 Disabled statements at the very top of the download macro; maybe it will disable HTML5 automatically prior to the download. Then I can always toggle HTML5 back on later.
Emmmm, no, that won't work. Placing a toggle at the beginning of the macro will do nothing unless you invoke it.
And the macro is just invoked on load (using the macro holder $OnLoad).
That, without further explanations means, that anything is run unless the page has fully loaded, included the HTML5 video player.
Any toggle you do must be done BEFORE you load the YouTube page, and, therefore, the script invoked by this macro.
Re: Download YouTube Videos as MP4
Date: August 11, 2017 04:52PM
Quote
JohnHell
Quote
foliator
Now I'm going to try inserting the HTML5 Disabled statements at the very top of the download macro; maybe it will disable HTML5 automatically prior to the download. Then I can always toggle HTML5 back on later.
Emmmm, no, that won't work. Placing a toggle at the beginning of the macro will do nothing unless you invoke it.
And the macro is just invoked on load (using the macro holder $OnLoad).
That, without further explanations means, that anything is run unless the page has fully loaded, included the HTML5 video player.
Any toggle you do must be done BEFORE you load the YouTube page, and, therefore, the script invoked by this macro.
True, inserting the toggle doesn't work, as I discovered by trial and error. It's just as easy for me to quickly toggle HTML5 off beforehand using a keyboard shortcut, although I've been able to do so even after the page has fully loaded and the download link appears. So now I just wait until YouTube starts the video playing, pause it, toggle HTML5 off and hit the download link. Pretty easy, actually, and thanks for sharing that macro!
BTW, sometimes the file downloads as "videoplayback" without an extension, but it's easy to add the extension and rename the file later. At other times, the file comes down already properly named with its title and the MP4 extension.
---
Gerry
Re: Download YouTube Videos as MP4
Date: August 11, 2017 05:06PM
Quote
foliator
BTW, sometimes the file downloads as "videoplayback" without an extension, but it's easy to add the extension and rename the file later. At other times, the file comes down already properly named with its title and the MP4 extension.
As posted, that is up to the script developer. Remember to check the github page for updates!!
OH GOD I JUST FOUND THE GITHUB PROJECT DOESN'T EXISTS ANYMORE LOL!!!
HERE AS WELL xDDD
https://greasyfork.org/en/scripts/1317-download-youtube-videos-as-mp4
Edited 2 time(s). Last edit at 08/11/2017 05:10PM by JohnHell.
Re: Download YouTube Videos as MP4
Date: August 11, 2017 05:13PM
Or calling the macro only manually, only when needed, not automatically after every page load ($OnLoad). The catch is that would of course require again a shortcut/menu/button, but if you don't mind that it's another possibility. In that case the toggle could be included.
Re: Download YouTube Videos as MP4
Date: August 11, 2017 05:18PM
Quote
siria
Or calling the macro only manually, only when needed, not automatically after every page load ($OnLoad). The catch is that would of course require again a shortcut/menu/button, but if you don't mind that it's another possibility. In that case the toggle could be included.
I leave enhancements and changes to any of you
It is open to anyone who wants to make changes
Re: Download YouTube Videos as MP4
Date: August 11, 2017 05:38PM
Ha! Maybe Google forced the project off those sites in an attempt to prevent video downloads!
Anyway, it looks like you got that script just in time.
This is why I always store applications that I've stopped using in Zip archives. I might later decide to start using them again, but they may no longer be available online. "Get it while it's hot," as they say.
---
Gerry
Re: Download YouTube Videos as MP4
Date: August 11, 2017 05:40PM
Quote
JohnHell
Quote
siria
Or calling the macro only manually, only when needed, not automatically after every page load ($OnLoad). The catch is that would of course require again a shortcut/menu/button, but if you don't mind that it's another possibility. In that case the toggle could be included.
I leave enhancements and changes to any of you
It is open to anyone who wants to make changes
... and has the knowledge and/or patience to do so.
---
Gerry
Re: Download YouTube Videos as MP4
Date: August 11, 2017 05:42PM
Quote
siria
Or calling the macro only manually, only when needed, not automatically after every page load ($OnLoad). The catch is that would of course require again a shortcut/menu/button, but if you don't mind that it's another possibility. In that case the toggle could be included.
Hmmm ... I might try that later. It might also be necessary for the macro to force a reload of the YouTube page if it hasn't been invoked before loading the page.
UPDATE: No, the page doesn't need to be reloaded. I commented out the $OnLoad statement in the original macro with #. Then I wrote a brand-new macro called YTdownload, which looks like this:
YTdownload{
setpref(BOOL, "media.autoplay.enabled", false);
setpref(BOOL, "media.fragmented-mp4.enabled", false);
setpref(BOOL, "media.ogg.enabled", false);
setpref(BOOL, "media.wave.enabled", false);
setpref(BOOL, "media.webm.enabled", false);
setpref(BOOL, "media.windows-media-foundation.enabled", false);
setpref(BOOL, "media.windows-media-foundation.play-stand-alone", false);
setpref(BOOL, "media.windows-media-foundation.use-dxva", false);
$_x=getpref(BOOL,"media.fragmented-mp4.enabled");
statusbar("HTML5 enabled: ".$_x);
macros(downloadyoutubescript_checkYT);
}
It first disables HTML5, then invokes the download macro. It only requires a single shortcut (I assigned ALT Y). It's not really more convenient, because in my original approach, where the script was allowed to be invoked automatically ($OnLoad), only a single shortcut was required for toggling HTML5. In fact, my second approach would leave HTML5 disabled after the download, so I'd still have to toggle it back on later.
---
Gerry
Edited 2 time(s). Last edit at 08/11/2017 07:49PM by foliator.
Re: Download YouTube Videos as MP4
Date: September 26, 2018 10:02PM
IT WORKS!!!!
I mean - this Gantt-script actually works with KM-Goanna74 on Win98, can you imagine that?! Just downloaded a video with it *dropdead* LOL!!
(of course after a little macro-modifications to allow the script-size in KM74, but the script itself is still original!)
UA was
Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/20100101 Firefox/38.0
Even with cookies and rerrers blocked, xhr blocked, 3rd party iframes blocked, external script files blocked - strangely also despite permissions.default.media still blocked)
OSCPU was set to Win7 too (pref "general.oscpu.override=Windows NT 6.1")
No idea if that's important or not, because trying without spoofing it kept freezing again, and freezing... freezing...(KernelEx compat normally reports W2000) In general, when javascript is on, I have only a few seconds to start any action before the whole browser freezes on such heavy sites. But faking oscpu to Win10 worked too.
Edited 4 time(s). Last edit at 09/26/2018 11:51PM by siria.
Re: Download YouTube Videos as MP4
Date: September 26, 2018 11:37PM
How the download button from this Gantt-script looks, and what it shows (to me) when opened:
Important:
That button needs awhile to appear! Macros can inject scripts only after the whole page has finished loading, and then it takes another couple seconds to run that user script and build the button.
Edited 2 time(s). Last edit at 09/26/2018 11:43PM by siria.
Attachments:
DownloadYouTubeAsMP4_screen.png (44.6 KB)
Re: Download YouTube Videos as MP4
Date: September 28, 2018 04:54PM
Found Gantt's userscript again, on greasyfork:
https://greasyfork.org/en/scripts/1317-download-youtube-videos-as-mp4/code
https://greasyfork.org/en/scripts/1317-download-youtube-videos-as-mp4/
Along with hundred reviews. Probs are also reported here:
https://forum.palemoon.org/viewtopic.php?t=13815
It seems to have probs with newer browser versions, but older ones run well!
And the script needs the classic youtube layout, not the 'modern' one.
Also interesting, youtube in general:
https://en.wikipedia.org/wiki/YouTube#Quality_and_formats
Quote
The default video stream is encoded in the VP9 format with stereo Opus audio; if VP9/WebM is not supported in the browser/device or the browser's user agent reports Windows XP, then H.264/MPEG-4 AVC video with stereo AAC audio is used instead.
Regarding "webm", the script can detect those versions too, but by default they are hidden. This part in the script can be changed by users if they like:
Quote
line 38:
var FORMAT_RULE={'mp4':'all','webm':'noneall','m4a':'all'};
// all=display all versions, max=only highest quality version, none=no version
// the default settings show all MP4 videos
But I see no advantage, after
download even on my old system the normal mp4 runs fine, and for webm the main difference is that the filesize is double as big. So didn't try it yet.
Edited 1 time(s). Last edit at 09/28/2018 05:00PM by siria.
Re: Download YouTube Videos as MP4
Date: September 30, 2018 05:25PM
More findings, tested in
KM1.6 and KM74-goanna:
This brilliant userscript can fetch the download links
even if JS is globally blocked!
And the useragent string doesn't seem to matter either: even my usual old IE-string works.
The one big catch:
due to cosmetical reason, those links are
hidden at first, and only appear after clicking the download button. And now the prob starts:
whatever function that
download button uses "onclick",
this requires the whole page to be loaded with JS first, or it does nothing! And also
this button function is the culprit that KM1.6 does nothing at all, probably just too old.
Alternative:
right-click in page > Page Properties > Links
=> the download links are listed like normal ones too, above the sign-in links
Ideally I'd now like some trick to get those links visible in the page from the start, without needing to click on 'download'. Looks are secondary, ease-of-use matters. Have dabbled with css, injected manually, and finally got those links visible BUT:
they are not clickable, seem to have no focus, rather useless
button * {position: relative !important;}
ol.yt-uix-button-menu {
display: inline !important;
margin-top: 20px !important;
}
Re: Download YouTube Videos as MP4
Date: September 30, 2018 08:14PM
It isn't a brilliant, nor magic, script. It is all in the hands of injectJS. As it doesn't call a function at any point, all is run at once and doesn't need to enable JS.
About the display, that is the reason I told that I had a customized file.
Find the line:
listItems.setAttribute('style', 'display:none;');
And comment it:
// listItems.setAttribute('style', 'display:none;');
Now it will be displayed at the bottom....
always. If I didn't change anything else, that I can't recall what was exactly.
Edited 1 time(s). Last edit at 09/30/2018 08:15PM by JohnHell.
Re: Download YouTube Videos as MP4
Date: September 30, 2018 09:25PM
Thanks, but there must be more. Have tried: in KM1.6 it makes zero difference, and in KMG74 there is no visible difference at first, only after killing all stylesheets the links show up - as part of a multiline button label! Inside one big gray rectangle. Clicking single ones is not possible, whichever one clicks, the result is the complete button is clicked.
I do find that script quite amazing, first for being able to figure out those highly complicated URLs at all, and second for still working after 1 1/2 years, despite google changing their codes all the time!
Re: Download YouTube Videos as MP4
Date: September 30, 2018 10:22PM
Quote
siria
Thanks, but there must be more.
Oh, this one too.
Replace:
mainSpan.appendChild(listItems);
with:
mainSpan.appendChild(listItems);
document.getElementById('footer').appendChild(listItems);
Is nasty, but I found some old css too that I tried to implement and I think I left like this to keep it simple.
Edited 1 time(s). Last edit at 09/30/2018 10:24PM by JohnHell.
Re: Download YouTube Videos as MP4
Date: September 30, 2018 10:48PM
Quote
JohnHell
About the display, that is the reason I told that I had a customized file.
Find the line:
listItems.setAttribute('style', 'display:none;');
And comment it:
// listItems.setAttribute('style', 'display:none;');
Quote
JohnHell
Replace:
mainSpan.appendChild(listItems);
with:
mainSpan.appendChild(listItems);
document.getElementById('footer').appendChild(listItems);
HA - yes!! It works, tested in KM1.6 and KMG74!
All download links at bottom of page, without needing to open the download button.
Wonder if that may fix it also for other folks with KMG7677??
Just one catch, it takes very long to load on this old machine (10sec?) Will remove it from automatic $OnLoad and add it to some menu, to call it manually, only if needed.
Edited 3 time(s). Last edit at 09/30/2018 11:16PM by siria.
Re: Download YouTube Videos as MP4
Date: September 30, 2018 11:15PM
Quote
siria
Wonder if that may fix it also for other folks with KMG7677??
That is just a script, "basic" (those lines at least), as long as KMG hadn't remove the injectJS function, shouldn't be any reason not to run it.
Re: Download YouTube Videos as MP4
Date: September 30, 2018 11:23PM
Quote
foliator
However, while some of the videos download properly, others immediately start playing in the browser's HTML5 player instead of being downloaded, and I can't successfully save them that way
Slightly belated, but: simply right-click the links and "Save Link Target"?
Re: Download YouTube Videos as MP4
Date: August 06, 2019 09:09PM
If you are using YouTube without JavaScript enabled and this script to download the videos, change the following in the script file:
videoID=findMatch(bodyContent, /\"video_id\":\s*\"([^\"]+)\"/);
for this other text
videoID=findMatch(bodyContent, /[\"\']video_id[\"\']:\s*\"([^\"]{11})\"/i);
Or this, but I found "dumb" to search for unlimited characters for the video ID when always has been just 11... and I "fixed" above.
videoID=findMatch(bodyContent, /[\"\']video_id[\"\']:\s*\"([^\"]+)\"/i);
It stopped working because they changed double quotes for single quotes.
Edited 4 time(s). Last edit at 08/07/2019 12:18PM by JohnHell.
Re: Download YouTube Videos as MP4
Date: August 06, 2019 10:41PM
Quote
JohnHell
If you are using YouTube without JavaScript enabled and this script to download the videos, change the following in the script file:
(....)
It stopped working because they changed double quotes for single quotes.
YES - it works again!!
Thank you
Had noticed the script stopped working some 2 weeks ago, but not the slightest clue how to fix.
Really nice to get some help when needing it. Happens far too rarely these days (and good timing, was just brooding again about how obviously the forum is now dying for good, or perhaps even the whole browser, with not a single km76 user around anymore for even checking the simplest things)
Looks like Google is now slowly killing off all the old classic views, which were still working perfectly fine until just lately
The normal youtube page still looks normal - at the moment yet - but just discovered the
mobile youtube page stopped working too (=in old browser without JS). Last week it still worked, that was after that code change already. But now looks nearly empty, that means I don't get to see any descriptions or anything else anymore.
Looks just as 'nearly empty' as the page for Google translations of text snippets. At the moment only their full-URL translations work - YET - but who knows how long. And it's even only accessible by the direct URL-strings created by the macro now, otherwise I wouldn't even get ANY translations anymore. Well, probably with KG74 and scripts their new pages may still work, more or less, but with far too little RAM that means freezing in no time.
Re: Download YouTube Videos as MP4
Date: August 06, 2019 11:37PM
Quote
siria
Quote
JohnHell
If you are using YouTube without JavaScript enabled and this script to download the videos, change the following in the script file:
(....)
It stopped working because they changed double quotes for single quotes.
YES - it works again!!
Thank you
Had noticed the script stopped working some 2 weeks ago, but not the slightest clue how to fix.
Really nice to get some help when needing it.
Yep, it was driving me crazy too since a few days, because it worked with JS on. The clue was reverse engineering (tiresome) and I already tried a couples of times trying to figure it out. Until it was the simplest thing in the code sections where it tells, "if everything else fails" XDDD And even it failed
by dumb quotes.
Re: Download YouTube Videos as MP4
Date: August 06, 2019 11:53PM
I didn't know about the mobile version.
Woah, just visited.
Use the alternate page that parses it for a more friendly view posted weeks ago.
www.invidio.us
There is no other hope.
(del)
Date: August 07, 2019 12:33AM
(del)
Edited 1 time(s). Last edit at 08/07/2019 01:02PM by siria.
Re: Download YouTube Videos as MP4
Date: August 07, 2019 12:42AM
Quote
siria
For the moment have kept this part in the right half, because I understand it and still matches:
\"([^\"]+)\"
Confused by [^] , what does it mean? Similar as this allpurpose version? \"(.*?)\"
Reversed meaning. Instead \", all except \" (the bar is for escaping the quotes). But for that reason has more sense to set any character as long as 11 characters (even I left that part), because I have never seen quotes in video ids and you don't have to avoid include the last quote of the video id (in the code is as 'video_id': "11videoidcharacters").
EDIT: updated file above.
Edited 1 time(s). Last edit at 08/07/2019 12:56AM by JohnHell.