Go
Not registered? Sign up!

YouTube streaming - stopped working!

Google Translate
330 posts | return to the Setup Problems forum | get the rss feed for this thread

Oct. 23, 2008Derek

was using this:

if (preg_match('/http:\/\/www.youtube.com\/watch\?v=(.*)/', $videoid, $match))
{
$videoid = $match[1];
}

$page = @file_get_contents('http://youtube.com/v/' . $videoid);

if ((preg_match('/&t=(.*?)&/', $http_response_header[5], $match)) || (preg_match('/&t=(.*)/', $http_response_header[5], $match)))
{
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $match[1];
}

header("Location: $url");

It stopped working with youtubes recent update. Any help?

Oct. 23, 2008lostsoul

Same here, I guess we need a formula for this part.

if ((preg_match('/&t=(.*?)&/', $http_response_header[5], $match)) || (preg_match('/&t=(.*)/', $http_response_header[5], $match)))

any ideas anyone?

Oct. 23, 2008Derek

I looked at this page: http://youtube.com/v/vuv8L_QW5Ik

And then looking at the headers it says all of this is the stream:
http://mia-v227.mia.youtube.com/get_video?video_id=vuv8L_QW5Ik&ip=35.95.55.55&signature=A0852A1E1F084561F92302950568FB2A29F20C26.423AF14903A1CEBBC5B9B8AE6AAE8110152AA4F7&sver=2&expire=1224761552&key=yt4&ipbits=2

So are we missing all of this? Maybe this can help someone find the problem because I don't know what I am doing.

Oct. 23, 2008Stryke

on http://videodownloader.ch/index.php it still works. :-(

@Derek: if you enter there your example http://www.youtube.com/watch?v=vuv8L_QW5Ik

it returns only

http://youtube.com/get_video?video_id=vuv8L_QW5Ik&t=OEgsToPDskJRVhqMYqA9tS3KWeADD5Lg

With this, you can still download the movie (At the moment).

Maybe there is a new way at Youtube to create the timestamp in t=xxx

Oct. 23, 2008Derek

How come that site still works but a popular site such as keepvid.com doesn't work?

So this works if I enter it in to stream:
http://youtube.com/get_video?video_id=vuv8L_QW5Ik&t=OEgsToPDskJRVhqMYqA9tS3KWeADD5Lg

But this doesn't work to get other videos:
$page = @file_get_contents('http://youtube.com/v/' . $videoid);

if ((preg_match('/&t=(.*?)&/', $http_response_header[5], $match)) || (preg_match('/&t=(.*)/', $http_response_header[5], $match)))
{
$url = "http://youtube.com/get_video?video_id=".$videoid."&t=".$match[1];
}

So is it not getting the 't' correctly? I'm stumped.

Oct. 23, 2008Derek

This is what I get when printing $http_response_header:

Array ( [0] => HTTP/1.1 303 See Other [1] => Date: Thu, 23 Oct 2008 09:05:39 GMT [2] => Server: Apache [3] => Expires: Tue, 27 Apr 1971 19:44:06 EST [4] => Cache-Control: no-cache [5] => Location: http://youtube.com/swf/l.swf?swf=http%3A//s.ytimg.com/yt/swf/cps-vfl60807.swf&video_id=k7Z0jZZpMOI&rel=1&eurl=&iurl=http%3A//i4.ytimg.com/vi/k7Z0jZZpMOI/hqdefault.jpg&use_get_video_info=1&load_modules=1&hqt=1 [6] => Connection: close [7] => Content-Type: text/plain [8] => HTTP/1.1 200 OK [9] => Age: 2699 [10] => Date: Thu, 23 Oct 2008 08:21:27 GMT [11] => Connection: Keep-Alive [12] => Via: NS-CACHE [13] => ETag: "372-4571e0129e1c0" [14] => Server: Apache [15] => Last-Modified: Wed, 17 Sep 2008 21:18:07 GMT [16] => Accept-Ranges: bytes [17] => Content-Length: 882 [18] => Keep-Alive: timeout=300 [19] => Content-Type: application/x-shockwave-flash )

So it is still using [5] for the data however I don't see the 't' GET variable anywhere.

But when printing $match I get nothing.

Oct. 23, 2008ShaddyShow

Unfortunately now I need to go to cut my hairs, lol, and later I have tennis. But later I will also help you finding a solution, cause I need it. Maybe I have luck and somebody will be faster with the magic code wink

Oct. 23, 2008ShaddyShow

Well, I have a first "help" what you can do to fix the problem a little bit - for the moment - as long as we have no better solution.

To get t, use this code:

$page = @file_get_contents("http://www.youtube.com/watch?v=" . $videoid);
$start=strpos($page,"&t=")+3;
$ende=strpos($page,"&",$start+1);
$t=substr($page,$start,$ende-$start);

This code won't work or videos where the user needs to be registered (for example adult stuff), but for most videos it will work.

This is just a temporary workaround. We still need to find out, how to get the t variable by a better way.

Oct. 23, 2008Derek

So I guess the past few hours of me trying was a waste. wink

Your code is working great, I haven't tested it with videos that have content warnings though.

Oct. 23, 2008ShaddyShow

Sure no waste, Derek - keep on searching.

If a video has a content warning, u won't find the t variable in the code and won't get the video to play.

This is just a temporary workaround to give back SOME functionality. But we want full functionality, right? wink

I need to go to tennis - I hate to do that when I have an open problem. So I will continue later.

Oct. 23, 2008ShaddyShow

All I see yet is that a cps-vfl60807.swf is called... I bet this swf is fetching data from a php or xml file... so I will try to search the source code of this swf later.

Oct. 23, 2008ShaddyShow

I think I made it.

As I told you: the mentioned swf file had the secret. It's fetching the t-virus, sorry, the t-variable from an api. So - let's do the same, eh? wink

$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($url)));
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $t;

Have a nice day.

Oct. 23, 2008Stryke

Ich danke Dir, Ich danke Dir!!! ;-)

Thanks a lot. Works perfect!!!

I think I must start playing tennis again! ;-)

Oct. 23, 2008ShaddyShow

Yeah wink If you wanna see where I use the code, then visit me on www.shaddyshow.com wink

You need to register to get inside - but don't worry, the site is really free - I'm the webmaster.

Oct. 23, 2008ShaddyShow

Besides: the change happened at about 08:20 CET.

I run a script every 10 minutes, so that's quite precise wink

Oct. 23, 2008Bouke Regnerus

It works!, but only with the old player :(

Oct. 23, 2008Mikey

You guys rock! I have been trying to fix this issue for 3 hours.... THANK YOU! THANK YOU!

I will name my first kid after you, Shaddy. Shaddy McCalister. It has a nice sound. wink

Thanks again!

Oct. 23, 2008ShaddyShow

Bouke, I see you registered on ShaddyShow - and yes, I use the old player.

But I have the new player in store and I will test it in some moments for you.

Oct. 23, 2008ShaddyShow

No, of course it's working.

I made a test page here: http://www.shaddyshow.com/experimental/flvplayer.php

On this page are 3.14, 4.1 and 4.2 player.

Bouke, I guess I know what is your problem - and maybe the problem of other people, too. So I give you full instructions again.

a) Make a PHP file (for example: youtubefix.php) with this content:

$videoid=$_GET["videoid"];
$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($url)));
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $t;
header("Location: $url");


b) Call your FLV Player like this:

file=youtubefix.php?videoid=xyz
type=flv


c) Enjoy your evening

Oct. 23, 2008Bouke Regnerus

ok, tanks!

Oct. 23, 2008Bouke Regnerus

it works!, but is workt even better if you add: &fmt=18 (you get the high quality video)

$videoid=$_GET["videoid"];
$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($url)));
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $t . "&fmt=18";
header("Location: $url");

Oct. 23, 2008Webastah

Thanks for the fix Shaddy.

However, has anyone got this to work with a playlist? A singular track works fine, but when I try and build a playlist I'm having problems. If I try to either use the youtubefix.php?videoid=xyz link for each track source in the playlist or loop through each video, do the lookup, and then use those http://www.youtube.com/get_video.php?video_id=XXXXX&t=XXXXXXX as the source the player constantly spins and nothing ever loads.

It seems that the flashvars type=flv isn't happy with trying to determine how to handle this playlist. I've tried everything from changing the type to youtube, video, http, and just removing it all together, but all result in the error "unsuitable media files".

Anyone get a playlist of youtube videos to work? Or will I have to hook in to the Javascript events like LOAD to manually add individual tracks to the playlist? (Although this really stinks since all of the play controls would have to be rewritten and hooked in).

Oct. 23, 2008ShaddyShow

@ Bouke: ah, thanks for the hint... can you give one example video which has two different qualities?

@ Webastah: sure I use playlists like this... come to my site.
Well, for a playlist you can't use the flashvar TYPE wink The type of a playlist is? XML wink And as your file will have the ending .xml you don't need the flashvar TYPE when addressing an xml playlist wink
But, you need the TYPE in the playlist itself like this: <meta rel="type">flv</meta>

The solutions about all this stuff were the same hard for me in the start. I was searching this forum and and down till I finally found how to do it. I'm happy that today I can give back my experience wink

Oct. 24, 2008HolmesSPH

I have tried the PHP script works fine, however when I set the file flashvar to query my new page, (which works if I use it in the browser) the JW player (4.2) loads a preview and that's it.. When I click play it just sits there and buffers indefinitely... Any ideas?

Oct. 24, 2008Derek

@HolmesSPH: Try setting the 'type' flashvar to 'video'.

As long as we are all showcasing our sites, here is mine: http://www.gameanyone.com/

I haven't switched my code to the new one (the one to get past 18+ block), but I don't think any of my videos have that issue anyways.

Great work again ShaddyShow!

Oct. 24, 2008ShaddyShow

Holmes, post us your code... u surely did some mistake. Are u giving the rigth videoid to the script? And are u having type=flv assigned?

Oct. 24, 2008Bouke Regnerus

@ShaddyShow: look at this url: http://howto.wired.com/wiki/Watch_Higher_Quality_YouTube_Videos.

Oct. 27, 2008paranoiaparadise

@ShaddyShow: Your script: "" works great, but when I try to use it on my server, it doesn't work. Are you sure, that your script is like this:

<?php
$videoid=$_GET["videoid"];
$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($url)));
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $t;
header("Location: $url");
?>

If not, please post your script. Thanks in advance.

Oct. 29, 2008dana

<?php
$videoid=$_GET["videoid"];
$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($url)));
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&amp;t=" . $t;
header("Location: $url");
?>

Oct. 31, 2008paranoiaparadise

The script works fine, but not in "Google Chrome". Any suggestions?

PS: If you don't want to use Google Chrome, check this one: Iron (http://www.srware.net/en/software_srware_iron.php) //
SRWare Iron: The browser of the future - based on the free Sourcecode "Chromium" - without any problems at privacy and security

Nov. 03, 2008ShaddyShow

The script is run in PHP, so its run on the SERVER.

Wouldnt know why it should not run in any browser.

Nov. 17, 2008paranoiaparadise

yeah sorry - it didn't work, but a day later it did - maybe a caching error. Everything works just fine. Thanks for the support, ShaddyShow.

Nov. 23, 2008waswew

seafsegadsrgdsgdsgrdgdg

Nov. 24, 2008Nivea

I am trying to stream youtube videos. I created a youtubefix.php file in my jw_player.

I also added a file in my videos file similar to this but with the video id from youtube http://youtube.com/get_video?video_id=vuv8L_QW5Ik&t=OEgsToPDskJRVhqMYqA9tS3KWeADD5Lg.

I then went into my playlist and added this
<track>
<creator>Many Four Day Work Week</creator>
<title>Many Companies Considering Four Day Work Week</title>
<location>templates/newsline2/jw_player/videos/many4day.flv</location>
<image>templates/newsline2/jw_player/thumbs/many4day.gif</image>
<info>templates/newsline2/jw_player/videos/many4day.flv</info>
</track>
and what I am getting on my frontpage is video is loading please wait.

Am I missing something in terms of getting youtube videos to play? Any help would be greatly appreciated.

Nov. 24, 2008kLink

 
@Nivea,

"I created a youtubefix.php file in my jw_player."You can't create a PHP file in your JW Player.

Stop the nonsense talk and post a link to your test page if you want help.

Nov. 25, 2008ShaddyShow

Nivea... first make it possible to play ONE video with the YouTube fix explained in http://www.jeroenwijering.com/?thread=13704.

If you made it with one video - THEN start looking on the playlists, not before.

Nov. 25, 2008Nick

I get an error "0: error #2048" and the file doesn't play, just an exlamation mark in the middle.

here's my code

<script type='text/javascript' src='http://www.fortherestless.com/embed/swfobject.js'></script>


<div id='preview'>TO BE REPLACED</div>
<script type='text/javascript'>
var s1 = new SWFObject('http://www.fortherestless.com/embed/player.swf','player','640','360','9');
s1.addParam('allowfullscreen','true');
s1.addParam('allowscriptaccess','always');
s1.addParam('flashvars','file=http://www.fortherestless.com/embed/fix.php?videoid=4LCN-kM5VYs');
s1.addVariable('type=flv');
s1.write('play-youtubeHQ');
</script>


I'm assuming there's something wrong with it but I don't know what.

the fix.php is this:


<?php
$videoid=$_GET["videoid"];
$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($url)));
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&amp;t=" . $t . "&amp;fmt=18";
header("Location: $url");

?>

Nov. 25, 2008ShaddyShow

s1.addVariable('file',http://www.fortherestless.com/embed/fix.php?videoid=4LCN-kM5VYs');
s1.addVariable('type','flv');

What u made was comlpetely weired wink

Nov. 26, 2008Marc J

This is excellent - thanks! I got it working with a single video but am struggling with an XML playlist :(

so.addVariable('type','flv');

worked with my single video, but where do I put this in my XML file? At the start, or in each entry (I tried both, but neither seemed to work).

Here's my XML file: -

<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>XSPF Example Playlist</title>
<info>http:/xspf.org/xspf-v1.html</info>
<trackList>

<track>

<title>Video 1</title>
<creator>26th November, 2008</creator>
<location>youtubefix.php?videoid=xxxxxxxxxxx</location>
<meta rel="type">flv</meta>
</track>

<track>
<title>Video 2</title>
<creator>6th November, 2008</creator>
<location>youtubefix.php?videoid=xxxxxxxxxxx</location>
<meta rel="type">flv</meta>
</track>

</trackList>

</playlist>

Any pointers as to where I'm going wrong? Using version 3.16 (I think).

Nov. 26, 2008kLink

@Marc J,

It would be helpful if you would post your player code and a link to your test page.

Nov. 27, 2008Marc J

Single Video: http://www.loweringprices.com/videotest/single.php

XML Playlist: http://www.loweringprices.com/videotest/playlist.php

For the Playlist, the player code includes (view source above to see it all): -
so.addVariable('file','http://www.loweringprices.com/videotest/youtubeplaylist.xml');
so.addVariable('type','xml');


youtubefix.php: -

<?php
$videoid=$_GET["videoid"];
$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($url)));
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&amp;t=" . $t . "&amp;fmt=22";
header("Location: $url");
?>


And youtubeplaylist.xml :-

<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>XSPF Example Playlist</title>
<info>http:/xspf.org/xspf-v1.html</info>
<trackList>

<track>

<title>Where the Hell is Matt</title>
<creator>Matt Harding</creator>
<location>youtubefix.php?videoid=zlfKdbWwruY</location>
<meta rel="type">flv</meta>
</track>

<track>
<title>Womanizer</title>
<creator>Britney Spears</creator>
<location>youtubefix.php?videoid=gZSLIq6YiRY</location>
<meta rel="type">flv</meta>
</track>

</trackList>

</playlist>


Any help greatly appreciated!

Nov. 27, 2008kLink

The v3.x player supported file types are: http://code.jeroenwijering.com/trac/wiki/Flashvars3#Externalcommunication

So... send this off to "stray electron land":so.addVariable('type','xml');

Your player code, player version, and playlist is fine for the LQ YouTube videos.

The HQ youtube videos are MP4, so you need to upgrade to the v4.x player, at least Flash 9.48 (might as well go for v10.0.12.36), and update your playlist to specify a v4.x player supported type from here: http://code.jeroenwijering.com/trac/wiki/FlashVars#Fileproperties>meta rel='type'>video</meta>

Nov. 27, 2008kLink

Starter code for a v4.x player:
<script type="text/javascript">
  var so = new SWFObject('player.swf', 'mediaplayer', '640', '590', '10.0.12', '#ffffff', true);
      so.addParam('allowscriptaccess', 'always');
      so.addParam('allowfullscreen',   'true');
      so.addVariable('file',           'http://www.loweringprices.com/videotest/youtubeplaylist.xml');
      so.addvariable('playlist,        'bottom');
      so.addVariable('playlistsize',   '120'); // two tracks
      so.addVariable('autostart',      'true');
      so.write('flashcontent');
</script>

Nov. 27, 2008Marc J

Thanks wink

Now I have a different problem: www.loweringprices.com/videotest/test.php

I upgraded to FW FLV Player 4.2, which include the yt.swf file which I put in the same folder as player.swf.

My youtubefix.php remains the same as before: -
<?php
$videoid=$_GET["videoid"];
$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($url)));
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&amp;t=" . $t . "&amp;fmt=22";
header("Location: $url");
?>


My test.xml file:
<?xml version='1.0' encoding='UTF-8'?>
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
<trackList>
<track>
<title>Where the Hell is Matt</title>
<location>youtubefix.php?videoid=zlfKdbWwruY</location>
<image>http://img.youtube.com/vi/zlfKdbWwruY/2.jpg</image>
<meta rel='type'>video</meta>
</track>
<track>
<title>Womanizer</title>
<location>youtubefix.php?videoid=gZSLIq6YiRY</location>
<image>http://img.youtube.com/vi/gZSLIq6YiRY/2.jpg</image>
<meta rel='type'>video</meta>
</track>
</trackList>
</playlist>


My player code: -

var so = new SWFObject("mediaplayer/player.swf", "mediaplayer", "640", "470", "10.0.12", "#ffffff", true);
so.addParam("menu", "false");
so.addVariable('playlist','bottom');
so.addVariable('playlistsize','120'); // two tracks
so.addVariable('file','http://www.loweringprices.com/videotest/test.xml');
so.addVariable('autoscroll','true');
so.addVariable('autostart','true');
so.write("flashcontent");


What am I doing wrong? Do you have a working example of a playlist for HQ YouTube videos?

Nov. 27, 2008Marc J

BTW single video still works with 4.2 player using the same youtubefix.php : www.loweringprices.com/videotest/single_42.php

Nov. 27, 2008kLink

You don't need the YouTube proxy YT.SWF unless you are going to get YouTube videos through the YouTube API.

Are you sure that your host allows external file access?

For trouble shooting and testing, you can always do this:
<?php

// call with: http://my.domain.com/path/youtubefix.php?videoid=zlfKdbWwruY

$videoid = $_GET['videoid'];
$url     = "http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t       = trim(strip_tags(@file_get_contents($url)));
$url     = "http://www.youtube.com/get_video.php?video_id=$videoid&t=$t&fmt=22";

//debug
print "Video URL: $url"; exit;

header("Location: $url");

?>

If you get a video file URI, comment out the print statement.

Your player code and your playlist look OK.

Nov. 28, 2008Marc J

See http://www.loweringprices.com/videotest/youtubefix_test.php?videoid=zlfKdbWwruY

I don't think there's anything wrong with the content or execution of youtubefix.php as the single video works, which uses the same youtubefix.php. It must be the player code or playlist???

Nov. 28, 2008kLink

Your youtubefix.php script:
<?php

// call with: http://my.domain.com/path/youtubefix.php?videoid=zlfKdbWwruY

$videoid = $_GET['videoid'];
$url     = "http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t       = trim(strip_tags(@file_get_contents($url)));
$url     = "http://www.youtube.com/get_video.php?video_id=$videoid&t=$t&fmt=22";

//debug
//print "Video URL: $url"; exit;

header("Location: $url");

?>


Your playlist_MarcJ.xml playlist:
<?xml version='1.0' encoding='UTF-8'?>
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
  <trackList>
    <track>
      <title>Where the Hell is Matt</title>
      <location>youtubefix.php?videoid=zlfKdbWwruY</location>
      <image>http://img.youtube.com/vi/zlfKdbWwruY/2.jpg</image>
      <meta rel='type'>video</meta>
    </track>
    <track>
      <title>Womanizer</title>
      <location>youtubefix.php?videoid=gZSLIq6YiRY</location>
      <image>http://img.youtube.com/vi/gZSLIq6YiRY/2.jpg</image>
      <meta rel='type'>video</meta>
    </track>
  </trackList>
</playlist>


Your MarcJ.html HTML document:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">

  <head>

    <title>Marc J</title>

    <script type="text/javascript" src="swfobject.js"></script>

  </head>

  <body>

    <div id="flashcontent" class="flashcontent">
      <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Flash Plugin to see this video.</a>
    </div>
    <script type="text/javascript">
      var so = new SWFObject('player-4.2.90.swf', 'mediaplayer', '640', '470', '9.0.124', '#ffffff', true);
          so.addParam('allowscriptaccess',   'always');
          so.addParam('menu',                'false');
          so.addVariable('playlist',         'bottom');
          so.addVariable('playlistsize',     '120'); // two tracks
          so.addVariable('file',             'playlist_MarcJ.xml');
          so.addVariable('autostart',        'true');
          so.write('flashcontent');
    </script>

  </bocy>

</html>


Works perfectly for me!

Anythng else is a local problem...

                                                                                     grin

Nov. 28, 2008Marc J

Thanks for taking the time to try and resolve this, it's much appreciated wink

Must be local, I'll dig further. All I can think of now is that register globals is off for PHP?

Nov. 28, 2008Marc J

Ok, I cracked it wink

The <location> in the XML file needed the domain added, so instead of:-
<location>youtubefix.php?videoid=zlfKdbWwruY</location>


it needed: -
<location>http://www.loweringprices.com/videotest/youtubefix.php?videoid=zlfKdbWwruY</location>


And it worked wink

However, a new problem has surfaced. I hardcoded the &fmt=22 into the youtubefix.php as suggested earlier in the thread. The second of my video examples (Womanizer) has no &fmt=22 video, it has &fmt=18 instead. I figured this was an easy fix: -

youtubefix.php: -
<?php
$videoid=$_GET["videoid"];
if (isset ($_GET["format"])) {
$format=$_GET["format"];
}
$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($url)));
if (isset ($format)) {
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&amp;t=" . $t . "&amp;fmt=" . $format;
} else {
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&amp;t=" . $t;
}
header("Location: $url");
?>


Fully expecting that any &fmt=xx variable (if passed in the URL along with the video code) would add the relevant format to the final URL (so I could mix and match fmts in the playlist). This only resulted in the low quality video being shown for all videos, though :(

Any ideas why this would be? I testing using the print url method from earleir and the URLs seemed OK....

Nov. 28, 2008Marc J

Oops, I should have said the format is being passed in the <location> part of the XML file, like this: -

<?xml version='1.0' encoding='UTF-8'?>
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
<trackList>
<track>
<title>Where the Hell is Matt</title>
<location>http://www.loweringprices.com/videotest/youtubefix.php?videoid=zlfKdbWwruY&format=22</location>
<image>http://img.youtube.com/vi/zlfKdbWwruY/2.jpg</image>
<meta rel='type'>video</meta>
</track>
<track>
<title>Womanizer</title>
<location>http://www.loweringprices.com/videotest/youtubefix.php?videoid=gZSLIq6YiRY&format=18</location>
<image>http://img.youtube.com/vi/gZSLIq6YiRY/2.jpg</image>
<meta rel='type'>video</meta>
</track>
</trackList>
</playlist>

Dec. 01, 2008luis alarcon

there is a error in youtubefix

change
$url = "http://www.youtube.com/get_video.php?video_id=$videoid&t=$t&fmt=22";

for

$url = "http://www.youtube.com/get_video.php?video_id=$videoid&t=$t&fmt=18";

Dec. 01, 2008Marc J

Excellent, thanks Luis - works perfectly now wink

My complete youtubefix.php is now: -

<?php
$videoid=$_GET["videoid"];

if (isset ($_GET["format"])) {
$format=$_GET["format"];
}

$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($url)));

if (isset ($format)) {
$url = "http://www.youtube.com/get_video.php?video_id=$videoid&t=$t&fmt=$format";
} else {
$url = "http://www.youtube.com/get_video.php?video_id=$videoid&t=$t";
}

header("Location: $url");
?>


And videos are called in the playlist by using: -

<location>http://www.mydomain.com/youtubefix.php?videoid=zlfKdbWwruY&format=22</location>

:)

Dec. 03, 2008meh

hey guys,

anyone having issues trying to render the flash player by using swfObject? everything seems to work fine if i use the embed tag but as soon as i try to use swfObject the player just seems to sit there waiting for the file to stream :(

works fine


<embed src='#application.url.webroot#/farcryradiostar/mediaplayer.swf' flashvars='file=http://#cgi.server_name#/farcryradiostar/youtubeFix.cfm?videoID=#stObj.fileID#&type=flv' type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="#stObj.width#" height="#stObj.height#"></embed>


fails


<div id="player#UID#">This text will be replaced</div>
<script type="text/javascript">
var so = new SWFObject('#application.url.webroot#/farcryradiostar/mediaplayer.swf','#UID#','#stObj.width#','#stObj.height#','8');
so.addParam('allowscriptaccess','always');
so.addVariable('flashvars','file=http://#cgi.server_name#/farcryradiostar/youtubeFix.cfm?videoID=#stObj.fileID#');
so.addVariable('type','flv');
so.write('player#UID#');
</script>


my coldfusion of youtubeFix.cfm seems to work fine, successfully grabs the t var and works without any issues with the embed, the swfobject call looks pretty standard, works in other cases, just not when trying to render a youtube file, any ideas?

Dec. 03, 2008meh

fyi i have no problems with the flashplayer generally, this is issue is isolated to youtube videos for me, thanks

Dec. 03, 2008kLink

flashvars isn't a JW FLV Media Player flashvar, it is an Adobe Flash Player parameter.

so.addParam('flashvars','file=http://#cgi.server_name#/farcryradiostar/youtubeFix.cfm?videoID=#stObj.fileID#');

Don't put any so.addVariable(someflashvar... before the so.addParam('flashvars',... because they will get wiped out by the so.addParam('flashvars',...

You should also urlencode ( ? = & ) if they are used in the file flashvar URI.

Dec. 03, 2008meh

kLink Thank you!!

have updated to jw's flashvar (what a nub!) and urlencoded the url as well, all working now, thanks again!

Dec. 04, 2008UnrealRG

I tried using youtubefix.php to no avail. In fact, I believe my host (http://home.cfl.rr.com) does not allow php. Is there a simple test I can run to see if I can use ANY php? If so, please post the code and I'll test. Thanks.

UPDATE: Nevermind...I tried the most simple php...

<?php phpinfo(); ?>

and it did not work. I also spoke with RoadRunner tech support who confirmed they do not provide php on their servers. :(

If anyone knows a way to get HD (fmt=22) YouTube videos in the JW Player without using php I'd be interested. I think I'm going to switch web host provider too, so I'll take any recommendations on simple (inexpensive) web hosts that provide php. Thanks.

Dec. 05, 2008ustas

Marc J

Your youtubefix works fine with QuickTime 7 too. For test I used MakeRefMovie version 5.0 for Win (free tool by Apple) and previous version of your script (fmt=18).

MakeRefMovie.exe > Add Url > Save as yourvideo.mov. .

Dec. 05, 2008kLink

works for fmt=35 640x360 MP4 and fmt=22 1280x720 MP4 plus fmt=6 and fmt=18

Dec. 06, 2008Subfighter

i can not get this work and i run out of ideas :(

here is what it shows me in FIREBUG and it look correct to me

<script type="text/javascript">
1
2var s1 = new SWFObject('http://www.subfighter.tv/components/com_jtube/assets/swf/player.swf','mpl','560','440','9')
3s1.addParam('allowscriptaccess','always')
4s1.addParam('allowfullscreen','true')
5s1.addVariable('autostart','true')
6s1.addVariable('stretching','fill')
7s1.addVariable('skin','http://www.subfighter.tv/components/com_jtube/assets/swf/skins/Bekle/overlay.swf')
8s1.addVariable('file','http://www.subfighter.tv/tmp/jw/youtubefix.php?videoid=w_kV_zE0HVo=flv')
9
10s1.write('player1')
11
</script>


here is the page of the video

http://www.subfighter.tv/index.php?option=com_jtube&view=video&id=2434

all thats happens is the SPINNING loading emblem just keeps going in circles?????

Dec. 06, 2008ustas

=flv'
I do not use SWFObject, I prefer simple XHTML. It is my example for single YT video and it works.

<param name="flashvars" value="file=http://www.mysite/upload/youtubefix.php?videoid=w_kV_zE0HVo&amp;type=video" />

So I think =flv is wrong. Try =video or &type=video

Dec. 07, 2008Subfighter

loaded from the xml playlist then it worked correctly

Dec. 08, 2008test

.mp4 youtube.com -> 4.2 player - it not worked correctly (bitreit?!)

test - http://www.dulski.pri.ee/deadparker
--------

Dec. 08, 2008ustas

2 test
???

Dec. 08, 2008test

under the high bitrate it doesn't work, the video disappears

Dec. 10, 2008Veoh

@ShaddyShow

I have a problem i did everything as you told

i made the youtubefix.php file
<?php
$videoid=$_GET["videoid"];
$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($url)));
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $t;
header("Location: $url");
?>


its not working.

its working. i see that many people had this problem. can you please explain what is wrong ?

what is wrong ?

thank you

Dec. 10, 2008Soso

Can Someone Just Post download Link Of Youotubefix.php file that works ?

Be nice to see something that works and understand and not just that everyone give his thought why its not working.


if Anyone made that and its working for him post the link of the file please for peaple

Dec. 13, 2008kwynns

have yall noticed that the quality isn't quite as good?

I upload some HD videos...

when I view both from my site, and then on youtube I notice a slight bluring...

any idea how to avoid this?

Otherwise props to you guys...good stuff...

here is the one embedded in my site:

http://mybeardhurts.com/youtube/youtube.html

youtube:

http://www.youtube.com/watch?v=ybX3Cj5JXiQ&fmt=22

sorry for the awkward videos...I swear it makes more sense with the audio finished (they are up just for testing)

Dec. 13, 2008kLink

@kwynns,

There are specialized forums and blogs that have instructions for preparing your videos for upload to YouTube so that you get the best quality video and sound. Google has them at "YouTube upload quality" or similar search terms.

Dec. 14, 2008kwynns

klink,

You misunderstood me...

it's the same source as they are both coming from youtube...

the one going through the JW player with this process looks worse (both have HD on)...

do you know what might cause this?

Dec. 14, 2008kLink

@kwynns,

I vaguely recall that Jeroen mentioned in a post that only the LQ video is available through the YouTube API.

To get the HQ video in fmt=18, 22, or 35, you have to use a script like the one posted above and add the fmt= parameter to the URI. Make sure that your host allows external file access (most don't) or the script won't work.

<?php

// call with: http://www.mydomain.com/path/YouTube_Multi-Format.php?v=K2_U1kbIcJQ&fmt=18
// fmt=6  HQ FLV   480x360
// fmt=18 HQ MP4   480x270
// fmt=22 HQ MP4  1280x720
// fmt=35 HQ MP4   640x360

$videoid = (isset($_GET['v']))   ? strval($_GET['v'])   : 'K2_U1kbIcJQ';
$fmt     = (isset($_GET['fmt'])) ? intval($_GET['fmt']) : '';
$uri     = "http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t       = trim(strip_tags(@file_get_contents($uri)));
$uri = "http://www.youtube.com/get_video.php?video_id=$videoid&t=$t&fmt=$fmt";

//...debug
/*
$headers = get_headers($uri);
print "<pre>\n";
print "URI: $uri\n" ;
print_r($headers);
print "\n</pre>\n";
exit;
*/
//...debug

header("Location: $uri");

?>

Dec. 15, 2008kwynns

@kLink

wow...am I really explaining it this badly?

I am using the script above...which is why I posted the question here...

when I use the script while streaming "fmt=22" I notice the quality isn't quite as good as while viewing on youtube's site...

My site, with THIS script is located here (like in my first post):

http://mybeardhurts.com/youtube/youtube.html

and to view from youtube's site...here:

http://www.youtube.com/watch?v=ybX3Cj5JXiQ&fmt=22

the youtube version is sharper...for sure...

and klink...I appreciate you responding...but it might help to pay attention and view the 2 videos first...

Dec. 15, 2008Marc J

@kwynns,

I can't notice any difference in quality to be honest, but if you can then the reason for it may be that on your site the video is being resized, notice the pillarboxing going on either side of your video.

This is because you haven't taken the height of the control bar into consideration with the size of your flash movie. Try making your size 640 x 392, as your control bar seems to be 32 high...

Dec. 15, 2008kLink

@kwynns,

If you want the FREE, VOLUNTEER help that is available here, it is helpful to take a few extra seconds to explain things in detail. Your post on the 15th, immediately above, is the first post where you stated that you were using the script and fmt=22.

· And I am paying attention.

· And I can't read minds (and I am glad that I can't).

· And I did watch your videos.

· And I have the privilege of ignoring AHs.

Looking at you page code, there is no way that I could tell that you were using the fmt=22 in the script.so.addVariable('file','http://www.mybeardhurts.com/youtube/youtubefix.php?videoid=ybX3Cj5JXiQ&skin=stylish.swf');

No lecturing needed or appreciated.

Your player code is using some v3.x player flashvars. Please review the v4.x player supported flashvars here:

      http://developer.longtailvideo.com/trac/wiki/FlashVars

Note that some flashvars are read-only, so there's no point in using them in your player embedding code.
<script type="text/javascript">
  var so = new SWFObject('player.swf', 'mediaplayer', '640', '360', '9', '#000000', true);
      so.addParam('allowscriptaccess', 'always');
      so.addParam('menu',              'false'); // only permitted if you hold a valid license for a v4.x player
      so.addParam('allowfullscreen',   'true');
      so.addVariable('width',          '640'); // read-only
      so.addVariable('height',         '360'); // read-only
      so.addVariable('displayheight',  '360'); // v3.x flashvar
      so.addVariable('file',            encodeURIComponent('http://www.mybeardhurts.com/youtube/youtubefix.php?videoid=ybX3Cj5JXiQ')); // file URIs containing the symbols " ? + & " must be urlencoded
      so.addVariable('skin',           'stylish.swf');
      so.addVariable('type',           'flv'); // incorrect type
      so.addVariable('type',           'video');
      so.addVariable('autoscroll',     'true'); // v3.x flashvar
      so.addVariable('autostart',      'true');
      so.write('flashcontent');
</script>



Since your video has a native size of 1280x720, your player dimensions should be 1280x752, allowing for the control bar, which is 32px in the skin that you are using So either re-size your player or your video.

It's never a good idea to re-size on the client. It wastes bandwidth, creates double or triple traffic, results in video quality degradation, and is very CPU intensive.

                                                                                      grin

Dec. 20, 2008kwynns

@Klink sorry man...I am just fussy that my video is fuzzy...

and it still is...it's only noticeable in fullscreen...

here is my php:

"<?php
$videoid=$_GET["videoid"];
$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($url)));
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $t . "&fmt=22";
header("Location: $url");

?>"

And here is my embed...
" <script type="text/javascript">
var so = new SWFObject("player.swf", "mediaplayer", "860", "512", "#000000", true);
so.addParam("allowscriptaccess", "always");
so.addParam("menu", "false");
so.addParam('allowfullscreen','true');
so.addVariable('file','http://www.mybeardhurts.com/youtube/youtubefix.php?videoid=ybX3Cj5JXiQ&skin=stylish.swf');
so.addVariable('type', 'video');
so.addVariable('autoscroll','true');
so.write("flashcontent");
</script> "

thanks a ton for your help...and make sure you look at the difference in fullscreen...

youtube:
http://www.youtube.com/watch?v=ybX3Cj5JXiQ&fmt=22
through my site:
http://mybeardhurts.com/youtube/youtube.html

Dec. 20, 2008kLink

When I display your video from YouTube in the JW FLV Media Player in the proper size (1280x720) and fullscreen it, it looks just as good as your video from YouTube in the YouTube player fullscreened.

I'm judging by the label on the water bottle near the bottom, about one-quarter of the way from the left side.

You can't re-size on the client (to 860x480) and expect the video quality to be as good as the natively sized video. If you want to display your video at 860x480, you should size it to that. However, YouTube doesn't have a format that size.

Try this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">

  <head>

    <title>mybeardhurts - JWMP v4.3.x - swfobject v2.1</title>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>

    <script type="text/javascript">
      var flashvars =
      {
        file:                  encodeURIComponent('youtubefix.php?videoid=ybX3Cj5JXiQ&fmt=22'),
        type:                 'video',
        shuffle:              'false',
        repeat:               'true',
        skin:                 'stylish.swf',
        stretching:           'none',
        frontcolor:           '86C29D', // text & icons                  (green)
        backcolor:            '849BC1', // playlist background           (blue)
        lightcolor:           'C286BA', // selected text/track highlight (red)
        screencolor:          'FFFFFF', // screen background             (black)
        quality:              'true',
        autostart:            'true'
      };

      var params =
      {
        allowfullscreen:      'true',
        allowscriptaccess:    'always',
        bgcolor:              '#FFFFFF'
      };

      var attributes =
      {
        id:                   'playerId',
        name:                 'playerId'
      };
      
      swfobject.embedSWF('player-4.3.131.swf', 'player', '1280', '752', '9.0.124', false, flashvars, params, attributes);
    </script>

  </head>

  <body>

    <div id="playercontainer" class="playercontainer">
      <a id="player" class="player" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Flash Plugin to see this video.</a>
    </div>
    
  </body>

</html>

Dec. 22, 2008kwynns

If that's the case then it doesn't really make sense to embed in a webpage as that's way too big...

Do you know how youtube embeds at a smaller size and still retains the high quality for full screen?

I was basically copying youtube by picking that particular size, as that's how they embed their hd video on their site now...

Dec. 22, 2008kwynns

can you just size the player container div?

Dec. 22, 2008andersen

can you just size the player container div? yes...

please see - http://www.longtailvideo.com/support/tutorials/Javascript-API-Examples

and find examples like
http://home5.inet.tele.dk/nyboe/flash/mediaplayer4/JW_API_xmpl_2-1-1-0.html
and - http://home5.inet.tele.dk/nyboe/flash/mediaplayer4/JW_API_xmpl_2-1-2-0.html

please note the examples uses swfobject v.2.1 - http://code.google.com/p/swfobject/

Dec. 25, 2008Soso Jana

I will Say That it worked for me

Thank you very Much !

<embed src='http://www.***.co.il/theme/default/player.swf' width="688" height="408" flashvars='file=http://www.***.co.il/youtubefix.php?videoid={player.videoid}&fmt=18&type=flv' type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true"></embed>

and youtubefix.php file

It is working great with my vebsite video gallery

Jan. 02, 2009ytnotworking

"$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$id";
$t = trim(strip_tags(@file_get_contents($url)));
$url = "http://www.youtube.com/get_video.php?video_id=" . $id . "&t=" . $t . "/";"

is not working, made a check at file_get_contents($url) and returns this

"2Bad parameter format. For XML-RPC calls, a single struct parameter is required."

Any idea how to solve this?

Jan. 02, 2009Terry

you making BIG mistake by / after t parmeter

is suposed to be fmt

$url = "http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$id";
$t = trim(strip_tags(@file_get_contents($url)));
$url = "http://www.youtube.com/get_video.php?video_id=$id&t=$t&fmt=18";

Jan. 02, 2009discoInferno

createPlayer('http://www.mysite.com/path/playlist.xml');
<?xml version='1.0' encoding='UTF-8'?>
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
<trackList>
<track>
<creator>Creator</creator>
<title>Title</title>
<location>http://www.youtubemp4.com/video/3U6GAjmz_bA.mp4</location>
<image>http://www.mysite.com/path/preview.jpg</image>
<info>http://www.mysite.com/</info>
</track>
<track>
<creator>Creator</creator>
<title>Title</title>
<location>http://www.youtubemp4.com/video/3U6GAjmz_bA.mp4</location>
<image>http://www.mysite.com/path/preview.jpg</image>
<info>http://www.mysite.com/</info>
</track>
</trackList>
</playlist>

Jan. 02, 2009Discoimperium

Recently i read on this site about the method to embed a YouTube video onto a website using the (HQ) mp4 method and it works like a charm:
http://discoimperium.50webs.com/testing.htm
(only 1 video now) .. (an old 1978 discovideo by 'Phylicia Allen' (aka 'Clair Huxtable' from the Cosby Show btw).

The next step is doing the same with a playlist of my Youtube video's, i just want them to play non-stop one after the other (as above in mp4 format without the Youtube logo).
Does anybody know a way to do this .. if yes: how ?. Do i have to make and use an xml file .. or is there another way to do this ?.

Ps: Below is the code i'm using at the moment:
(the 1 line of code in black towards the bottom is the actual url to the video.. now i'd like a playlist.. anyone ?).

Thanks in advance.
Happy new year !.

<html>
<head>
<title>JW API Example 2-1-1-0 - JW FLV Media Player</title>
<style type="text/css">
body { padding:0px; margin:0px; overflow:auto; }
#txt { margin:8px; }
#wrapper { position:absolute; left:0px; top:0px; width:80px; height:20px; z-index:999; text-align:center; }
</style>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">

var oldWrap = new Object();

function storePosition(theWrapper) {
var tmp = document.getElementById(theWrapper);
if (tmp) {
oldWrap.left = parseInt(tmp.style.left);
oldWrap.top = parseInt(tmp.style.top);
}
}


function storeSize(theWrapper) {
var tmp = document.getElementById(theWrapper);
if (tmp) {
oldWrap.width = parseInt(tmp.style.width);
oldWrap.height = parseInt(tmp.style.height);
}
}


function storeWrap(theWrapper) { storeSize(theWrapper); storePosition(theWrapper); }


function positionWrap(theWrapper, theLeft, theTop, unitStr) {
var tmp = document.getElementById(theWrapper);
if (tmp) {
if (! unitStr) { var unitStr = 'px'; }
tmp.style.left = parseInt(theLeft)+unitStr;
tmp.style.top = parseInt(theTop)+unitStr;
}
}


function sizeWrap(theWrapper, theWidth, theHeight, unitStr) {
var tmp = document.getElementById(theWrapper);
if (tmp) {
if (! unitStr) { var unitStr = 'px'; }
tmp.style.width = parseInt(theWidth)+unitStr;
tmp.style.height = parseInt(theHeight)+unitStr;
}
}


function showWrap(theWrapper, theLeft, theTop, theWidth, theHeight, unitStr) {
if (! unitStr) { var unitStr = 'px'; }
positionWrap(theWrapper, theLeft, theTop, unitStr);
sizeWrap(theWrapper, theWidth, theHeight, unitStr);
}


function hideWrap(theWrapper) { storeWrap(theWrapper); showWrap(theWrapper, 0, 0, 0, 0); }

function restoreWrap(theWrapper) { showWrap(theWrapper, oldWrap.left, oldWrap.top, oldWrap.width, oldWrap.height); }


function createPlayer(theFile) {
var flashvars = {
file:theFile,
autostart:"true"
}
var params = {
allowfullscreen:"true",
allowscriptaccess:"always"
}
var attributes = {
id:"player1",
name:"player1"
}
swfobject.embedSWF("player.swf", "placeholder1", "100%", "100%", "9.0.115", false, flashvars, params, attributes);
}


function initPlayer() {
createPlayer('http://www.youtubemp4.com/video/3U6GAjmz_bA.mp4');
showWrap('wrapper', 80, 50, 490, 387);
storeWrap('wrapper')
}
</script>
<head>
<body onload="initPlayer()" >

<div id="txt">

<font face="Arial">                                                    
DISCO-TV (Coming soon!)<br>
</font><br>
<br>
 </div>

<div id="wrapper">
<div id="placeholder1"></div>
</div>

</body>
</html>

Jan. 03, 2009ytnotworking

thanks Terry,

it was working before with the '/' until recently...

Tried your method and its working now.

Jan. 04, 2009Discoimperium

Thanks Discoinferno !!.
Somehow your reply is posted 'before' my question on this thread, thats why i overlooked it until now :-) (timezone matter i guess). I already thought that your solution might be the way to go but up until now couldn't find the exact syntax (code) to do it.
Cheers.
Discoimperium.

Jan. 04, 2009Discoimperium

Just been testing the Xml method described above but the videos in the playlist don't play non-stop .. you have to click the 'next' button to see the next video ..
Anyone know a way to play all the videos in an Xml file non-stop ?.

This is the code of the Xml file i'm using now:

<?xml version='1.0' encoding='UTF-8'?>
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
<trackList>
<track>
<creator>Creator</creator>
<title>Title</title>
<location>http://www.youtubemp4.com/video/3U6GAjmz_bA.mp4</location>
<image>http://discoimperium.50webs.com/discotv.jpg</image>
<info>http://www.discoimperium.com/</info>
</track>
<track>
<creator>Creator</creator>
<title>Title</title>
<location>http://www.youtubemp4.com/video/WNRGMr5lUS8.mp4</location>
<image>http://discoimperium.50webs.com/discotv.jpg</image>
<info>http://www.discoimperium.com/</info>
</track>
</trackList>
</playlist>

And below is the code to the htm file in which the above Xml file is embedded (the black line towards the bottom is the URL to the Xml which is on my server space).
Anybody have the answer to this ??.
Just wanna play my YouTube videos non-stop..

Cheers.

<html>
<head>
<title>JW API Example 2-1-1-0 - JW FLV Media Player</title>
<style type="text/css">
body { padding:0px; margin:0px; overflow:auto; }
#txt { margin:8px; }
#wrapper { position:absolute; left:0px; top:0px; width:80px; height:20px; z-index:999; text-align:center; }
</style>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">

var oldWrap = new Object();

function storePosition(theWrapper) {
var tmp = document.getElementById(theWrapper);
if (tmp) {
oldWrap.left = parseInt(tmp.style.left);
oldWrap.top = parseInt(tmp.style.top);
}
}


function storeSize(theWrapper) {
var tmp = document.getElementById(theWrapper);
if (tmp) {
oldWrap.width = parseInt(tmp.style.width);
oldWrap.height = parseInt(tmp.style.height);
}
}


function storeWrap(theWrapper) { storeSize(theWrapper); storePosition(theWrapper); }


function positionWrap(theWrapper, theLeft, theTop, unitStr) {
var tmp = document.getElementById(theWrapper);
if (tmp) {
if (! unitStr) { var unitStr = 'px'; }
tmp.style.left = parseInt(theLeft)+unitStr;
tmp.style.top = parseInt(theTop)+unitStr;
}
}


function sizeWrap(theWrapper, theWidth, theHeight, unitStr) {
var tmp = document.getElementById(theWrapper);
if (tmp) {
if (! unitStr) { var unitStr = 'px'; }
tmp.style.width = parseInt(theWidth)+unitStr;
tmp.style.height = parseInt(theHeight)+unitStr;
}
}


function showWrap(theWrapper, theLeft, theTop, theWidth, theHeight, unitStr) {
if (! unitStr) { var unitStr = 'px'; }
positionWrap(theWrapper, theLeft, theTop, unitStr);
sizeWrap(theWrapper, theWidth, theHeight, unitStr);
}


function hideWrap(theWrapper) { storeWrap(theWrapper); showWrap(theWrapper, 0, 0, 0, 0); }

function restoreWrap(theWrapper) { showWrap(theWrapper, oldWrap.left, oldWrap.top, oldWrap.width, oldWrap.height); }


function createPlayer(theFile) {
var flashvars = {
file:theFile,
autostart:"true"
}
var params = {
allowfullscreen:"true",
allowscriptaccess:"always"
}
var attributes = {
id:"player1",
name:"player1"
}
swfobject.embedSWF("player.swf", "placeholder1", "100%", "100%", "9.0.115", false, flashvars, params, attributes);
}


function initPlayer() {
createPlayer('http://discoimperium.50webs.com/discotvtest1.xml');
showWrap('wrapper', 80, 50, 490, 387);
storeWrap('wrapper')
}
</script>
<head>
<body onload="initPlayer()" >

<div id="txt">

<font face="Arial">                                        
<a href="http://www.discoimperium.com">www.discoimperium.com</a>  - Disco-Tv (Test).<br>
</font><br>
<br>
 </div>

<div id="wrapper">
<div id="placeholder1"></div>
</div>

</body>
</html>

Jan. 06, 2009justWalkingBy

http://developer.longtailvideo.com/trac/wiki/FlashVars#Behaviour

repeat=list
repeat=always

Jan. 07, 2009Discoimperium

Thanks !.
Excuse the 'newbie' question but do i add these lines in the xml-file or in the html-code ?. And where exactly do i add them .. and do i use 'repeat=list' or "repeat=list" or <repeat=list> or whatever ??.
Maybe you or someone else can paste a part of the code with these lines inserted correctly .. (just trying to get my head around this ..).
Thanks in advance !.
Cheers.

Jan. 09, 2009Marc J

Does anybody know the minimum flash version required to play youtube HD content in this way?

Jan. 09, 2009andersen

@Marc - probably v9.115

BUT use v.10+ by all means !
earlier version have vulnerabilities and are not safe to use...

@Discoimperium - please see:
http://www.longtailvideo.com/support/jw-player-setup-wizard
http://www.longtailvideo.com/support/tutorials/Embedding-Flash

Jan. 10, 2009Discoimperium

Thanks Andersen .. tried the setup-wizard before with no luck. But reading the tutorial i finally realised that i just had to replace my (long) code with:

<embed
src="player.swf"
width="490"
height="387"
allowscriptaccess="always"
allowfullscreen="true"
flashvars="file=discotvtest1.xml&autostart=true&repeat=list&repeat=always"
/>

And that did the trick ..
Non-stop YouTube video's in HQ without the YT logo .. works like a charm :-) !.
Cheers.

Jan. 15, 2009kathy

The youtube fix is not working for the video:
http://www.youtube.com/watch?v=tGm4f_Co4mM

Can anybody tell what the reason is ???? For other videos it works ????

Jan. 17, 2009Marc J

@Kathy - are you adding a format variable? As that video isn't available in anything other than "standard" quality, and so attempting to view it in fmt=18 or fmt=22 will fail.

Jan. 19, 2009Marc J

Next question - is there any way to add captions to playlist items streamed from YouTube using this method?

This method uses RSS feeds, and captioning a playlist item only seems possible in an XSPF feed (using <meta rel="captions">), I've tried to update this method to use XSPF but can't seem to get it to work?

EDIT: Nevermind, I got it working with some trial and error wink

Jan. 24, 2009Stijn Jasper

I have a little question. Can't you make a video tutorial on how to do this?

You see, I work with wordpress and the WordTube plugin. But I don't really know how all the php codes work. I DO want the HQ videos. What should I do?

Thanks for the reply grin

Jan. 26, 2009edwin

this hack does not work with the new dimensions of the youtube video

Jan. 27, 2009Marc J

@Stijn - everything you need is in this thread or http://www.longtailvideo.com/support/forum/Setup-Problems/15114/HQ-video-thorugh-YouTube-API-JW-player- (another thread with a similar technique). If you have any specific questions just ask!

@edwin - yes it does!

Jan. 27, 2009lefTy

@edwin,

This works with ALL of the new YouTube formats.

Feb. 12, 2009Web Browser

STOPPED STREAMING TODAY 12th FEB 2009

http://www.youtube.com/get_video?video_id=ID&t=SIGNATURE&fmt=18

NOT WORKING

http://www.youtube.com/get_video?video_id=RiWKluUFvl0&t=vjVQa1PpcFM-Fk9ZUNrxaZ1M2HrP1Gak

HELP GUYS

URGENT - 12th Feb 2009

Feb. 14, 2009Carl

Apparantly YouTube have changed the way in which the get-video works.

If you type in your browser http://www.youtube.com/v/RiWKluUFvl0

The following new format appears:

http://www.youtube.com/swf/l.swf?swf=http%3A//s.ytimg.com/yt/swf/cps-vfl78056.swf&video_id=RiWKluUFvl0&rel=1&eurl=&iurl=http%3A//i3.ytimg.com/vi/RiWKluUFvl0/hqdefault.jpg&sk=3VFzhOdSvOv--SxjCPydPh5urlwjhe1mC&use_get_video_info=1&load_modules=1&cr=US&title=Step%20Up%202%20the%20Streets%20%E3%80%90HD%20Trailer%E3%80%91&avg_rating=3.0&length_seconds=551

This is different from the format prior to the 12 February.

I have not been able to break this format down so that it works with get_video.

Anyone else help?

Feb. 14, 2009Robert

I'm using ShaddyShow's two magic lines of code right now:

$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($url)));

and they're working great! I've got Youtube videos streaming into a virtual world, Check it out:

http://www.digparty.com/fb

Thanks ShaddyShow, this is brilliant!

Feb. 15, 2009Robert

<b>New API Script</b>
Yesterday's API call looked like legacy API to me and ShaddyShow's approach got me thinking, so I decided to ferret out the new API call. My new version of this script tries the new API first, and if it fails it falls back to the legacy API. The videoid in my case is passed to this script in a url string, so I need to parse it out first.
Available at http://www.ourwebhome.com/misc/getVideoId.zip
Here's the code:
<>
$url = trim($_REQUEST['url']);
if (strpos($url, 'http://www.youtube.com/watch?v=') === 0) {
$urlArray = split("=", $url);
$videoid = trim($urlArray[1]);

$pageurl = $_SERVER["HTTP_REFERER"];
$newAPIurl = "http://www.youtube.com/get_video_info?&video_id=$videoid";
$newAPIurl .= "&el=embedded&ps=chromeless&eurl=$pageurl";

$newInfo = trim(@file_get_contents($newAPIurl));
$infoArray = split("&", $newInfo);
for ($i=0; $i < count($infoArray); $i++) {
$tmp = split("=", $infoArray[$i]);
$key = urldecode($tmp[0]);
$val = urldecode($tmp[1]);
$paramArray["$key"] = "$val";
}

if (array_key_exists("token", $paramArray)) {
$t = $paramArray["token"];
$response = "<video><id>$videoid</id><t>$t</t></video>";
} else {
$legacyAPIurl="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$legacyT = trim(strip_tags(@file_get_contents($legacyAPIurl)));
$response = "<video><id>$videoid</id><t>$legacyT</t></video>";
}

header("Content-type: text/xml");
echo $response;
} else {
die("Wrong URL / Parameters");
}
<>

Feb. 16, 2009goatlord999

im having trouble with this line:
$t = trim(strip_tags(@file_get_contents($url)));
any alternatives?

Feb. 17, 2009Robert

goatlord,

You might try using curl instead. Something like this:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$info = curl_exec($ch);
curl_close($ch);

Feb. 17, 2009tilderman

please post a php funcional code that works!!!!!!! thanks!

Feb. 17, 2009goatlord999

Thanks Robert, I tried that but it gave me a fatal error

Fatal error: Call to undefined function curl_init()

<?php
$videoid=$_GET["videoid"];
$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$info = curl_exec($ch);
curl_close($ch);
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $ch . "&fmt=18";
header("Location: $url");
?>

Feb. 18, 2009goatlord999

my host has the allow_url_fopen set OFF :(

Feb. 18, 2009Robert

It sounds like you don't have curl loaded. Can you edit your php.ini and load it, and then restart apache?

Feb. 19, 2009tilderman

i have both options enabled in my server but the videos won't load.... i've tested the script in

http://corbilla.com/proxyyt2.php?id=B0OGpRq0Lic.flv

and it works, but none of these scripts works in my server now! please help! some one has the corbilla source code?

Feb. 26, 2009XOO

help

how do you stream video

the other method doesnt work after feb 12

Feb. 28, 2009James

PHP Guide for dummies:

If like me you have a problem with your youtubefix.php file, it's most likely because of copy/paste. When you copy code from the forums into some programs (dreamweaver for me) it adds extra lines the code shouldn't have. For me I had a 9 line file when it was supposed to be 7.

To have a proper running youtubefix.php file you need 7 total lines of code with each of the lines starting as follows:

1.<?php
2.$videoid=$_GET......
3.$url=.....
4.$t =....
5.$url....
6.header....
7.?>

To test that your code is running properly put in www.yourdomain.com/youtubefix.php?videoid=yourvideo and you should be prompted to download the video. If not then there's something wrong.

Many thanks to ShaddyShow for helping me figure out this easily avoidable error. I thought I might be a moron, and he proved me right wink

Feb. 28, 2009lefTy

Actually, your host has a broken PHP implementation that won't tolerate blank lines.

Ask them to fix it.

Feb. 28, 2009James

Completely blank lines are fine for me. I can insert as many lines as I want as long as it's after the semi-colon, but splitting the $url lines in 2 is what messes it up.

So when I was getting my error I had an extra 2 lines that started as follows:

method=youtube......
$t . "&fmt=18"

Mar. 26, 2009Sean Hogan

my guess is that it's the &t= in the actual youtube flv location url.

the flash player is throwing an error that it can't find file, and it's only mentioning the part before the &t= as if the player thinks that is an actual flashvar t= the rest of the youtube video location

Maybe youtube did that to keep their videos from being played in other players?

Mar. 26, 2009ShaddyShow

Heeeeeeeeeeeeeelp

We need a workaround...

Mar. 26, 2009Merlin

The problem is with the t string.

Works:
t=vjVQa1PpcFMDsec-nnFU5TBnHZ-8DOSNxTCIyAVX8SE%3D

Doesn't Work:
t=vjVQa1PpcFN9yK8t3kesIDJ6vLOHBW8I6t9rWRU9IMI=

I can't figure out why...

Mar. 26, 2009ShaddyShow

Pardon?

Please explain more precise...

Mar. 26, 2009ShaddyShow

Ahhhhhhhhh I got you...

So we need a new T-virus wink

The old method still works - just we need to get a new T variable now ...

Mar. 26, 2009Merlin

Works:
http://www.youtube.com/get_video.php?video_id=re4wRoosjvs&t=vjVQa1PpcFOGjPYiccMH7FtdoYO1QNKn2xPg73b_BoE%3D

Doesn't Work:
http://www.youtube.com/get_video.php?video_id=re4wRoosjvs&t=vjVQa1PpcFPwkFFyvWoD854GFNft3FxnDGwdVzX9gXs=

Mar. 26, 2009Merlin

The working t string came from the video page source. The non-working t string came from the youtube API youtube.videos.get_video_token.

Mar. 26, 2009ShaddyShow

So it means that the variable that we get from

http://www.youtube.com/api2_rest

doesn't work any more...

So we need to find a new way to pick it up.

Mar. 26, 2009ShaddyShow

Merlin, do you use yahoo?

Add me: derkleinehajo@yahoo.com

Maybe we can try to work something out together.

Mar. 26, 2009Merlin

Exactly or maybe YouTube will update the API t-string. YouTube is always slow to update the API end.

Mar. 26, 2009ShaddyShow

but... what about the players??? The players MUST retrieve the variable from somewhere to be able to play the video...

Mar. 26, 2009ShaddyShow

For example...

http://www.youtube.com/swf/l.swf?swf=http%3A//s.ytimg.com/yt/swf/cps-vfl86375.swf&video_id=ElgjP00LXnE

This can play a video ...

where l.swf is just the loader,
and cps-vfl86375.swf is the player

The player must contain code how to get the T variable.

Mar. 26, 2009ShaddyShow

In the cps-vfl86375.swf there is sprite20551.as with the function "VideoLoader".

There must be the code. I will try if I am able to interprete it.

Mar. 26, 2009Merlin

For now I'm just grabbing the t-string from the video page and using it.

Mar. 26, 2009ShaddyShow

Hmm, can't find something.

I just see, that the LENGTH of the video token is still the same...

Just the = is replaced by %3D (which is the same)

I tried to just replace the sign in the t variable from the API but didn't work :P

Mar. 26, 2009ShaddyShow

Merlin, can you give the code for grabbing?

Sure, it's not hard, but if you have already a nice optimized code, it would be handy to use it wink

Mar. 26, 2009ShaddyShow

ok, have it now, too:

$content=@file_get_contents("http://www.youtube.com/watch?v=" . $videoid . "&fmt=18");
$start=strpos($content,"&t=")+3;
$ende=strpos($content,"&hl=",$start);
$t=substr($content,$start,$ende-$start);


But ... videos which are flagged for adults are not accessible with this.

Mar. 26, 2009Merlin

Damn! You're right. How can we bypass the flagged part?

Mar. 26, 2009ShaddyShow

We can't - as far as I know.

Mar. 26, 2009nubianprince

ive tested this code and it seems to work

$content=@file_get_contents("http://www.youtube.com/watch?v=" . $videoid . "&fmt=18");
$start=strpos($content,"&t=")+3;
$ende=strpos($content,"&hl=",$start);
$t=substr($content,$start,$ende-$start);

Mar. 26, 2009ShaddyShow

nubian: it just works for videos which are not flagged for adult...

Mar. 26, 2009ShaddyShow

I checked again the youtube code...

On the page we can find 2 different t-variables.

vjVQa1PpcFMJmpXgvedW_mHY7WX3GhQns6XfDagqW9g=
vjVQa1PpcFMJmpXgvedW_mHY7WX3GhQns6XfDagqW9g%3D

So I was thinking, maybe it's just about the urlencode of the t-variable - but it's not.

Both types of t-variable work... but the API that we used so far is just really returning invalid t variables, no matter how we convert them.

Mar. 26, 2009Merlin

Yep, good thinking! There has to be a flagged bypass. On YouTube mobile they use a &is_adult=1 variable.

Mar. 26, 2009Lovley Boy

can you please post the working code for it?

Mar. 26, 2009Mick

Very good post. Thanks for all

Mar. 26, 2009Monashee

Yes I just had my videos stop working this afternoon. And I was using...

$uri = "http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($uri)));

and changed it to:

$content=@file_get_contents("http://www.youtube.com/watch?v=" . $videoid . "&fmt=18");
$start=strpos($content,"&t=")+3;
$ende=strpos($content,"&hl=",$start);
$t=substr($content,$start,$ende-$start);

And it seems to work. I'll probably throw in a try{}catch into my actionscript and divert the error to stream from my server instead of utube.

hope it helps

Mar. 27, 2009Merlin

There has to be another way.......

Mar. 27, 2009ShaddyShow

I have updated / fixed my code. Please replace the above code with this:

$content=@file_get_contents("http://www.youtube.com/watch?v=" . $videoid);
$start=strpos($content,"&t=");
IF ($start<>0)
{
$start=$start+3;
$ende=strpos($content,"&",$start);
$t=substr($content,$start,$ende-$start);
}
else
{
$t=0;
}


The old code didn't run some videos... now they do.

Nevertheless: flagged videos still don't run.

Mar. 27, 2009ShaddyShow

*************************************
********** SOLUTION ************
*************************************

OK, do you want it? Do you really want it? grin

ShaddyShow proudly presents ... the solution:

$content= file_get_contents("http://youtube.com/get_video_info?video_id=$videoid");
$start=strpos($content,"&token=");
IF ($start<>0)
{
$start=$start+7;
$ende=strpos($content,"&",$start);
$t=substr($content,$start,$ende-$start);
}
else
{
$t=0;
}


I searched again in the SWF file (the video player) and found the "get_video_info" wink That file contains also some other informations like length_seconds, avg_rating etc...

If you wanna say "thanks", then join my community shaddyshow.com wink Inside you can see my usage of the licensed (!) FLV Player together with YouTube.

Mar. 27, 2009Stephan

Not working for me :(

Mar. 27, 2009Stephan

Sorry woking great! thanks ShaddyShow you are the man.

Mar. 27, 2009wil

i was using this:

<?php

$videoid=$_GET["videoid"];
$url="http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($url)));
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $t ;
header("Location: $url");


?>

but is stop working,,i try the code from ShaddyShow,but i really a noob abot php so can anybody help me with the right code..

Mar. 27, 2009Rudolf

ShaddyShow you are the man²

This adaptation of ShaddyShow code works for me:

<?php

$format = 18;

/**
=== Explaining YouTube formats ===
Widescreen videos:
6 = 320x180 @ FLV;
18 = 480x270 @ MP4;
22 = 1280x720 @ MP4;
35 = 640x360 @ FLV (some people saying this like MP4. In my tests always shows in FLV);
*/

$videoid='dMH0bHeiRNg'; // change this variable for $_GET['yourVar']
$content= file_get_contents("http://youtube.com/get_video_info?video_id=$videoid");
$start=strpos($content, "&token=");
if($start != 0){
$start = $start + 7;
$ende=strpos($content, "&", $start);
$t=substr($content, $start, $ende-$start);
}else{
$t=0;
}
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $t. "&fmt=".$format;
header("Location: $url");

?>

Mar. 27, 2009Paul

Rudolf that works fine for individual videos but how do i get it to work for my xml playlists

Mar. 27, 2009Soso

Rudolf !

Dear Rudolf i tryed your code and its working when the player id mantioned in the code in this line

$videoid='dMH0bHeiRNg'; // change this variable for $_GET['yourVar']

but if i change this id to my databse call

$videoid='{player.videoid}'; // change this variable for $_GET['yourVar']

it gives error in the player

Video Not found
www.mydomain.com/youtubefix.php?videoid= somethin

actualy it is getting the video id of player but it's not playing.

but if i change the $videoid='{player.videoid}'

to some video file url

$videoid='YuELeUK0dcY'

it is playing this one

can someone help me with it ?

Mar. 27, 2009ShaddyShow

Who of you went to my website and asked in LiveSupport for help?

Lol, you talked with one of my admins.

Guys... if you need help: REGISTER on shaddyshow.com and then send me an internal message over there.

Don't call LiveSupport - my admins are only to help members of my site, lol.

Mar. 27, 2009Soso

ShaddyShow can you please give us to download your php file that you have in demo page ?

my just suck and its not workin :(

Mar. 27, 2009Merlin

ShaddyShow thank you VERY much!! wink

Mar. 27, 2009TurtleBlast

My version of fix.php

<?php

$videoid=$_GET["v"];
$format = 18;
$content= file_get_contents("http://youtube.com/get_video_info?video_id=$videoid");
parse_str($content);
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $token. "&fmt=".$format;
header("Location: $url");
?>

Mar. 27, 2009Merlin

I'm so happy I'm going to say thanks again! Thanks ShaddyShow! wink

Mar. 28, 2009ShaddyShow

Hmm... but there is a new problem...


This video:

http://www.youtube.com/watch?v=3Ii8m1jgn_M

exists as FLV and MP4. When you play it on YouTube with &fmt=18 you get a better quality.

But playing this song with &fmt=18 through our script doesnt work anymore (it worked before, the song was added to my database)

So what is that now?

Mar. 28, 2009ShaddyShow

Ah, now it works again.

Looks like that was just a bug.

And I hope it wont return wink

Mar. 28, 2009charch84

It's not working for me... I get a error saying "Video not found:youtubefix.php?videoid=_MuJ5HQa4Os"... Here is my code:
youtubefix.php

$content= file_get_contents("http://youtube.com/get_video_info?video_id=$videoid");
$start=strpos($content,"&token=");
IF ($start<>0)
{
$start=$start+7;
$ende=strpos($content,"&",$start);
$t=substr($content,$start,$ende-$start);
}
else
{
$t=0;
}


html file
<p id='preview'>The player will show in this paragraph</p>

<script type='text/javascript' src='swfobject.js'></script>
<script type='text/javascript'>
var s1 = new SWFObject('player-viral.swf','player','400','300','9');
s1.addVariable('file','youtubefix.php?videoid=_MuJ5HQa4Os');
s1.addVariable('type','flv');
s1.write('preview');
</script>


What am I doing wrong? They are in the same directory soo, it should work?

Mar. 29, 2009PissedOff

I am sick of this damn thing breaking down ever couple of months and having to spend hours trying to find what new piece of code I need just to stream mother-F'ing Youtube.

How hard is to just provide the exact copy of the php file that works. A copy of the html code for the player and a copy of how are xml playlist should look. Really how hard can this be? We've got a topic with over 150 posts that is an abomination to try and read through only to find out more then half of what's on here doesn’t work.

Mar. 30, 2009Marc J

What used to work has stopped working :(

EDIT: Sorry, I posted a bit too quickly! I've applied the latest fix and all is good again wink

Mar. 30, 2009charch84

can someone please help me?

Mar. 31, 2009Merlin

Shaddy use:
$content= file_get_contents("http://www.youtube.com/get_video_info?video_id=$videoid");

Instead of:
$content= file_get_contents("http://youtube.com/get_video_info?video_id=$videoid");

Apr. 01, 2009ShaddyShow

Merlin... why?

Besides: anyone an idea how to get around country bans? Negotiations with Germany have failed - videos are getting blocked grrrrrrrrrr

Apr. 01, 2009Marc J

Getting around country bans will be difficult, I imagine you'd have to go through some kind of proxy somewhere but it's probably the visitor's IP and not that of the server.

A pity because the UK also has a ban on music videos :(

Apr. 01, 2009Unreal

ShaddyShow,

Thanks for your post on Mar. 27, 2009. That code works great! Thank you very much for continuing to share your updates when YouTube changes stuff.

Apr. 01, 2009willie

i cannot play this video with the code http://www.youtube.com/watch?v=8bV0XSwnPkI .i see this video is Embedding disabled by request.Is it only me or ar all that disabled by request not playing??

Apr. 02, 2009ShaddyShow

@willie: several countries are banned for this video... US people can play it

@all: thanks for your compliments about my code... visit my community www.shaddyshow.com if you wanna make me happy wink It's a free site

@Marc: I found a way... u must have a server in the USA and get not just the T key but also the FINAL URL where the video is... if u have this final URL it can be opened by any country in the world wink

Apr. 02, 2009willie

@ShaddyShow

I try to play the video on an other server,and its play,then i understand that server is in US?How can i see what countrys are banned for this video?

Apr. 02, 2009Marc J

Ah....unfortunately I don't have a server in the US :(

Apr. 02, 2009mo_freestyle

Hi guys, is it me or is the fix not working again?

Apr. 02, 2009mo_freestyle

hot it working again wink

Apr. 02, 2009ShaddyShow

Server in the US = $66 for a year. No big deal huh?

@ Willie: open
http://gdata.youtube.com/feeds/api/videos/$videoid

It has a section for banned countries somewhere... open your video which made problems and scroll down, you will see it.

Apr. 03, 2009Merlin

It seems to have stopped working... :(

Apr. 03, 2009Megjoy

Yep it has stopped working again. Anyone have a solution yet?

Apr. 03, 2009Paul

I give in, why do the videos work on my local server only?

Apr. 03, 2009Merlin

I'm not sure... Where is the smart people when we need them? wink

Apr. 03, 2009ShaddyShow

For me it looks like just an error on YouTube....

Apr. 03, 2009Paul

well I have no problems watching the videos on my PC via the server I have installed but the videos online just don't work

Apr. 03, 2009ShaddyShow

To all: there is NO "new problem".

There seem to be some problems on the YouTube servers tonight, but the code works unchanged.

I post now again the code which you should use (noticed that my code posting above was not complete, the last line was missing):


$content= file_get_contents("http://www.youtube.com/get_video_info?video_id=$videoid");
$start=strpos($content,"&token=");
IF ($start<>0)
{
$start=$start+7;
$ende=strpos($content,"&",$start);
$t=substr($content,$start,$ende-$start);
}
else
{
$t=0;
}

$url= "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $t . "&fmt=18";

Apr. 03, 2009Derek

The code works to get the token, etc, but it does not play the video. What we need is a way to get the googlevideo.com url which is where the video is located.

Apr. 03, 2009ShaddyShow

mhh.... indeed looks like ...

Apr. 03, 2009ShaddyShow

You mean... when u have the URL (open the URL) it says "you don't have the permission to open this page" ... ?

Apr. 03, 2009Derek

Well, it wasn't saying that, but in the headers I was getting a 403 error.

Apr. 03, 2009Merlin

Its the same problem we had last time. The token is no good. When you open up a video personally and take the token it works, but when the server does it, it doesn't.

Apr. 03, 2009ShaddyShow

Yes, 403 is exactly this error.

Hmm... well videos on my site work cause I now use a very very long different code... but the videos didn't work for some minutes for me, too.

I would say I go to bed and check in the morning how is the status.

Apr. 03, 2009Merlin

Anyone else figure it out yet?

Apr. 04, 2009Derek

I'm using the YouTube player in the meantime. I like the JW player better though.

Apr. 04, 2009thesamemike

It stops working againnnnnnnnn ....i think there is something not quite correct on the youtube server (either intentionally or a problem) .
please helpppp

Apr. 04, 2009Merlin

I'm stumped.. I have been working for hours trying to figure it out. :(

Apr. 04, 2009ShaddyShow

Open this page:

http://aktuell.de.selfhtml.org/artikel/php/existenz/

and look for "Funktion mit fsockopen()"

Copy the whole function into your code.

Now... pas the $url which we get from our code into the function like this:

$response=http_test_existance($url);
$url=$response["location"];

And it works.

Apr. 04, 2009Selam

show we one example..

Apr. 04, 2009Merlin

That code spits out the location for you? I looked at the array it spits out and do not see a location response.

Apr. 04, 2009Spud

Seems like it's working on localhost, but not on the liveserver.
Still getting a 403 error

Apr. 04, 2009ShaddyShow

ah.... delete these 2 lines at the end of the function:

$return['_response'] = $response;
$return['_request'] = $head;

Now check the return again with print_r ... do u now see the array with location?

Apr. 04, 2009ShaddyShow

I checked - works... but as I said, u need to delete the 2 lines...

So: if YouTube will make this also secure now, then I really dont have any new solution. I hope that this will stay for a while...

Apr. 04, 2009Merlin

Thanks but its not working for me. Anyone else get it working?

This is a good read for all of you:
http://www.bellera.cat/josep/videocache/squid_videocache_youtube.html

The Live HTTP Headers firefox extension rocks. Using Live HTTP Headers and watching a video you'll see it spits out are usual format:
http://www.youtube.com/get_video?video_id=lAxe_bqLKv4&t=vjVQa1PpcFN0M1maVEq_kOl14Lo-9qDfmnSEhcO_3Zo=&el=detailpage&ps=&fmt=34

Apr. 04, 2009willie

i not getting it work,,someone please post a complete code please

Apr. 04, 2009ShaddyShow

Merlin - I tried it.

Take the code which we had before.
Take the function which I linked above and delete the 2 lines from the function which I said.

And then add these 2 lines to OUR code:

$response=http_test_existance($url);
$url=$response["location"];

Apr. 04, 2009Merlin

Niceeee! It does work now that I did it like that!

You are the man! Thank you times 10! wink

Apr. 04, 2009ShaddyShow

But like I said: if YouTube will make a cross through this, then we really have problems....

Apr. 04, 2009Soso

i use this
<?php

$videoid=$_GET["videoid"];
$content= file_get_contents("http://youtube.com/get_video_info?video_id=$videoid");
$start=strpos($content,"&token=");
IF ($start<>0)
{
$start=$start+7;
$ende=strpos($content,"&",$start);
$t=substr($content,$start,$ende-$start);
}
else
{
$t=0;
}

$url="http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $t . "&fmt=18";

header("Location: $url");
?>



AND GUESS WHAT ????
IT IS NOT WORKING :(

it works yesterday, and suddenly it stops.

can anybody give me some help ?

Apr. 04, 2009Derek

Thanks! Workin' great! For some reason it seems even faster than it was before.

Thanks again!

Apr. 04, 2009Merlin

Shaddy: If it breaks we'll find another way. This has been going on for years.. Great job again man! I cant thank you enough wink

Apr. 04, 2009Soso

Merlin:

can you post your code here ?

Apr. 04, 2009Merlin

Soso: Please follow Shaddy's directions.

Apr. 04, 2009Soso

i need to copy of this fuction "Funktion mit fsockopen()" where ? to youtubefix.php file ?

sorry but i'm just a dumb ....

Apr. 04, 2009Merlin

<?php

Put the function here

Add Shaddy's original code here.

?>

Don't forget to remove the two lines from the function.

Apr. 04, 2009Stephan

ShaddyShow, I love you! I realy do.

Apr. 04, 2009Soso

Merlin i made what you sad

and the code looks like that

<?php

function http_test_existance(
$url,
$timeout = 10
) {
$timeout = (int)round($timeout/2+0.00000000001);
$return = array();

### 1 ###
$inf = parse_url($url);

if (!isset($inf['scheme']) or $inf['scheme'] !== 'http') return array('status' => -1);
if (!isset($inf['host'])) return array('status' => -2);
$host = $inf['host'];

if (!isset($inf['path'])) return array('status' => -3);
$path = $inf['path'];
if (isset($inf['query'])) $path .= '?'.$inf['query'];

if (isset($inf['port'])) $port = $inf['port'];
else $port = 80;

### 2 ###
$pointer = fsockopen($host, $port, $errno, $errstr, $timeout);
if (!$pointer) return array('status' => -4, 'errstr' => $errstr, 'errno' => $errno);
socket_set_timeout($pointer, $timeout);

### 3 ###
$head =
'HEAD '.$path.' HTTP/1.1'."\r\n".
'Host: '.$host."\r\n";

if (isset($inf['user']))
$head .= 'Authorization: Basic '.
base64_encode($inf['user'].':'.(isset($inf['pass']) ? $inf['pass'] : ''))."\r\n";
if (func_num_args() > 2) {
for ($i = 2; $i < func_num_args(); $i++) {
$arg = func_get_arg($i);
if (
strpos($arg, ':') !== false and
strpos($arg, "\r") === false and
strpos($arg, "\n") === false
) {
$head .= $arg."\r\n";
}
}
}
else $head .=
'User-Agent: Selflinkchecker 1.0 (http://aktuell.selfhtml.org/artikel/php/existenz/)'."\r\n";

$head .=
'Connection: close'."\r\n"."\r\n";

### 4 ###
fputs($pointer, $head);

$response = '';

$status = socket_get_status($pointer);
while (!$status['timed_out'] && !$status['eof']) {
$response .= fgets($pointer);
$status = socket_get_status($pointer);
}
fclose($pointer);
if ($status['timed_out']) {
return array('status' => -5, '_request' => $head);
}

### 5 ###
$res = str_replace("\r\n", "\n", $response);
$res = str_replace("\r", "\n", $res);
$res = str_replace("\t", ' ', $res);

$ares = explode("\n", $res);
$first_line = explode(' ', array_shift($ares), 3);

$return['status'] = trim($first_line[1]);
$return['reason'] = trim($first_line[2]);

foreach ($ares as $line) {
$temp = explode(':', $line, 2);
if (isset($temp[0]) and isset($temp[1])) {
$return[strtolower(trim($temp[0]))] = trim($temp[1]);
}
}

return $return;

$videoid=$_GET["videoid"];
$content= file_get_contents("http://youtube.com/get_video_info?video_id=$videoid");
$start=strpos($content,"&token=");
IF ($start<>0)
{
$start=$start+7;
$ende=strpos($content,"&",$start);
$t=substr($content,$start,$ende-$start);
}
else
{
$t=0;
}

$url="http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $t . "&fmt=18";

header("Location: $url");

?>

and its not workin'

Apr. 04, 2009Soso

Can someone just share the working code ?

whats a deal with it, not sharing the code and say follow the steps. if you already did it why you can't just share with others. not every one are gurus like you...

can''t understand this ppl

Just copy past to your code,... not so hard...

Apr. 04, 2009wil

this work for me

<?php

// call with: http://www.mydomain.com/path/YouTube_Multi-Format.php?v=K2_U1kbIcJQ&fmt=18
// JWMP code:
// 'file': encodeURIComponent('YouTube_Multi-Format.php?v=K2_U1kbIcJQ&fmt=18'),
// 'type': 'video',
// fmt=6 HQ FLV 480x360
// fmt=18 HQ MP4 480x270
// fmt=22 HQ MP4 1280x720
// fmt=35 HQ MP4 640x360

$videoid = (isset($_GET['videoid'])) ? strval($_GET['videoid']) : '8bV0XSwnPkI';
$fmt = (isset($_GET['fmt'])) ? intval($_GET['fmt']) : '';
parse_str(file_get_contents("http://youtube.com/get_video_info?video_id=$videoid"));
$uri = "http://www.youtube.com/get_video.php?video_id=$videoid&t=$token";
//$uri = "http://www.youtube.com/get_video.php?video_id=$videoid&t=$token&fmt=$fmt";
//...debug

//$headers = get_headers($uri);
//print "<pre>\n";
//print " uri: $uri\n" ;
//print "videoid: $videoid\n";
//print " token: $token\n";
//print " fmt: $fmt\nheaders: ";
//print_r($headers);
//print "\n</pre>\n";
//exit;

//...debug


function http_test_existance(
$url,
$timeout = 10
) {
$timeout = (int)round($timeout/2+0.00000000001);
$return = array();

### 1 ###
$inf = parse_url($url);

if (!isset($inf['scheme']) or $inf['scheme'] !== 'http') return array('status' => -1);
if (!isset($inf['host'])) return array('status' => -2);
$host = $inf['host'];

if (!isset($inf['path'])) return array('status' => -3);
$path = $inf['path'];
if (isset($inf['query'])) $path .= '?'.$inf['query'];

if (isset($inf['port'])) $port = $inf['port'];
else $port = 80;

### 2 ###
$pointer = fsockopen($host, $port, $errno, $errstr, $timeout);
if (!$pointer) return array('status' => -4, 'errstr' => $errstr, 'errno' => $errno);
socket_set_timeout($pointer, $timeout);

### 3 ###
$head =
'HEAD '.$path.' HTTP/1.1'."\r\n".
'Host: '.$host."\r\n";

if (isset($inf['user']))
$head .= 'Authorization: Basic '.
base64_encode($inf['user'].':'.(isset($inf['pass']) ? $inf['pass'] : ''))."\r\n";
if (func_num_args() > 2) {
for ($i = 2; $i < func_num_args(); $i++) {
$arg = func_get_arg($i);
if (
strpos($arg, ':') !== false and
strpos($arg, "\r") === false and
strpos($arg, "\n") === false
) {
$head .= $arg."\r\n";
}
}
}
else $head .=
'User-Agent: Selflinkchecker 1.0 (http://aktuell.selfhtml.org/artikel/php/existenz/)'."\r\n";

$head .=
'Connection: close'."\r\n"."\r\n";

### 4 ###
fputs($pointer, $head);

$response = '';

$status = socket_get_status($pointer);
while (!$status['timed_out'] && !$status['eof']) {
$response .= fgets($pointer);
$status = socket_get_status($pointer);
}
fclose($pointer);
if ($status['timed_out']) {
return array('status' => -5, '_request' => $head);
}

### 5 ###
$res = str_replace("\r\n", "\n", $response);
$res = str_replace("\r", "\n", $res);
$res = str_replace("\t", ' ', $res);

$ares = explode("\n", $res);
$first_line = explode(' ', array_shift($ares), 3);

$return['status'] = trim($first_line[1]);
$return['reason'] = trim($first_line[2]);

foreach ($ares as $line) {
$temp = explode(':', $line, 2);
if (isset($temp[0]) and isset($temp[1])) {
$return[strtolower(trim($temp[0]))] = trim($temp[1]);
}
}

//$return['_response'] = $response;
//$return['_request'] = $head;






return $return;

}

$response=http_test_existance($uri);
$uri=$response["location"];


header("location: $uri");
exit;


?>

Apr. 04, 2009Luckypc

This code can run in my localhost,but not run in my server and godaddy host,I don't find reasons.Apache set wrong?

Apr. 04, 2009brathering

Don't forget to add

$response=http_test_existance($url);
$url=$response["location"];

before the last line:
header("Location: $url");

This should work - it does for me.

Apr. 04, 2009Soso

wil :

CAN I HUG YOU ? wink

Apr. 04, 2009ShaddyShow

Its NOT good to post the full code.

Just in general.

Apr. 04, 2009wil

Why is not good ShaddyShow??

Apr. 04, 2009brathering

Because it's more easy now to create a workaround against it.

Apr. 04, 2009wil

oke,,if you people not like that i post the code,i will deleted it.

just tell me how can i deleted it????

Apr. 04, 2009darn

Wil your code doesnt work it keeps coming back with the same old stupid reggae video, you can basically put anything in the string for a video url it will always give the same. :(

Apr. 04, 2009darn

and i don't agree with not posting the full code it gets very confusing for n00bs like me, please post the full code i beg of you.

Apr. 04, 2009Soso

Darn will's Code Work Great For me !

Check the embed code in your page

Apr. 04, 2009wil

@darn

call with: http://www.mydomain.com/path/YouTube_Multi-Format.php?videoid=K2_U1kbIcJQ&fmt=18

Apr. 04, 2009mike

Hmmm, it is still not working for me, is wil's code complete that we don't need anything else?
note: yes I did called it with ?videoid=K2_U1kbIcJQ&fmt=18

Apr. 04, 2009Paul

It works for me, here is an example of my xml file




<?xml version="1.0" encoding="utf-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>

<track>
<title>Denis</title>
<author>Blondie</author>
<image>images/blondie.jpg</image>
<location>YouTube_Multi-Format.php?videoid=YbqssGAsL6Q</location>
<meta rel="type">flv</meta>
</track>

</trackList>
</playlist>

Apr. 04, 2009paniekzaaier

this will work wink

<?php

// call with: http://www.mydomain.com/path/YouTube_Multi-Format.php?v=K2_U1kbIcJQ&fmt=18
// JWMP code:
// 'file': encodeURIComponent('YouTube_Multi-Format.php?v=K2_U1kbIcJQ&fmt=18'),
// 'type': 'video',
// fmt=6 HQ FLV 480x360
// fmt=18 HQ MP4 480x270
// fmt=22 HQ MP4 1280x720
// fmt=35 HQ MP4 640x360

$videoid=$_GET["v"];
//$videoid = (isset($_GET['videoid'])) ? strval($_GET['videoid']) : '8bV0XSwnPkI';
//$fmt = (isset($_GET['fmt'])) ? intval($_GET['fmt']) : '';
$fmt = 18;
parse_str(file_get_contents("http://youtube.com/get_video_info?video_id=$videoid"));
//$uri = "http://www.youtube.com/get_video.php?video_id=$videoid&t=$token";
$uri = "http://www.youtube.com/get_video.php?video_id=$videoid&t=$token&fmt=$fmt";
//...debug

//$headers = get_headers($uri);
//print "<pre>\n";
//print " uri: $uri\n" ;
//print "videoid: $videoid\n";
//print " token: $token\n";
//print " fmt: $fmt\nheaders: ";
//print_r($headers);
//print "\n</pre>\n";
//exit;

//...debug


function http_test_existance(
$url,
$timeout = 10
) {
$timeout = (int)round($timeout/2+0.00000000001);
$return = array();

### 1 ###
$inf = parse_url($url);

if (!isset($inf['scheme']) or $inf['scheme'] !== 'http') return array('status' => -1);
if (!isset($inf['host'])) return array('status' => -2);
$host = $inf['host'];

if (!isset($inf['path'])) return array('status' => -3);
$path = $inf['path'];
if (isset($inf['query'])) $path .= '?'.$inf['query'];

if (isset($inf['port'])) $port = $inf['port'];
else $port = 80;

### 2 ###
$pointer = fsockopen($host, $port, $errno, $errstr, $timeout);
if (!$pointer) return array('status' => -4, 'errstr' => $errstr, 'errno' => $errno);
socket_set_timeout($pointer, $timeout);

### 3 ###
$head =
'HEAD '.$path.' HTTP/1.1'."\r\n".
'Host: '.$host."\r\n";

if (isset($inf['user']))
$head .= 'Authorization: Basic '.
base64_encode($inf['user'].':'.(isset($inf['pass']) ? $inf['pass'] : ''))."\r\n";
if (func_num_args() > 2) {
for ($i = 2; $i < func_num_args(); $i++) {
$arg = func_get_arg($i);
if (
strpos($arg, ':') !== false and
strpos($arg, "\r") === false and
strpos($arg, "\n") === false
) {
$head .= $arg."\r\n";
}
}
}
else $head .=
'User-Agent: Selflinkchecker 1.0 (http://aktuell.selfhtml.org/artikel/php/existenz/)'."\r\n";

$head .=
'Connection: close'."\r\n"."\r\n";

### 4 ###
fputs($pointer, $head);

$response = '';

$status = socket_get_status($pointer);
while (!$status['timed_out'] && !$status['eof']) {
$response .= fgets($pointer);
$status = socket_get_status($pointer);
}
fclose($pointer);
if ($status['timed_out']) {
return array('status' => -5, '_request' => $head);
}

### 5 ###
$res = str_replace("\r\n", "\n", $response);
$res = str_replace("\r", "\n", $res);
$res = str_replace("\t", ' ', $res);

$ares = explode("\n", $res);
$first_line = explode(' ', array_shift($ares), 3);

$return['status'] = trim($first_line[1]);
$return['reason'] = trim($first_line[2]);

foreach ($ares as $line) {
$temp = explode(':', $line, 2);
if (isset($temp[0]) and isset($temp[1])) {
$return[strtolower(trim($temp[0]))] = trim($temp[1]);
}
}

//$return['_response'] = $response;
//$return['_request'] = $head;






return $return;

}

$response=http_test_existance($uri);
$uri=$response["location"];

header("location: $uri");
exit;


?>

Apr. 04, 2009darn

Wil, that works! thanx guy!

So does youtube does this often, change their security? :(

Apr. 04, 2009Monashee

I wonder if youtube monitors this forum to see how we are using this workaround. Essentially we are kinda stealing their bandwidth?

Apr. 04, 2009Paul

Monashee they probably are aware but before YouTube came along I used to get 4000+ hits per day to my site because i showed rare videos which could not be seen anywhere else on the internet, now it has dropped to less than 100 per day since people nicked them and uploaded them to YouTube so as far as i am concerned I have no qualms stealing their bandwidth as they stole my income.

Apr. 04, 2009Stephan

I suggest longtailvideo will create a privet forum for this issue! youtube developers probably checking this topic quite often.

Apr. 04, 2009Derek

We aren't stealing anyone's bandwidth. YouTube provides a player for us to use (or 2 if you count the chromeless), we just prefer the JW player.

Apr. 04, 2009paniekzaaier

the youtube player sucks... big time ,in 2 weeks i had to update my script 4 times every weekend its bingo ...would like to spend some time with my girl .. not enough middlefingers in the air for the youtube team !!

Apr. 04, 2009Monashee

I should also add I have no qualms about youtube hosting my HD videos and getting free worldwide hosting. It is the cheapest CDN we will find without having any ad support or huge costs. At least we are giving someone a job at Google/YouTube. Plus when you upload your HD content you don't even need to know how to work an encoder to get the correct results (file size vs. quality) .

@Derek: "We aren't stealing anyone's bandwidth." Then what are we doing 'borrowing' their bandwidth?
The videos are totally hosted on googlevideo.com.

Apr. 04, 2009paniekzaaier

Then let them stop yibbayabba with the code al the time. embedd vids the way they like people to do (low quality flv stupid watermarks etc), its YOUtube vids for everybody !! whats the diference in playing the vids like we do and the way they want us to play it? its just bullshit huh .the api that they want to let us use sucks !!
the jwplayer is a great piece of coding witch is ideal for embedding videos like we do now capable of playing hq vids,

Apr. 05, 2009Merlin

Ok, so here is the deal. Our old previous not working code will work with som editting. I think.

Here is what I think YouTube changed. The IP that pulls the video code must be the same IP of the person trying to get the video. Make sense? So your server is IP 1.1.1.1 and YouTube generates the token with that in mind and when surfer IP 2.2.2.2 tries to use that token it fails.

Apr. 05, 2009mo_freestyle

Nothing seems to be working guys dayum :(

Apr. 05, 2009Lucki

if your script doesn't work with this kind of functions() you can use free this url for download or stream.

http://radiolight.6te.net/functie/ytfix.php?v=(YourIdHere)

Regards.

Apr. 05, 2009mike

@Lucki
I tried below

http://radiolight.6te.net/functie/ytfix.php?v=y3TBZ3t8OtQ

and it doesn't work?
am i missing something ?

Apr. 05, 2009mike

@wil
@paniekzaaier

Thank you for the script, it works great but for it seems always generates mp4 format even when I change fmt to 6 how do I make it to get flv instead mp4 as I want to use it wot JW player, already tried with

http://www.mydomain.com/path/YouTube_Multi-Format.php?v=K2_U1kbIcJQ&fmt=6

still mp4 not flv ? not sure why ...

Apr. 05, 2009henry

http://radiolight.6te.net/ytfix.php?v=[videoID]
without /functie/

and it works!

Apr. 05, 2009TurtleBlast

Worked version. Enjoy
<?php
$videoid=$_GET["v"];
$format = $_GET["fmt"];
if(empty($format)) $format = 18;
$content= file_get_contents("http://youtube.com/get_video_info?video_id=$videoid");
parse_str($content);
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $token. "&fmt=".$format;
$headers = get_headers($url);

foreach($headers as $h){
if(strpos($h,"googlevideo.com")!=false){
$url = substr($h,10);
break;
}
}

header("Location: $url");
?>

Apr. 05, 2009Lucki

sorry folks.

I wrote wrong.

The link is:

http://radiolight.6te.net/ytfix.php?v=(youridhere)&fmt=(fmt)
Enjoy.

Apr. 05, 2009Lucki

@TurtleBlast

Good script too and much smaller

Ok. Now youtube it'z unlocked grin

Apr. 05, 2009TurtleBlast

More perfect variant ytfix.php
<?php
/**
=== Explaining YouTube formats ===
Widescreen videos:
6 = 320x180 @ FLV;
18 = 480x270 @ MP4;
22 = 1280x720 @ MP4;
35 = 640x360 @ FLV;
*/
$videoid=$_GET["v"];
$format = $_GET["fmt"];
if(empty($format)) $format = 18;
$content= file_get_contents("http://youtube.com/get_video_info?video_id=$videoid");
parse_str($content);
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $token. "&fmt=".$format;
$headers = get_headers($url,1);

if(!is_array($headers['Location'])) {
$url = $headers['Location'];
}else {
foreach($headers['Location'] as $h){
if(strpos($h,"googlevideo.com")!=false){
$url = $h;
break;
}
}
}
if(isset($_GET["debug"])){
print "URI: $url<br/>" ;
echo "<pre>";print_r($headers);
die("it's all folks!");
}
header("Location: $url");

Apr. 05, 2009christian

This new script works for you all? I'm using php4 so I can't use get_headers. I changed get_headers to apache_response_headers/apache_request_headers and the code works but the YouTube video URL is dead.

Apr. 05, 2009steve

sorry if this is duplicated but below works for mp4
http://radiolight.6te.net/ytfix.php?v=y3TBZ3t8OtQ&fmt=18

but if I want flv then
http://radiolight.6te.net/ytfix.php?v=y3TBZ3t8OtQ&fmt=6

does not work.
I want to get a flv link so I can use it with JW player, any idea how to get it work.

Apr. 06, 2009Lucki

@TurtleBlast

That script it'z working in fmt

6 = 320x180 @ FLV;
22 = 1280x720 @ MP4;
35 = 640x360 @ FLV;

?

Apr. 06, 2009TurtleBlast

christian, php4 not supported from august 2007 and i'm not use php4.

But you can use ph4 version get_headers from this page: http://php.net/get_headers

Apr. 06, 2009TurtleBlast

Lucki yes, working. If format is not given, that is used format 18, by default.

That is to say these url's same
http://yousite.com/fix.php?v=y3TBZ3t8OtQ&fmt=18
http://yousite.com/fix.php?v=y3TBZ3t8OtQ

If you open in brouser this url, you can see headers and can change fix.php if all conks. again :(
http://yousite.com/fix.php?v=y3TBZ3t8OtQ&fmt=18&debug

p.s. sorry my ugly english

Apr. 06, 2009steve

@Lucki
could you please let us know how can we get
http://yousite.com/fix.php?v=y3TBZ3t8OtQ&fmt=18
working with jw player, i know this sounds a silly question but please if you know the answer let us know or just tel us how to get an flv url
http://yousite.com/fix.php?v=y3TBZ3t8OtQ&fmt=6 ??

thank you

Apr. 06, 2009DarrellM

for flv try:

fmt=34

Apr. 06, 2009Lucki

@steve:

just encode file in php with urlencode() and put file

http://radiolight.6te.net/ytfix.php?v=(yourid)

and type = flv and will work.

Good luck!

Apr. 06, 2009Lucki

@DarrellM

Good point. Use fmt=34 for flv.

:d

Apr. 06, 2009ShaddyShow

Thats quite a lot of new interesting infos...

Thanks Lucki, I will check out your code wink

Apr. 06, 2009d4weed

for flv you can also use fmt=18, gives a higher quality

but I'm wondering how long this solution will work... How reliable can this be? do you think google could reverse this, or make another change so it stops working?

and why is it they changed it in the first time?, isnt't there a way (maybe using client & api key, I don't know) to fget a flv url whithout so much hassle an hacks?

any ideas?

Apr. 06, 2009Lucki

@d4weed,

Youtube are changing api for bandwith purposes & illegal download.

Every time they will try to modify current api.

P.S Doesn't exist a way ( Client or api key ) to get flv url without some hacking. Google doesn't permit this.

Sorry for my romanian english.

Regards.

Apr. 06, 2009pskoz

why can I edit this code? flv dont load :(

<?php require_once('ayar.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$currentPage = $_SERVER["PHP_SELF"];

mysql_select_db($database_geceninrengi, $geceninrengi);
$query_sonyazilar = sprintf("SELECT * FROM yazilar WHERE id = %s ORDER BY id DESC", GetSQLValueString($_GET['id'], "int"));
$sonyazilar = mysql_query($query_sonyazilar, $geceninrengi) or die(mysql_error());
$row_sonyazilar = mysql_fetch_assoc($sonyazilar);
$totalRows_sonyazilar = mysql_num_rows($sonyazilar);

$hjg4789 = $row_sonyazilar['id'];
mysql_select_db($database_geceninrengi, $geceninrengi);
$query_yorumlar = sprintf("SELECT * FROM yorumlar WHERE yaziid = '%s' AND onay='1' ORDER BY id DESC LIMIT 5", $hjg4789);
$yorumlar = mysql_query($query_yorumlar, $geceninrengi) or die(mysql_error());
$row_yorumlar = mysql_fetch_assoc($yorumlar);
$totalRows_yorumlar = mysql_num_rows($yorumlar);

$yaziokunma = sprintf("geceninrengi%s", $row_sonyazilar['id']);
if($_COOKIE[$yaziokunma] == '1'){
} else {
mysql_select_db($database_geceninrengi, $geceninrengi);
mysql_query("UPDATE yazilar SET okunma = okunma+1 WHERE id='$row_sonyazilar[id]'", $geceninrengi);
$cook = $_COOKIE[$yaziokunma] + 1;
setcookie("$yaziokunma", "$cook", time()+86400);
}

$url = "http://www.youtube.com/watch?v=$row_sonyazilar[yazidevami]" ;//
$data = implode("", file($url));
if (preg_match_all("/&t=[^&]*/", $data, $matches))
{
$t = $matches[0][0];
$t = preg_split("/=/", $t);
$t = $t[1];


$v = $url;
$v = preg_split ("/\?v=/", $v);
//$v = preg_split ("/=/", $v);
$v = $v[1];
//echo '&status=ok';


//echo "me=".$youtubeVideoPath;
//header ("Location: $youtubeVideoPath");
}
else
{
echo "null";
}
?><body topmargin="0" leftmargin="0">
<script type="text/javascript" src="sw.js"></script>

<div id="flashplayer"><a href="http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player.exe">Video izlemek için programı indirin Flash Player</a> to see this player.</div>

<script type="text/javascript">
<!--
var object = new SWFObject("player.swf", "mediaplayer", "731", "20", "7");
object.addVariable("width", "731");
object.addVariable("quality", "high");
object.addVariable("height", "20");
object.addVariable("autostart", "true");
object.addVariable("file", encodeURIComponent("<?php echo "http://www.youtube.com/get_video.php?video_id=".$v . "&t=".$t . "&.flv";?>"));
object.addVariable("type", "flv");
object.addVariable('backcolor','0x787878');
object.addVariable('frontcolor','0x000000');
object.addVariable('lightcolor','0xCCCCCC');
object.write("flashplayer");
-->
</script>


<?php
mysql_free_result($sonyazilar);
mysql_free_result($yorumlar);
mysql_close();?>

Apr. 06, 2009mo_freestyle

Guys I use this code for my youtubefix.php

<?php
$videoid=$_GET["v"];
$format = $_GET["fmt"];
if(empty($format)) $format = 18;
$content= file_get_contents("http://youtube.com/get_video_info?video_id=$videoid");
parse_str($content);
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $token. "&fmt=".$format;
$headers = get_headers($url,1);

if(!is_array($headers['Location'])) {
$url = $headers['Location'];
}else {
foreach($headers['Location'] as $h){
if(strpos($h,"googlevideo.com")!=false){
$url = $h;
break;
}
}
}
if(isset($_GET["debug"])){
print "URI: $url<br/>" ;
echo "<pre>";print_r($headers);
die("it's all folks!");
}
header("Location: $url");

?>


Am I doing something wrong because it's not working at all

MO wink

Apr. 06, 2009d4weed

@Lucki

so that means I shouldn't use this method in commercial work (Google could call the owner of the site and ask him about it?)

what do you think... I mean... is the hack legal? cause there are a lot of people out there using techniques like this... isn't there another way to put youtube content into flash?

Apr. 06, 2009steve

could someone please just copy&paste a complete working code here (i.e. a working code with jw player).

for me either of mp4 or flv format is fine but i need this to be working with jw player.

please help ...

Apr. 06, 2009steve

Thanks to whoever fixed this

http://corbilla.com/proxyyt2.php?id=B0OGpRq0Lic.flv

Now it is working fine ...

Apr. 06, 2009Merlin

For those of you not using php5 I created a php4 version. Its small 14 lines of code and mostly cURL. If you want it let me know.

Apr. 07, 2009Marc J

Thanks again to ShaddyShow, Merlin, TurtleBlast and everyone else who has contributed for their continuing excellent work on this wink

Hopefully YT will give up soon wink

Apr. 07, 2009Lucki

@d4weed,

The only way to respect google and law is to pun the original embed player.
All hacks are for sure an illegal way wink

You can use this source but i think that you should hide it too.

That's all wink

Apr. 07, 2009TurtleBlast

mo_freestyle, if beside you do not work fix.php with use get_headers(), that open url http://yousite.com/fix.php?v=y3TBZ3t8OtQ&fmt=18&debug
If you see the heap of code and do not see any report on error, signifies here okay.

Hereinafter - check as you send url to in jw player. It must look here is so:
file: encodeURIComponent('http://yousite.com/fix.php?v=y3TBZ3t8OtQ&fmt=18')
If you not use encodeURIComponent() that all parameters except first get lost.

And the last - parameter type: "video" when use flv or mp4 movie is not openned in the lasts versions jw player.

Hope that this helps ;-)

Apr. 07, 2009Lucki

@TurtleBlast,

your script doesn't work in php 5.2.6

i think that get_header() function is not working.

Can we change that function with another?

Apr. 07, 2009James

Has anyone experienced issues with the i.p. they're running the code from?

From my development machine, my personal, old code works fine. I'll get the url in the format http://www.youtube.com/get_video.php?video_id=mi0X_cnFe-w&t=vjVQa1PpcFOFgSbLEBu9FGuKm_urMLWx5rcm3AQMp8E%3D&.flv etc, which I can then see get 303 redirected to the googlevideo cache url.

However, on the live server if I follow the same process, I get back the same format url but this time it's a 403 forbidden.

This tells me maybe google has started stopping offending i.p.s from requesting the url.

Anyone with similiar experience?

Apr. 07, 2009Lucki

@James,

Please review previous posts.
Old script is not working anymore.

Apr. 07, 2009James

@Lucki, i've read the old posts, i'm not using any code listed on here.

I'm experiencing strange behaviour between different machines and am wondering if anyone else is.

Apr. 07, 2009mo_freestyle

TurtleBlast, Debug gives me: URI: http://v17.lscache6.googlevideo.com/videoplayback?id=cb74c1677b7c3ad4&itag=18&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag&ip=81.93.49.178&signature=1B2A7A179538B977C8D94B7C7CC187F64351A75B.498E5126CD39B13783CB68ECEF79230F7F92E2D1&sver=3&expire=1239140457&key=yt1&ipbits=0


I just don't get it I call the scipt with:
file: encodeURIComponent('http://www.xxxx.nl/tinus/youtubefix.php?videoid=FmMFOhZ0kUE&type=flv'),

Apr. 07, 2009mo_freestyle

Darn I'm so stupid i was using $videoid=$_GET["videoid"];

It's working like a charm now!!!

Thanks grin

Apr. 07, 2009mvideohamster

so can someone post the final complete code php. Im confused by the many verisions above, some work some wont.

this one works -

http://corbilla.com/proxyyt2.php?id=B0OGpRq0Lic.flv

-> Steve
can you post your proxyyt2 php code please?! wink

Apr. 07, 2009TurtleBlast

@Lucki, my fix.php work in http://sms2kino.ru (try) under php 5.2.6, and my dewelopment station under php5.2.8

other version get_headers function see in comments http://php.net/get_headers

Apr. 07, 2009Lucki

Ok. I've changed

get_headers()

with

stream_context_get_default()

Now it works. Thx.

Apr. 07, 2009Lucki

I've done some dev thing, youtube get token witch can be used with file_get_contents();

http://radiolight.6te.net/ytfix.php?v=(yourid)&get_token=true

will print youtube video token.

Hope that will be usefull to smb. wink

Apr. 10, 2009Bouke Regnerus

there is still a way to use the get_video.php file. You now only need some more parameters. You need to find the video_id, l , t, and sk parameters. (search in the video sourcecode for "var fullscreenUrl =") And use it like this: http://youtube.com/get_video.php?video_id=&l=&t=&sk=&fs=1

Apr. 10, 2009ShaddyShow

Dear people,


it's lame that some people need to get posted the full code because they either don't speak English well or because they are too lazy or because they are just dumb.

But it's more lame and even criminal to steal bandwidth from another server.

Some of you have linked to my youtubefix-Script on my domain on your hostings! Hundreds or queries run to my server every day. That is really big shit!!

But ok... there is always a way to take advantage from a disadvante. My script no longer returns YouTube videos but ShaddyShow promotion videos wink

Apr. 10, 2009Ruffrazor

Great Work ShaddyShow

Apr. 10, 2009hi

theres too many versions posted to firue out which one is the right one and every other post is replace this with this, ive went through the entire thread and cant get it working

can someone email me how to get this working? ill provide that person with free web hosting.

snit@ytvretro.com

Apr. 10, 2009Subfighter

turtleblast thanks for the great script as you made it so small..

i have question maybe someone can answer as i have a DB full of youtube videos...

is there a to check for the format that are available?

they are a bunch of different videos from different people so the formats are not uniform..

i would like to use the BEST QUALITY one of course.. so is there a way to pull what formats the video actually supports and choose the best quality automatically in the script..

thanks

Apr. 11, 2009Bouke Regnerus

@TurtleBlast not working for every video, http://sms2kino.ru/fix.php?v=muP9eH2p2PI.

Apr. 11, 2009TurtleBlast

@Bouke Regnerus
http://sms2kino.ru/fix.php?v=muP9eH2p2PI&debug

If you see [0] => HTTP/1.1 404 Not Found signifies that IP with which occurs the request (my server inheres in europe) prohibited to examine this video.

Install fix.php on its server, and do not use my server, please.

Apr. 11, 2009Louis

This is very usefull. Seems to work well, Thanks a million,

Apr. 12, 2009azmajus

I see what you did there TurtleBlast, the trick was not to request the content but to just get the header. Works.

Apr. 12, 2009Lucki

@TurtleBlast,

Do you have an ideea to get video anyway inclusive to prohibed ip's?

I want to use videos that are "Not available in my country".

Some tips?

Apr. 12, 2009mvideohamster

@Lucki

as a thank you for the great brainwork and help in this thread, i can offer 3 country links.
Feel free to use these servers for your queries or in your pages ( i could need some extra traffic for the ranking pages, so this can help us both).

http://ipod1.livebuster.com/fix.php?v=muP9eH2p2PI&debug (switzerland)

http://ipod5.livebuster.com/fix.php?v=muP9eH2p2PI&debug (germany)

http://ipod8.livebuster.com/fix.php?v=muP9eH2p2PI&debug (USA) - which shows the clip!! in this case

So if some of you people will post their country links, maybe russia and china --- we could solve the thing with the "Not available in my country" messages for many many clips cross our nations.

Apr. 13, 2009xyzyx

Here's a quick and ugly Perl hack for ppl that just wanna run a simple server locally (nice if you stream with mplayer, send vid:fmt like mplayer -prefer-ipv4 http://127.0.0.1:4321/CD6VgRUE1y0:18 for mp4), should work with everything else like wget and such too.

#! /usr/bin/perl -w
#

use strict;
use IO::Socket;

for ($|++, my ($s, $c) = new IO::Socket::INET(Listen => 1, LocalAddr => '127.0.0.1', LocalPort => 4321); $c = $s->accept(); close($c)) {
my $vf = <$c>;
$vf =~ s/\r\n//g; $vf =~ s/GET \///g; $vf =~ s/ HTTP\/1..*//g;
my $v = $vf;
my $f = $vf;
$v =~ s/:.*//g;
$f =~ s/.*://g;
my $y = new IO::Socket::INET(PeerAddr => 'www.youtube.com', PeerPort => '80');
print $y "GET /get_video_info?video_id=$v HTTP/1.0\n\n";
my @i = <$y>;
close($y);
my $t = $i[12];
$t =~ s/.*token=//g; $t =~ s/&.*//g;
print $c "HTTP/1.0 302\nLocation: http://www.youtube.com/get_video.php?video_id=$v&t=$t&fmt=$f\n\n";
}

Apr. 13, 2009TurtleBlast

@Lucki, try buy server in USA. For example, http://dreamhost.com/
Sign up today for a one-year hosting plan using the promotional code "777" and you'll get an entire year of web hosting (including a domain registration) for just $9.24! That's 92% off our normal pricing!
I'm use this hosting - not bad, but not very fast

Apr. 13, 2009abu

hello,

i having problem the audio file is not playing where as video is running properly. can u suggest me what i have 2 do for that.

thanx
abrar
mdabraralam@gmail.com

Apr. 13, 2009Lucki

@mvideohamster

Thanx a lot. It's a good ideea to bring all country links.

U.K server:

http://radio-light.freeoda.com/scripts/ytfix.php?v=by8CwXl5-WI (freehost but it'z ok) wink


and i will make one into an Romanian server.

Apr. 13, 2009Lucki

but i think ... how we can figure from get_video_info or other atom feeds if video is prohibed in some countries, and to know wich proxy ( one of our servers ) to use?

Feel free to reply wink

Apr. 13, 2009mvideohamster

@Lucki

trying out (cause im not good in thinking) maybe round robin.

Apr. 13, 2009Lucki

ok. i will try.

but with php or other api's is imposible to do it?

Apr. 14, 2009Unreal

@ShaddyShow:

Your updates have been greatly appreciated and have bailed me out a few times. Please do not let some bandwidth stealing lamers interfere with your participation in this forum.

Apr. 18, 2009Questioner

Is it solved yet ?
Do we have a good working script...
I would not like to depend on the download location for this...A script will be good...
I got a script from here it works but whenever i need to convert that perticular output link my other server (convertor) do not work with it....
I don't know why...

Apr. 18, 2009mvideohamster

@QUestioner

mine does. Can you be more specific what the server's problem exactly is?

Apr. 18, 2009TurtleBlast

@Lucki it's easy wink

Variant #1
# See http://code.google.com/intl/en/apis/youtube/2.0/reference.html#Custom_parameters
# for more information about restriction param
$videoid = 'muP9eH2p2PI'; # restricted video
$j = json_decode(file_get_contents('http://gdata.youtube.com/feeds/api/videos/'.$videoid.'?alt=json&restriction=255.255.255.255'),true);
if(!empty($j['entry']['media$group']['media$restriction']))
$ytfixurl = "http://mysite.com/fix.php?v={$videoid}";
else
$ytfixurl = "http://your-usa-non-restricted-site.com/fix.php?v={$videoid}";


Variant #2
$videoid = 'muP9eH2p2PI'; # restricted video
parse_str(file_get_contents("http://youtube.com/get_video_info?video_id={$videoid}"),$i);
if($i['status']=='ok') $ytfixurl = "http://mysite.com/fix.php?v={$videoid}";
else $ytfixurl = "http://your-usa-non-restricted-site.com/fix.php?v={$videoid}";


Varinat #3 - in ytfix.php
<?php
/**
=== Explaining YouTube formats ===
fmt=? HQ FLV 480x320 1.5:1 3:2 H.263 MP3
fmt=5 LQ FLV 320x180 1.7:1 16:9 FLV1 MP3
fmt=6 HQ FLV 480x360 1.3:1 4:3 H.263 MP3
fmt=18 HQ MP4 480x270 1.7:1 16:9 AVC AAC
fmt=? HQ FLV 534x360 1.4:1 6:4 AVC AAC
fmt=22 HQ MP4 1280x720 1.7:1 16:9 AVC AAC
fmt=34 LQ FLV 320x180 1.7:1 16:9 ? ?
fmt=35 HQ MP4 640x360 1.7:1 16:9 AVC AAC

*/

$videoid=$_GET['v'];
$format = $_GET['fmt'];
if(empty($format)) $format=18;

parse_str(file_get_contents("http://youtube.com/get_video_info?video_id={$videoid}"));
if($status!='ok') header("Location: http://your-usa-non-restricted-site.com/fix.php?v={$videoid}&fmt={$format}");
$url = "http://www.youtube.com/get_video.php?video_id={$videoid}&fmt={$format}&t={$token}";
$headers = get_headers($url,1);

if(!is_array($headers['Location'])) {
$url = $headers['Location'];
}else{
foreach($headers['Location'] as $h){
if(strpos($h,"googlevideo.com")!=false){
$url = $h;
break;
}
}
}
if(isset($_GET["debug"])){
print "URI: $url<br/>" ;
echo "<pre>";print_r($headers);
die("it's all folks!");
}
header("Location: $url");


I hope correct has understood your question :lol:

Apr. 20, 2009TurtleBlast

Some video impossible to get by ytfix.php :(

For example: http://www.youtube.com/watch?v=6ls0SjT6FM4

This video have empy 'fmt_map' var and normal 'token' var in get_video_info. Any idea how download this video?

Apr. 21, 2009wil

@TurtleBlast

The video http://www.youtube.com/watch?v=6ls0SjT6FM4 plays well on a server located in usa,maybe that is the problem

Apr. 21, 2009jim

Hi@all
is there somebody, who know how you can download this video?


http://www.youtube.com/watch?v=2yuMJ3v-h4E


I have tried many times with a lot of tools but none of them worked with it.

Apr. 21, 2009Marc J

@mvideohamster

Thanks for the http://ipod8.livebuster.com server link, works great for music videos in the UK wink

Apr. 21, 2009TurtleBlast

@jim this video encripted by Adobe RTMPE protocol
http://www.adobe.com/livedocs/flashmediaserver/3.0/docs/help.html?content=01_overview_basics_13.html
I think that its impossible :(

Apr. 21, 2009TurtleBlast

@wil, i try use usa server (http://ipod8.livebuster.com, tnx mvideohamster) - i cannot download it :(

Apr. 22, 2009Lucki

Thx TurtleBlast for country restrictions api.
json variant is working.

Apr. 23, 2009thesamemanhal

whoever used this link ...
http://corbilla.com/proxyyt2.php?id=B0OGpRq0Lic.flv

which was working fine but now he is redirecting any video to an ad :(

:( :(

Apr. 26, 2009john

i just not get it:-( , i use the scripts above,but how to get a link so i can download the file from youtube.The scripts work for play flv in the jw player but why no download,,help i cannot sleep

Apr. 29, 2009Lucki

my script http://bkp.radio-light.ro/ytfix2.php?v=6ls0SjT6FM4

not working!

debug tells me that:


URI:

Array
(
[0] => HTTP/1.1 404 Not Found
[Date] => Wed, 29 Apr 2009 16:41:08 GMT
[Server] => Apache
[X-Content-Type-Options] => nosniff
[Expires] => Tue, 27 Apr 1971 19:44:06 EST
[X-YouTube-MID] => WkFSZzctYUFHdmlSendfckMwT0piektBT09ULUtVOF96NF91dlh4a0pweFJTUllqVEFFMXln
[Cache-Control] => no-cache
[Transfer-Encoding] => chunked
[Content-Type] => text/html; charset=utf-8
)


some ideas?

Apr. 29, 2009Kaeesh

@ ShaddyShow

Please check http://www.video-clipz.com/ypp.php it has following code:

[script type='text/javascript' src='http://video-clipz.com/swfobject.js'][/script]
<div name='mediaspace1' id='mediaspace1'>This div will be replaced</div>
[script type='text/javascript']
var s2 = new SWFObject('http://video-clipz.com/yplayer.swf','ply','660','519','9','#ffffff');
s2.addParam('allowScriptAccess','true');
s2.addParam('allowscriptaccess','always');
s2.addParam('allownetworking','all');
s2.addParam('wmode','transparent');
s2.addParam('allowfullscreen','true');
s2.addVariable('file','http://video-clipz.com/ytu.php?videoid=P8YiF2wUF8c');
s2.addVariable('type','video');
s2.addVariable('image','http://i.ytimg.com/vi/yRfAht13emY/0.jpg');
s2.write('mediaspace1');
[/script]

and ytu.php has following codes:

$videoid=$_GET['videoid'];
$format=18;
$content= file_get_contents("http://youtube.com/get_video_info?video_id=$videoid");
$start=strpos($content,"&token=");
IF ($start<>0)
{
$start=$start+7;
$ende=strpos($content,"&",$start);
$t=substr($content,$start,$ende-$start);
}
else
{
$t=0;
}
$url = "http://www.youtube.com/get_video.php?video_id=" . $videoid . "&t=" . $t. "&fmt=".$format;

header("Location: $url");


But its not playing the video, what is the wrong?

Apr. 30, 2009Javier España

Hi there, I'm having problems with this... I need to echo a .flv to use it in Flash, this is the old code I had:

<?php

$url = $_GET['url'];
urldecode($url);
$data = implode("", file($url));

if(preg_match_all("/&t=[^&]*/", $data, $matches)){
$t = $matches[0][0];
$t = preg_split("/=/", $t);
$t = $t[1];
$v = $url;
$v = preg_split ("/\?v=/", $v);
$v = $v[1];
echo "&Path=http://www.youtube.com/get_video.php?video_id=".$v . "&t=".$t . "&.flv";
}
else{
echo "null";
}
?>

How can I make it work with these changes that youTube has had?

Thanks,

Javier

May. 02, 2009Questioner

@mvideohamster


Is it solved yet ?
Do we have a good working script...
I would not like to depend on the download location for this...A script will be good...
I got a script from here it works but whenever i need to convert that perticular output link my other server (convertor) do not work with it....
I don't know why...



Okay i will be more specific now...
After the link converted to
target : http:// youtube .com /watch?v=F9ytzgtLW1A
Download link = http://v15.lscache4.googlevideo.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag&itag=5&ip=xx.x.xxx.xx&signature=xxxx&sver=3&expire=xxx&key=yt1&ipbits=0&id=xxxxxxxxxxxxx
*changed the link info

I am able to download with the Output link (download link)

I just want the Output link (download link) to work with
http://media-convert.com/
Through "Conversion From Url" method on the site
That was working fien before this incidence (yt changed the code) took place.
Kindly help...

Jun. 02, 2009buns

why dont you all use myspace ? or dailymotion ? or ning ?

Jun. 03, 2009Rockman

The URL for getting a video url is not working...
[http://www.youtube.com/get_video.php?video_id=~]

Help me~~~

Jun. 18, 2009Derek

This function http_test_existance() sometimes returns the results very slowly from youtube (more than a minute to start playing the video). Sometimes, however, it is fast, as if it is relying on something specific at youtube.

Videos on youtube always play almost instantly when I go to the page, but it takes a while when using this code.

$response=http_test_existance($url);
$url=$response["location"];


Is there a more efficient way to convert the get_video url
into the googlevideo.com url?

Jul. 16, 2009Shmug

HI guys....When i whant to grabb video from youtube on my server I get 400 Bad Request from youtube...can someone help me ?

Jul. 16, 2009ShaddyShow

Hello...


YouTube has a new protection since ... um... midnight.

Videos, that are disabled for embedding, can no longer be grabbed with our methods.

Workarounds anyone?

Jul. 17, 2009Stryke

Same problem here.

"Disabled for embedding" - Videos are no longer playing! :-(

Jul. 19, 2009Bouke Regnerus

Same here, im looking for a new solution, but i'm almost out of ideas :(

Jul. 19, 2009Bouke Regnerus

I think i found the solution, the script is still a mess but it works!

<?php

$videoid = $_GET['v'];
$content = file_get_contents("http://www.youtube.com/watch?v={$videoid}");

$content = explode("var swfArgs = ", $content);
$content = explode(";
var watchGamUrl", $content[1]);
$content = $content[0];

$obj = json_decode($content);

$fmt_url_map = urldecode($obj->{'fmt_url_map'});
$fmt_url_map = explode("|", $fmt_url_map);
$fmt_url_map = explode(",", $fmt_url_map[1]);
header('Location: ' . $fmt_url_map[0]);

?>


Maybe someone can re-write this code, because it isnt really pretty. The main part is you get the fmt_url_map from the youtube video, and get the url of the quality you want. In my preview that is the highest quality.

Jul. 19, 2009Bouke Regnerus

# Update 2
New smaller version of the youtube get video script.


<?php

$videoid = $_GET['v']; //youtube video id
$content = file_get_contents("http://www.youtube.com/watch?v={$videoid}");

preg_match_all ("/(\\{.*?\\})/is", $content, $matches);
$obj = json_decode($matches[0][1]);

preg_match ("/((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s\"]*))/is", urldecode($obj->{'fmt_url_map'}), $matches);
$url = explode(',', $matches[0]);

header("Location: {$url[0]}"); //high quality video

?>

Jul. 19, 2009Bouke Regnerus

Please post new updates for the youtube video get script in this threat.

http://www.longtailvideo.com/support/forum/General-Chat/18570/-Solution-Youtube-Get-Video

Because I think this one is getting far to long...

Jul. 20, 2009burkul

you should not try to fetch from youtube.com unless you have very small amount of traffic since youtube began to ban IPs according to # of simultaneous connections to youtube.com video pages.

Jul. 20, 2009burkul

since some videos are still working with get_video file, i came with this code :

$content= file_get_contents("http://youtube.com/get_video_info?video_id=$id");
parse_str($content);
if($token)
{
$format=str_replace(strstr($fmt_map, '/'),"",$fmt_map);
$url = "http://www.youtube.com/get_video.php?video_id=" . $id . "&t=" . $token. "&fmt=".$format;
}
else
{
$timer_file="/home/toyour/public_html/temp/youtubetimer.txt";
$cache_tolerance = 30;
if(file_exists($timer_file)){clearstatcache();$time_difference=time()-filemtime($timer_file);
}else{$time_difference=$cache_tolerance;}
if($time_difference >= $cache_tolerance)
{
$fpx=fopen($timer_file,"w");
fwrite($fpx,"info timer");
fclose($fpx);

$ytstring=file_get_contents("http://www.youtube.com/watch?v=$id",0);
preg_match("/watch_fullscreen(.*?)plid/i",$ytstring,$match);
parse_str($match[1]);
$format=str_replace(strstr($fmt_map, '/'),"",$fmt_map);
$token=$t;
$url = "http://www.youtube.com/get_video.php?video_id=" . $id . "&t=" . $token. "&fmt=".$format;
}
}

Jul. 20, 2009burkul

i have implemented a cache file to limit your access to youtube.com/watch pages in order to escape from the ban. In my trials i have discovered 30 seconds is safe enough for a new connection.

I suggest you can put videoid - token - tokendate to your mysql table and allow that token to remain unchanged in your mysql table for 1 hour, after 1 hour you can try to renew the token, this way you can eliminate connections queues.

hope this helps

Jul. 22, 2009Bouke Regnerus

<?php
$videoid = $_GET['v'];
parse_str(file_get_contents("http://youtube.com/get_video_info?video_id={$videoid}"),$i);
if($i['status'] == 'fail' && $i['errorcode'] == '150') {
$content = file_get_contents("http://www.youtube.com/watch?v={$videoid}");

preg_match_all ("/(\\{.*?\\})/is", $content, $matches);
$obj = json_decode($matches[0][1]);

$token = $obj->{'t'};
$fmt_url_map = $obj->{'fmt_url_map'};
}
elseif ($i['status'] == 'fail' && $i['errorcode'] != '150') {
die("Fail, Errorcode: {$i['errorcode']} , Reason: {$i['reason']}");
}
else {
$token = $i['token'];
$fmt_url_map = $i['fmt_url_map'];
}
$url = "http://www.youtube.com/get_video.php?video_id={$videoid}&vq=2&fmt=18&t={$token}";
$headers = get_headers($url,1);
$video = $headers['Location'];
if(!isset($video)) {
preg_match ("/((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s\"]*))/is", $fmt_url_map, $matches);
$video = explode(',', $matches[0]); $video = $video[0];
}
header("Location: $video");
?>


This is my script, it doesnt use a 30sec cache, but it uses the old get_video_info for normal videos, and only /watch if the video is "Disabled for embedding", so you really need to have a site with really high traffic, and lots of "Disabled for embedding" before you get banned by youtube. More information here: http://www.longtailvideo.com/support/forum/General-Chat/18570/-Solution-Youtube-Get-Video

Jul. 24, 2009Bouke Regnerus

#Major Update:

Download the new improved youtube download script.

Download the .zip:http://bit.ly/BeaHq
Files included in the .zip:
- Readme file.
- Download script.
- 3 error videos (video shown when an error occurred).
- Longtail Video, FLV Player files.

Example:http://bit.ly/hkqki

Updates
- Now uses an cache file, when "youtube.com/watch?v=[Video_ID]" is used (Thanks to @burkul).
- Displays error videos, when an error occurred.
- Always YouTube highest possible video quality (in MP4 format).
- All previous features from #update 1.

Aug. 05, 2009visualmind

@Bouke Regnerus

Hi.Your latest script from the archive is working only for HQ movies.

http://beta.leefjedichter.nl/downloads/Youtube Get Video/yt/index.php?v=-r7oE_EOwqM

vs.

http://beta.leefjedichter.nl/downloads/Youtube Get Video/yt/index.php?v=lGbb6wk43Rs

any ideea how to work also for non HQ ?
Thankx

Aug. 05, 2009Stephan

Thanks. This code actually working.

Aug. 14, 2009Carl

On 13th August YouTube has changed the format for downloading video completely.

Gone is the get_video.php URL and the &t field no longer exists.

Any help in what the new parameters are and how to manually download so a script can be written would be appreciated.

Thanks.

Aug. 15, 2009Bouke Regnerus

@Carl, please read this thread

http://www.longtailvideo.com/support/forum/General-Chat/18570/-Solution-Youtube-Get-Video

PS. Sorry, for spamming my solution in this thread, but it works. wink

Aug. 30, 2009Jane

Bouke Regnerus code is not working..

Sep. 12, 2009Bouke Regnerus

@Jane it is

Add a reaction

You can also return to the category or try this search for related threads.


 

Search the Forums

Go

Support

Support Here are some helpful links to learn more about the JW Player™:

Monetize Your Video

Monetize Your Video Earn money with ads from LongTail's AdSolution. Watch our demos and sign up now!

Why Buy a License?

Why Buy a License? If you don’t buy a commercial license, you cannot use a JW Player™ on (i) a site that has ads; (ii) a corporate site; or a (iii) CMS. Our licenses are very inexpensive, so what are you waiting for? Buy a license today.