1.

Solve : Advanced PHP Help?

Answer»

Okay, I need a text box and a submit button. You enter a youtube link into the text box lets call this link 'A'. You then click submit.

'A' Will look SOMETHING like this: http://uk.youtube.com/watch?v=dxUXilGDzk8

When you click submit, the webpage needs to find "'/watch_fullscreen?fs=" within 'A'.
And then get the rest after that for instance it needs to turn:
Code: [Select]var fullscreenUrl = '/watch_fullscreen?fs=1&BASE_YT_URL=http%3A%2F%2Fuk.youtube.com%2F&vq=None&video_id=dxUXilGDzk8&l=194&sk=UipVJyQjldAVAUTftMXy7t5W_5dt_karC&fmt_map=34%2F0%2F9%2F0%2F115&t=OEgsToPDskJBx5h73eh0V0KNAiBqz_RF&hl=en&plid=AARdE3Ki_Rpaxi-sAAACgAA4AAA&title=Wiley - She Glows';
into:
Code: [Select]=1&BASE_YT_URL=http%3A%2F%2Fuk.youtube.com%2F&vq=None&video_id=dxUXilGDzk8&l=194&sk=UipVJyQjldAVAUTftMXy7t5W_5dt_karC&fmt_map=34%2F0%2F9%2F0%2F115&t=OEgsToPDskJBx5h73eh0V0KNAiBqz_RF&hl=en&plid=AARdE3Ki_Rpaxi-sAAACgAA4AAA&title=Wiley - She Glows';

Now lets say the link it now has is called 'B'.

It now needs to take 'B' and add "http://www.youtube.com/get_video?" to the start.

Once it has done all of this it should give a hyperlink to something like this:
Code: [Select]http://www.youtube.com/get_video?=1&BASE_YT_URL=http%3A%2F%2Fuk.youtube.com%2F&vq=None&video_id=dxUXilGDzk8&l=194&sk=UipVJyQjldAVAUTftMXy7t5W_5dt_karC&fmt_map=34%2F0%2F9%2F0%2F115&t=OEgsToPDskJBx5h73eh0V0KNAiBqz_RF&hl=en&plid=AARdE3Ki_Rpaxi-sAAACgAA4AAA&title=Wiley - She Glows'

I will appreciate anybody who could make this for me, as I have no experience in PHP AT ALL!
Thank You Very Much.I may have found a solution:
http://www.virtuosomaster.com/tutorials/youtube-flv-grabber-script/
How would I set the php up, for exaple do i put it in the same webpage as the form, do I save it as html or php?
I have uploaded this file with an extension of .php to my web host but nothing happens, could anybody help please.
Code: [Select]<?php

functionGrabVideo($url)
{
$CH=curl_init($url);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0(Windows;U;WindowsNT5.1;en-US;rv:1.8.1.2)Gecko/20070219Firefox/2.0.0.2');
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$page=curl_exec($ch);
if(!curl_errno($ch))
curl_close($ch);
else
$page=false;
return$page;
}

if(isset($_GET['url'])){
$url=$_GET['url'];
$url=trim($url);

if(strstr($_GET['url'],"youtube.com")){
$youtube_page=GrabVideo($_GET['url']);
preg_match('/watch_fullscreen\?fs=(.*?)&vq=(.*?)&video_id=(.*?)&l=(.*?)&sk=(.*?)&fmt_map=(.*?)&t=(.*?)&hl=(.*?)&plid=(.*?)&/',$youtube_page,$matches);
if($matches&&isset($matches[1])&&isset($matches[3])){
Header("LOCATION:http://www.youtube.com/get_video?video_id=$matches[3]&l=$matches[4]&t=$matches[7]");
}
}
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html XMLNS="http://www.w3.org/1999/xhtml">
<head>
<title>Youtube Grabber Script</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
body {
font-family: sans-serif;
font-size: 12px;
}
form{ margin:0; padding:0;}
#url {
font-size: 1em;
color: #222222;
background-color: #F8F8F8;
width: 295px;
margin: 0px 0px 4px 0px;
padding: 3px;
border-color: #333333 #CCCCCC #CCCCCC #333333;
border-style: solid;
border-width: 1px;
}
.submit
{ background-color: #000000;
height:22px;
border:1px solid #666666;
color:#FFF; font-size:12px;
font-weight:bold;
}
p{ margin:0; padding:2px 0}

-->
</style>
</head>

<body>

<form method="get" action="" name="form">
<input type="text" id="url" name="url" /><br>
<p> example: <a href="http://www.youtube.com/watch?v=QFrqKYwmhMc" target="_blank">http://www.youtube.com/watch?v=QFrqKYwmhMc</a></p>
<input type="submit" class="submit" value="Grab Video" />
</form>
</body>
</html>
If you click on the http://www.virtuosomaster.com/tutorials/samples/youtube-flv-grabber.php.txt link it will take you to the complete page. I did note there was a line of space between the php closing tag and the following doctype line - I'd remove that space.

If any file has tags then it will take the extension .php even if there is html mixed in. It is not at all uncommon to have both mixed in together.

~~~~~~~~~~~~~~~~~~~~

Ahhh - see you tried it. I haven't time to check this out right now but hopefully a php guru can have a look. Remove that line space I mentioned and - make sure file is .phpI took away that line, but it's very weird.
I just get, for example:
www.flvyoutube.com/youtube-flv.php
turns into
www.flvyoutube.com/youtube-flv.php?url=http%3A%2F%2Fuk.youtube.com%2Fwatch%3Fv%3D-T_SryRAXuw
and nothing happens.Outa my depth for now ... hope for other input.Thanks so far anyway. For your help on both topics.It is fixed, never mind it was just my crappy free host, thanks everyone. So - curiosity here - can you give a report on its function sequence - end result etc ... interesting to know the details.Sorry, I'm not sure how to do that, but please, take a look at this, I'm very pleased with what I have created, (with alot of help)
http://ytflv.110mb.com/youtube-flv.phpLooks good

One thing I'd change is that RATHER faint red text in the form field -- #FFD728 - might be better a bit darker.

So - I assume this does the job as you want now?Thank you, and yes it works perfectly, thanks.
Does this display properly in IE7, as I am using firefox, and just by chance I thought you might be using IE?
Thank you.Just checked IE vs FF - pretty much same and main difference is text size - as is usual FF shows a bit larger but essentially they match well. I don't have Opera set up on this puter so couldn't check that.

Field text looks way better. Thank you. and thanks for your help once again.



Discussion

No Comment Found