Jump to content

Video Script help


limpep

Recommended Posts

Hi

 

I am having an issue searching videos from youtube when ever I do a search i keep getting an page not found error.

 

here is my code

 

<?

class Youtube
{
var $dom, $idvideo, $title, $video;
//function for video title
function videoTitle()
{
	return $this->title;
}

function pagination()
{
	return true;
}

function tag($tag, $page = 1) 
{
	if ($page <= 0) $page = 1;

	$start = ($page-1)*10 + 1;
	$tag = str_replace(' ', '+', $tag);
	$feed = ('http://gdata.youtube.com/feeds/api/videos?vq='.$tag.'&start-index='.$start.'&max-results=10&orderby=updated&alt=rss');
	$this->dom = getFeed($feed);
}

function video($id) 
{
	$this->idvideo = $id;
	$feed = ("http://gdata.youtube.com/feeds/api/videos/".$id);
	$this->dom = getFeed($feed);
	$this->video = $this->dom->getElementsByTagName('entry')->item(0);
	$this->title = $this->video->getElementsByTagName('title')->item(0)->textContent;
}


function player()
{
	?>
	<object width="425" height="355">
		<param name="movie" value="http://www.youtube.com/v/<?=$this->idvideo?>" />
		<param name="wmode" value="transparent" />
		<embed src="http://www.youtube.com/v/<?=$this->idvideo?>" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed>
	</object>
	<?
}

function view($tag)
{
	$videos = $this->dom->getElementsByTagName('item');

	foreach ($videos as $video)
	{
		$id = $video->getElementsByTagName('guid')->item(0)->textContent;
		$id = explode('/', $id);
		$id = $id[6];

		echo '<div class="video">';
		$title = $video->getElementsByTagName("title")->item(0)->textContent;
			echo '<p><a href="'.BASE_URL.'/0/video/'.$tag.'/'.$id.'.html">'.$title.'</a></p>';

			$fotos = $video->getElementsByTagNameNS("http://search.yahoo.com/mrss/", "thumbnail");
			$tiempo = $video->getElementsByTagNameNS("http://gdata.youtube.com/schemas/2007", "duration");
			$tiempo = $tiempo->item(0)->getAttribute("seconds");

			$i = 0;
			echo '<div class="img">';
			foreach ($fotos as $foto)
			{
				$url = $foto->getAttribute("url");
				echo '<a href="'.BASE_URL.'/0/video/'.$tag.'/'.$id.'.html"><img src="'.$url.'" alt="'.$title.'"/></a>';
				$i++;
				if ($i > 2) break;
			}
			echo '</div>';

			echo '<p class="links"><a href="'.BASE_URL.'/0/video/'.$tag.'/'.$id.'.html">'._VIEW.'</a> '._DURATION.': '.minutes($tiempo).'</p>';

			echo '<p>'.cut($video->getElementsByTagName("description")->item(0)->textContent).'</p>';

			$tags = $video->getElementsByTagName("category");

			echo '<div class="tags">'; echo 'tags: ';
			foreach ($tags as $palabra)
			{
				if (strpos($palabra->textContent, "http") === FALSE)
					echo '<a href="'.BASE_URL.'/0/tag/'.$palabra->textContent.'.html">'.$palabra->textContent.'</a> ';
			}
			echo '</div>';

		echo '</div>';

	}
}

function videoInfo()
{	
		$id = $this->video->getElementsByTagName("id")->item(0)->textContent;
		$id = explode("/", $id);
		$id = $id[6];

		echo '<div class="video">';
			$title = $this->video->getElementsByTagName("title")->item(0)->textContent;

			$tiempo = $this->video->getElementsByTagNameNS("http://gdata.youtube.com/schemas/2007", "duration");
			$tiempo = $tiempo->item(0)->getAttribute("seconds");

			echo '<p class="links">'._DURATION.': '.minutes($tiempo).'</p>';

			echo '<p>'.$this->video->getElementsByTagName("description")->item(0)->textContent.'</p>';

			$tags = $this->video->getElementsByTagNameNS("http://www.w3.org/2005/Atom", "category");

			echo '<div class="tags">'; echo 'tags: ';
			foreach ($tags as $palabra)
			{
				if (strpos($palabra->getAttribute("term"), "http") === FALSE)
					echo '<a href="'.BASE_URL.'/0/tag/'.$palabra->getAttribute("term").'.html">'.$palabra->getAttribute("term").'</a> ';
			}
			echo '</div>';

		echo '</div>';
}
}

?>

Link to comment
Share on other sites

What you are trying to do violates YouTube's Terms of Service

 

4. A. You agree not to distribute in any medium any part of the Service or the Content without YouTube's prior written authorization, unless YouTube makes available the means for such distribution through functionality offered by the Service (such as the Embeddable Player).

 

4. C. You agree not to access Content through any technology or means other than the video playback pages of the Service itself, the Embeddable Player, or other explicitly authorized means YouTube may designate.

 

4. H. You agree not to use or launch any automated system, including without limitation, "robots," "spiders," or "offline readers," that accesses the Service in a manner that sends more request messages to the YouTube servers in a given period of time than a human can reasonably produce in the same period by using a conventional on-line web browser. . . .

Link to comment
Share on other sites

What you are trying to do violates YouTube's Terms of Service

 

4. A. You agree not to distribute in any medium any part of the Service or the Content without YouTube's prior written authorization, unless YouTube makes available the means for such distribution through functionality offered by the Service (such as the Embeddable Player).

 

4. C. You agree not to access Content through any technology or means other than the video playback pages of the Service itself, the Embeddable Player, or other explicitly authorized means YouTube may designate.

 

4. H. You agree not to use or launch any automated system, including without limitation, "robots," "spiders," or "offline readers," that accesses the Service in a manner that sends more request messages to the YouTube servers in a given period of time than a human can reasonably produce in the same period by using a conventional on-line web browser. . . .

 

never mind I fixed the issue

 

just had to added this line to my .httaccess

 

RewriteBase <location of my files>

 

btw using the youtube api doesnt violates YouTube's Terms of Service

 

http://www.ibm.com/developerworks/xml/library/x-youtubeapi/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.