youtube download videos

View: New views
5 Messages — Rating Filter:   Alert me  

youtube download videos

by patrick-189 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

I had a script that I got from openjs for downloading youtube videos,
and it stopped working recently..  It appears that youtube changed
their code a bit...  I did some poking around and found the data that
I need, and it all works fine----- in the console, not in
greasemonkey.

It's hard to tell exactly what youtube is doing, but I am suspecting
they are doing their own sort of 'window.onload' event that happens
after the actual window onload event, and creates their 'yt' class
which holds the parameters that I am looking for.  So, basically if I
go to youtube, and in firebug I type:

yt.config_.SWF_ARGS

I get the params I need...

But, if I put that same thing in a greasemonkey script, it says yt is
undefined...

So, I am just wondering, is there a way around this?  I tried putting
a timeout in the greasemonkey script, but that didn't help... Anyway,
here is the code.

(function() {

        setTimeout(function() { get_video() }, 5000);

        get_video = function() {
                console.log('yes');
                var swfArgs = yt.config_.SWF_ARGS;
                if (swfArgs) {
                        var keys = ["video_id", "sk", "t"];
                        var params = keys.map(function(k) { return k + "=" + swfArgs
[k]; }).join("&");

                        //Create the link
                        var link = document.createElement('a');
                        link.href= "http://www.youtube.com/get_video?" + params;
                        var txt = document.createTextNode("Download this Video");
                        link.appendChild(txt);
                        document.getElementById('watch-player-div').appendChild(link);
                }
        }

})();
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: youtube download videos

by cc-21 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Patrick, a quick note on this (not sending to list).

If I'm not mistaken, this quote from the YouTube TOS explicitly forbids
downloading videos unless there's a download link there, provided by
YouTube (as opposed to by a Greasemonkey script, for example):
> You may access User Submissions for your information and personal use
> solely as intended through the provided functionality of the YouTube
> Website. You shall not copy or download any User Submission unless you
> see a “download” or similar link displayed by YouTube on the YouTube
> Website for that User Submission.
So I suggest you avoid this sort of (apparently) unethical behavior.

On 2009-10-27 22:47, patrick wrote:

> Hi,
>
> I had a script that I got from openjs for downloading youtube videos,
> and it stopped working recently..  It appears that youtube changed
> their code a bit...  I did some poking around and found the data that
> I need, and it all works fine----- in the console, not in
> greasemonkey.
>
> It's hard to tell exactly what youtube is doing, but I am suspecting
> they are doing their own sort of 'window.onload' event that happens
> after the actual window onload event, and creates their 'yt' class
> which holds the parameters that I am looking for.  So, basically if I
> go to youtube, and in firebug I type:
>
> yt.config_.SWF_ARGS
>
> I get the params I need...
>
> But, if I put that same thing in a greasemonkey script, it says yt is
> undefined...
>
> So, I am just wondering, is there a way around this?  I tried putting
> a timeout in the greasemonkey script, but that didn't help... Anyway,
> here is the code.
>
> (function() {
>
> setTimeout(function() { get_video() }, 5000);
>
> get_video = function() {
> console.log('yes');
> var swfArgs = yt.config_.SWF_ARGS;
> if (swfArgs) {
> var keys = ["video_id", "sk", "t"];
> var params = keys.map(function(k) { return k + "=" + swfArgs
> [k]; }).join("&");
>
> //Create the link
> var link = document.createElement('a');
> link.href= "http://www.youtube.com/get_video?" + params;
> var txt = document.createTextNode("Download this Video");
> link.appendChild(txt);
> document.getElementById('watch-player-div').appendChild(link);
> }
> }
>
> })();
> >
>
> ____________________________________________________________________________________
> The Best Rates on Insurance - Compare the Best Rates on Insurance in Less than 3 Mins. Get Insurance Quotes, Compare Plans, and Save Today! Type in Your Zip Code and We Will Match You With the Best Rates on Insurance.
> http://click.lavabit.com/?r=Nzk1NA==
> ____________________________________________________________________________________
>    


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: youtube download videos

by patrick-189 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Ah.. I got it figured out:
(function() {
        window.addEventListener("load", function(event) {
                        var swfArgs = unsafeWindow.yt.config_.SWF_ARGS;

                        if (swfArgs) {
                                var keys = ["video_id", "sk", "t"];
                                var params = keys.map(function(k) { return k + "=" + swfArgs
[k]; }).join("&");

                                //Create the link
                                var link = document.createElement('a');
                                link.href = "http://www.youtube.com/get_video?" + params;
                                var txt = document.createTextNode("Download this Video");
                                link.appendChild(txt);
                                document.getElementById('watch-player-div').appendChild(link);
                        }
                 }, false);

})();

...  But, I read that using unsafeWindow is "bad"..  I am curious how
I can do this without it, because yt still is undefined without it...

-patrick

On Oct 27, 10:47 pm, patrick <patrick99...@...> wrote:

> Hi,
>
> I had a script that I got from openjs for downloading youtube videos,
> and it stopped working recently..  It appears that youtube changed
> their code a bit...  I did some poking around and found the data that
> I need, and it all works fine----- in the console, not in
> greasemonkey.
>
> It's hard to tell exactly what youtube is doing, but I am suspecting
> they are doing their own sort of 'window.onload' event that happens
> after the actual window onload event, and creates their 'yt' class
> which holds the parameters that I am looking for.  So, basically if I
> go to youtube, and in firebug I type:
>
> yt.config_.SWF_ARGS
>
> I get the params I need...
>
> But, if I put that same thing in a greasemonkey script, it says yt is
> undefined...
>
> So, I am just wondering, is there a way around this?  I tried putting
> a timeout in the greasemonkey script, but that didn't help... Anyway,
> here is the code.
>
> (function() {
>
>         setTimeout(function() { get_video() }, 5000);
>
>         get_video = function() {
>                 console.log('yes');
>                 var swfArgs = yt.config_.SWF_ARGS;
>                 if (swfArgs) {
>                         var keys = ["video_id", "sk", "t"];
>                         var params = keys.map(function(k) { return k + "=" + swfArgs
> [k]; }).join("&");
>
>                         //Create the link
>                         var link = document.createElement('a');
>                         link.href= "http://www.youtube.com/get_video?" + params;
>                         var txt = document.createTextNode("Download this Video");
>                         link.appendChild(txt);
>                         document.getElementById('watch-player-div').appendChild(link);
>                 }
>         }
>
> })();
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: youtube download videos

by Anthony Lieuallen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 10/28/09 01:47, patrick wrote:
> .. if I go to youtube, and in firebug I type:
>
> yt.config_.SWF_ARGS
>
> I get the params I need but, if I put that same thing in a
> greasemonkey script, it says yt is undefined...

For security, Greasemonkey scripts intentionally run in a separate
context than content scripts.  One cannot directly access the other.

http://wiki.greasespot.net/XPCNativeWrapper
http://wiki.greasespot.net/Location_hack

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: youtube download videos

by BD-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

They can say whatever they want in their TOS, it doesn't make it legal or ethical for them to make the claims and demands they do, or illegal or unethical for someone to download the videos, especially for personal use.

cc wrote:
Patrick, a quick note on this (not sending to list).

If I'm not mistaken, this quote from the YouTube TOS explicitly forbids 
downloading videos unless there's a download link there, provided by 
YouTube (as opposed to by a Greasemonkey script, for example):
  
You may access User Submissions for your information and personal use 
solely as intended through the provided functionality of the YouTube 
Website. You shall not copy or download any User Submission unless you 
see a “download” or similar link displayed by YouTube on the YouTube 
Website for that User Submission.
    
So I suggest you avoid this sort of (apparently) unethical behavior.

On 2009-10-27 22:47, patrick wrote:
  
Hi,

I had a script that I got from openjs for downloading youtube videos,
and it stopped working recently..  It appears that youtube changed
their code a bit...  I did some poking around and found the data that
I need, and it all works fine----- in the console, not in
greasemonkey.

It's hard to tell exactly what youtube is doing, but I am suspecting
they are doing their own sort of 'window.onload' event that happens
after the actual window onload event, and creates their 'yt' class
which holds the parameters that I am looking for.  So, basically if I
go to youtube, and in firebug I type:

yt.config_.SWF_ARGS

I get the params I need...

But, if I put that same thing in a greasemonkey script, it says yt is
undefined...

So, I am just wondering, is there a way around this?  I tried putting
a timeout in the greasemonkey script, but that didn't help... Anyway,
here is the code.

(function() {

	setTimeout(function() { get_video() }, 5000);

	get_video = function() {
		console.log('yes');
		var swfArgs = yt.config_.SWF_ARGS;
		if (swfArgs) {
			var keys = ["video_id", "sk", "t"];
			var params = keys.map(function(k) { return k + "=" + swfArgs
[k]; }).join("&");

			//Create the link
			var link = document.createElement('a');
			link.href= "http://www.youtube.com/get_video?" + params;
			var txt = document.createTextNode("Download this Video");
			link.appendChild(txt);
			document.getElementById('watch-player-div').appendChild(link);
		}
	}

})();
    
____________________________________________________________________________________
The Best Rates on Insurance - Compare the Best Rates on Insurance in Less than 3 Mins. Get Insurance Quotes, Compare Plans, and Save Today! Type in Your Zip Code and We Will Match You With the Best Rates on Insurance.
http://click.lavabit.com/?r=Nzk1NA==
____________________________________________________________________________________
   
    




  

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---