Handling of blocked videos retrieved through youtube video feed

bhupendra2895

New Member
Messages
554
Reaction score
20
Points
0
Hi,

The Problem:-
I am creating a youtube application(for mobile browsers) in zend framework(PHP) to learn the basics of framework.I have created a search form which uses GET method.So when user enters a query the api fetches the data from youtube server and parse it.So I can display it to user.

The problem is that whenever I search for 'Michael Jackson', I get some videos without content url, running this query in youtube.com's search engine shows that this blocked by Vevo in my country, may be due to copyright issue.

For resolving this issue I blocked videos with no content URL in view (User's Browser).But my youtube search interface is designed to show 10 videos per page, so when I block such videos either no video display in result or only few videos get displayed.This will certainly create a confusion in the mind of user.Unfortunately Michael Jackson is very popular among us.

The solutions in my mind:-
I think one solution isto fetch around 30 enteries at once and display 10 out of them having the content URL.But I feel it is very costly for server.Because if user find his choice in first page useful than what is the meaning of fetching 30 entries at once.For example when I search for 'mozila firefox', I don't get such videos.I can cache the filtered results, but is it a good idea to use caching with webservices.

The Question:-
If you had used youtube api in your application, is this issue occured to you and if occured how you resolved it?

Please suggest me a better solution for this problem.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
What URL(s) are you using to fetch results? What API of YouTube's are you using?
 
Last edited:

bhupendra2895

New Member
Messages
554
Reaction score
20
Points
0
This is the URL that is used to fetch the result http://gdata.youtube.com/feeds/api/videos?max-results=5&vq=Michael+Jackson

I am using zend Gdata PHP api, more info here:-
Develepors's guide php
Developer Guide
Youtube API Reference

This is the php code that is written in controller to fetch feed
PHP:
	public function searchAction() {
		try {
			$q = $this->_request->getParam ( 'q' ); //parameter from get request
			$yt = new Zend_Gdata_YouTube ();
			$yt->setMajorProtocolVersion ( 2 );
			$query = $yt->newVideoQuery ();
			$query->setMaxResults ( 5 );
			$query->setVideoQuery ( $q );
			$videoFeed = $yt->getWatchOnMobileVideoFeed($query->getQueryUrl( 2 ) );
			$this->view->videos = $videoFeed;
			$this->view->string = $q;
			$request_url = $query->getQueryUrl(); //Used for getting request URL
			$this->view->request = $request_url;
		} catch ( Zend_Excetion_Service $e ) {
			throw $e;
		}
	}


Edit:- I found the solution here http://code.google.com/apis/youtube/2.0/reference.html#formatsp

I set this format
PHP:
$query->setFormat('1');
So request URL changed to
http://gdata.youtube.com/feeds/api/videos?max-results=5&q=Michael+Jackson&format=1
Now I am getting only those videos in feed which have rtsp link for mobile phones.I am sorry that I asked this question before searching the Youtube API developers forum, instead I searched Google for finding solution.
 
Last edited:
Top