Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Youtube blocking mp4's?

Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
04-08-2009 08:40
From: Anya Ristow
Okay, I figured that out. It works. Are you willing to share how you did it?


So far so good! Thank you...

All I've done is one http request further than the previous script:
1. GET request to the video's page, to get the "token"
2. HEAD request to the resulting URL, to see where it redirects to... the result is the big URL with IP and all that junk in it, but so far, it's looking like that URL will work for others
3. GET request to create a tinyurl because that url is too big

Okay I am seriously off to bed <3
_____________________
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
04-08-2009 08:43
Thanks for the info, Day Oh. unfortunately, it only worked once. It's not working anymore.

Edit: More info...

Sometimes the media URL is set to a youtube address, and sometimes it's set to a tinyurl address. of course the youtube address doesn't work. The tinyurl address works if I paste it into the address bar of my browser (it downloads the video), but it doesn't work as a media URL in SL.
_____________________
The Vengeance Studio Gadget Store is closed!

Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
04-08-2009 09:05
Okay, it's working again. In fact it's working much more quickly than it did.

FWIW, I suspect the IP address is there so google can block just the sort of thing we're trying to do. Technically, you're not supposed to access youtube videos through any means other than the website or the embed links they provide. If anyone manages to sell enough TVs that they notice the IP address being used a lot, they'll probably block it.

Ideally, LL would negotiate the right to do this sort of thing, and TV makers would be required to display the youtube logo and provide a means for viewers to go to the youtube website, or whatever else youtube thinks it gets out of embedded videos.

I don't currently plan to sell a youtube player. I just want a not-for-sale player in my store that has a preset list of interesting things to view.
_____________________
The Vengeance Studio Gadget Store is closed!

Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
04-08-2009 12:38
Folloowing Day Oh's suggestions, I was able to get the sucker working. FWIW if you have curl available, you can get the headers that include the "real" url like this:

curl -I http://www.youtube.com/get_video?video_id=<video_id_goes_here>&t=<fetched_t_code_goes_here>&fmt=18

That'll tell you what you have to look for. It's in the "Location" header. Have your PHP script get that, then make a tinyurl and return it, and parse for it in your LSL script.
_____________________
The Vengeance Studio Gadget Store is closed!

ElQ Homewood
Sleeps Professionally
Join date: 25 Apr 2007
Posts: 280
04-08-2009 19:17
lol i just got back to this thread..looks like you got it figured out then, anya, I (again) went another way lol...I found that the greasemonkey plugin for youtube mp4 gets the long url but so far it works for other people too..I'm crossing my fingers
Jorgen Friis
Registered User
Join date: 16 Jul 2006
Posts: 2
04-08-2009 19:18
I don't post here much, in fact ever, but I do make a YouTube player that I use to watch videos with friends which had broken recently. I spent a couple of days trying to figure out the changes and I have come up with a few things.

First off, the old method of getting mp4's via a URL of the form

CODE

http://www.youtube.com/get_video?fmt=22&video_id=xW86DTpWWpM&t=vjVQa1PpcFMj-y4MLa8ylQREJ9d5JEd7qfN_gnaim54=


still works if you put it into a proper web browser. It seems that the difference between then and now is that YouTube is checking the user-agent field of the HTTP header. The SL media player doesn't send user-agent information as videos play directly in the embedded QuickTime player, which also doesn't send user-agent information. This was determined through packet inspection from requests made both in SL and directly through the QuickTime player. So, PHP scripts that request pages from YouTube in order to extract the video_id field for forming the download URL to an mp4 video need to add a valid user agent field to the request. I've tested this and it works.

Second, the mp4 URL redirects to another URL, one that is of the format

CODE

http://v14.lscache1.googlevideo.com/videoplayback?id=06c8ddedf549432d&itag=18&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag&ip=<IP ADDRESS>&signature=5BAD74FBA70F48B5DA2F17C3AD5E8783600C7B9E.77510B77521623D93BD806824BF35618CDDFD2E6&sver=3&expire=1239261698&key=yt1&ipbits=0


This URL is seemingly unique, in that the signature changes every time a request is made, and moreover, it's based on a hash containing at least the IP address of the requester. Ie. substituting any arbitrary IP address into the IP address field will result in an invalid URL. However, any computer can use that URL and download the mp4 version of a video. The only thing is it now becomes pretty much trivial for YouTube to know when someone other than the original requester is downloading a video. What YouTube might do with this information I have no idea.

I'm sure some people have noticed that the direct URL is longer than the 254 character limit on media URL's that SL imposes. That would explain/necessitate the use of a TinyURL type of service to shorten it.

Now, having said all this, it appears that now YouTube has since removed the user-agent check, or has done something else to enable mp4 downloads in SL (and by extension the QuickTime player) via the normal mp4 download URL. Sooooo, I guess this YouTube blocking issue has become old news. Sorry for the wall of text. Maybe it'll be useful in the future, who knows.
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
04-08-2009 19:22
From: ElQ Homewood
I found that the greasemonkey plugin for youtube mp4 gets the long url but so far it works for other people too..I'm crossing my fingers


Those URLs have an expiry date 2 days after you get 'em, so it's not something you can set and forget, or include in a notecard in a product you sell. I haven't confirmed that they actually stop working after they expire, though.
_____________________
The Vengeance Studio Gadget Store is closed!

Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
04-08-2009 19:50
From: Jorgen Friis
now becomes pretty much trivial for YouTube to know when someone other than the original requester is downloading a video. What YouTube might do with this information I have no idea.


Some people have *very* dynamic IP addresses. That is, every request they make comes from a different IP. Even different elements of the same web page. This might be why the following is now true...

From: someone
it appears that now YouTube has since removed the user-agent check, or has done something else to enable mp4 downloads in SL (and by extension the QuickTime player) via the normal mp4 download URL.


Yep, confirmed. After having gone through all that trouble, the old method works again :) The URL the original script creates works as a media URL now. So, the header check and tinyurl thing isn't necessary at them moment. No telling if this is temporary, so I'm not throwing out any code.
_____________________
The Vengeance Studio Gadget Store is closed!

Jorgen Friis
Registered User
Join date: 16 Jul 2006
Posts: 2
04-08-2009 20:02
I retracted my last post entirely. The part about the "real" URL, the one containing the requester's IP address, is still true. It's based on the requester's IP address and changing the IP address argument will break it. However, try to use the normal mp4 download URL that you get on one computer on a computer on a different network and it will fail with a 403 error. So the confusing post I read earlier about the mp4 URL hashing on IP address or something seems to be true.

ie.
http://www.youtube.com/get_video?fmt=22&video_id=zR22IL6WhxE&t=vjVQa1PpcFNUPqgbZqTou4ZdBV-VGIPHKitNuCdfX8M=


will work on the computer that you source it from, but won't work on a computer on a different network :/
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
04-08-2009 20:18
From: Jorgen Friis
I retracted my last post entirely. The part about the "real" URL, the one containing the requester's IP address, is still true. It's based on the requester's IP address and changing the IP address argument will break it. However, try to use the normal mp4 download URL that you get on one computer on a computer on a different network and it will fail with a 403 error.


Well, I could swear it did work just a bit ago, but yeah, back to requiring the IP address to match.
_____________________
The Vengeance Studio Gadget Store is closed!

Jorgen Friis
Registered User
Join date: 16 Jul 2006
Posts: 2
04-08-2009 21:29
These types of URLs

http://v11.lscache5.googlevideo.com/videoplayback?id=62aec528ee43955d&itag=18&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag&ip=<IP ADDRESS>&signature=<LONG STRING OF CHARACTERS>&expire=1239268429&key=yt1&ipbits=


will work (after shortening via TinyURL or similiar scheme), but they contain the original requester's IP address and is hashed/coded to only work if the URL is unchanged. A client with a different IP address can use this URL. The thing is it becomes really obvious that the IP addresses, and hence users, don't match.

The above URLs are retrieved when a request is made on the URL taking the form

http://www.youtube.com/get_video?fmt=<18(SD) OR 22(HD)>&video_id=<SIGNATURE>


As pointed out by Phonema Pelous, the signature calculation has changed so that it only works on the IP address of the requester. Since the signature is generated when a YouTube page is requested, these URLs can no longer be used to stream videos in-world.

I hope I'm not being redundant...
Sarah Nerd
I BUY LAND
Join date: 22 Aug 2005
Posts: 796
04-11-2009 20:08
I'm glad to hear I wasn't the only one who's youtube video loading script stopped working. I have a project that needs to load different youtube videos on command. I was using a script with a whisper script in various prim buttons. People touched a button, it read the Youtube url and then the movie played. I'm clueless when it comes to scripting. If anyone comes up with an updated version of what I have been using or something similar that they don't mind sharing I would greatly appreciate it. I need it pretty badly for an educational project.
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
04-12-2009 00:42
Sarah, your script uses a third-party site that extracts a needed token from the youtube html page and creates a new URL. Problem is, the encoding for that token uses the IP address of that third-party server, so the token doesn't work for you. This is the new behavior that broke things.

The easiest way to fix this is to use another third-party service that has already fixed their code. Youtubemp4 not only works again, but your script can use it without waiting for a response.

Here's a replacement script that seems to work:

integer IsOk()
{
key texture = llList2Key(llParcelMediaQuery([PARCEL_MEDIA_COMMAND_TEXTURE]), 0);
if((texture == NULL_KEY) || (texture == "";))
{
llSay(0, "Not land owner or no media texture";);
return FALSE;
}
else
{
llSetTexture(texture, 4);
return TRUE;
}
}

Browse(string url)
{
llOwnerSay("\"" + url + "\"";);
if(IsOk())
{
llSetText(url, <0.0, 0.0, 1.0>, 0.0);
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_STOP, PARCEL_MEDIA_COMMAND_URL, url, PARCEL_MEDIA_COMMAND_TYPE, "video/*"]);
llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_LOOP]);
}
}

default
{
state_entry()
{
llListen(0, "", "", "";);
}

listen(integer channel, string name, key id, string message)
{
integer index;
if(~(index = llSubStringIndex(message, "http://";)))
{
message = llGetSubString(message, index, -1);
message = llStringTrim(llGetSubString(message, 0, llSubStringIndex(message, " ";)), STRING_TRIM);
if (!llSubStringIndex(message, "http://www.youtube.com/watch?v=";))
{
if ( ~( index = llSubStringIndex( message, "&";)))
{
message = llGetSubString( message, 0, index - 1); // strip extra parameters
if ( ~( index = llSubStringIndex( message, "?v=";)))
{
message = "http://www.youtubemp4.com/video/" + llGetSubString( message, index + 3, -1) + ".mp4";
Browse( message);
}
}
}
else
{
Browse(message);
}
}
}
}

Youtube may be intentionally trying to break these youtube download sites, so there's no telling how long this fix will last.
_____________________
The Vengeance Studio Gadget Store is closed!

Landing Normandy
Proposing 4968
Join date: 28 Nov 2005
Posts: 240
04-14-2009 13:19
Guys, if you're interested or not, I don't know, but yes you're on the right track in following the URL further, and processing this (with cURL for example) and my DTV YouTube player processes URLs fine. It generates a URL that is valid for five hours (YouTube's restriction) but will get a new URL every time. It doesn't rely on TinyURL, and the URLs it generates will fit in to the Parcel Media URL field just fine. I'm also able to get around the "This video is not available in your country" thing, as long as the video is available in the US.

I'm afraid I can't allow the script in to the public domain as it relies on my own web servers to do a little work, and I need the cash from sales to keep the servers running, but at least I can say that yes it is possible, and if you really want to get it working now then DTV can provide you with a working one (advertisement over :D )
_____________________
<VOTE PROPOSITION 4968/>
http://jira.secondlife.com/browse/VWR-4968
For SecondLife Builders who need better mapping for better building
Raina Andel
Registered User
Join date: 17 Jul 2008
Posts: 3
04-17-2009 00:30
I saw a link elsewhere on this forum where someone had cross referenced a 3rd party site to get their videos working, and I took that code and hacked it into the Freeview TV I have (Version 1.2 Webguide (Revision 3))

I've put it up on slx if you want to grab it, or if you want to modify your own code I've included the code changes I made below

Insert at Line 63


string left(string src, string divider) {
integer index = llSubStringIndex( src, divider );
if(~index)
return llDeleteSubString( src, index, -1);
return src;
}

insert at line 535


if (llGetSubString(llToLower(message),11,17)=="youtube";){
string yturl=".youtube.com/watch?v=";
integer ytl=llStringLength(yturl);
integer i=llSubStringIndex(message,yturl);
if (i > 7) {
message="http://www.youtubemp4.com/video/"+left(llGetSubString(message,i+ytl,-1),"&";)+".mp4";
}
}


I'll admit this was a total hack job, but basically this checks the URL provided, if it contains youtube, then it'll break things out, grab the url from youtubemp4.com, and set your parcel media just as the normal Freeview TV would. If the URL doesn't have youtube in it, then it'll connect up as normal.

https://xstreetsl.com/modules.php?name=Marketplace&file=item&ItemID=1393573

if you want the pre-hacked script. Just drag'n'drop into any prim, deed the prim to a group (if required) then click the prim. Menu will appear from there.

PS. This failure is DEFIANTLY caused by the Signature ID on youtube's site now encoding the IP address. All the hacks and stuff previously shown here will work, for 1 person and 1 person only. The other person in the room with you will NOT be able to watch the same video, unless you use a 3rd party site like I have, you tube changes their rules/code.
Infrared Wind
Gridologist
Join date: 7 Jan 2007
Posts: 662
12-14-2009 06:47
Are there any developments on this?

Is there any news with regard to parsing
YouTube Videos URLs for streaming?

I was reformatting the URLs for MP4 download
using my server and a python script and then
feeding the result to an lsl script via http_request
in Second Life.

I hadn't checked playback in-world for a
while until yesterday and saw the script
wasn't working anymore. The python script
still works. I use it download videos
from YouTube in MP4 format locally (with
a PHP script).

Then I saw the new output from YouTube.

For example for the URL:

http://www.youtube.com/watch?v=Go7ceSUFlAc

I'm getting back with the python script:

http://www.youtube.com/get_video?fmt=18
&playback-GMT34/5.a954b1e427b0d46c?iv it=0710
&original=v3.lscache8.c.youtube.com/videoplayback?ip=0.0.0.0
&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor
&algorithm=throttle-factor
&itag=5
&ipbits=0
&burst=40
&sver=3
&expire=1260824400
&key=yt1
&signature=3F35D804D55D9C96C6FC4FCC2ADFC51FD007CA5A.D75B16D21D89B05653309C191ED26E4E67CE15CA
&factor=1.25
&id=a954b1e427b0d46c

The IP came back like that: 0.0.0.0

The good old format was:

http://www.youtube.com/get_video?fmt=18&video_id=Go7ceSUFlAc

Maybe it's game over. :rolleyes:

-r
_____________________
Landing Normandy
Proposing 4968
Join date: 28 Nov 2005
Posts: 240
12-14-2009 07:25
Nope, requires a bit of extra parsing which DTV players are doing OK. However, people have been leaving their players auto-playing when they're not there and YouTube have taken exception to the bandwidth usage and we had to verify ourselves. We're currently taking steps to have the player not send any requests to YouTube unless someone is on the parcel. Otherwise we're working fine
_____________________
<VOTE PROPOSITION 4968/>
http://jira.secondlife.com/browse/VWR-4968
For SecondLife Builders who need better mapping for better building
Abbey Underall
Registered User
Join date: 10 Apr 2006
Posts: 11
01-03-2010 19:49
From: Anya Ristow
The easiest way to fix this is to use another third-party service that has already fixed their code. Youtubemp4 not only works again, but your script can use it without waiting for a response.


It seems http://www.youtubemp4.com is down.

We are having problems with our YouTube player. For a while it would only work arbitrarily - we assumed it was just SL lagging - , but now it's not working at all.

Do you know of any other third-party services, that still work?
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
01-03-2010 20:47
I'm not doing SL scripting anymore, and Landing isn't going to give you anything but teasers that amount to advertisements for his products. Your best bet is probably to contact the maker of your TV and hope he fixes it.
_____________________
The Vengeance Studio Gadget Store is closed!

Abbey Underall
Registered User
Join date: 10 Apr 2006
Posts: 11
01-03-2010 21:34
From: Anya Ristow
I'm not doing SL scripting anymore, and Landing isn't going to give you anything but teasers that amount to advertisements for his products. Your best bet is probably to contact the maker of your TV and hope he fixes it.


Oh. Well I made it actually. And I have been selling it for more than a year. But the script is kinda messy now, because it's been done by two different people.
Personally I'm not anything of a scripter, but I know that the YouTube stream was coming through youtubemp4.com.
Landing Normandy
Proposing 4968
Join date: 28 Nov 2005
Posts: 240
01-03-2010 22:39
From: Anya Ristow
I'm not doing SL scripting anymore, and Landing isn't going to give you anything but teasers that amount to advertisements for his products. Your best bet is probably to contact the maker of your TV and hope he fixes it.
Ha ha, quite right. Ours still works :D
_____________________
<VOTE PROPOSITION 4968/>
http://jira.secondlife.com/browse/VWR-4968
For SecondLife Builders who need better mapping for better building
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-04-2010 08:55
From: Landing Normandy
Ha ha, quite right. Ours still works :D

and this is "scripting tips", not "brag about my product"... assistance with fixing code is what we try to accomplish here... the latter is reserved for places like ad boards and products wanted. please respect that.

we'll pretend you just said "it is still possible to work around" as that's at least encouraging to know.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Abbey Underall
Registered User
Join date: 10 Apr 2006
Posts: 11
01-04-2010 09:34
Seems there is no solution at all.

I doubt Landing's thing would work with our alternative version of YouTube streaming, where all the clips are pre-selected and hardwired into the script.

So if anyone hears about third-party clients, like youtubemp4, up and running - please let me know.

I have a lot of customers who are sad that their TV doesn't work anymore.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
01-04-2010 13:45
Would it work to copy your selected YouTube videos, host them somewhere, and rescript your viewers to point to that site? Since it's a limited and pre-selected range.
Abbey Underall
Registered User
Join date: 10 Apr 2006
Posts: 11
01-04-2010 15:35
From: Innula Zenovka
Would it work to copy your selected YouTube videos, host them somewhere, and rescript your viewers to point to that site? Since it's a limited and pre-selected range.


You mean like, download them from YouTube and maybe load them on a blog or something? Hmm I wonder? I guess it's a matter of whether the host site can run mp4's?

I'll run it by my script "partner". We are kinda winging this as we go along, cause it's a bit like quantum physics to us.
1 2 3