Thursday, September 22, 2011

Re: [YouTube-API] Re: search the next 50

Try removing the equal sign from the start-index Name/Value pair parameter definition:

                 qparams.add(new BasicNameValuePair("start-index=", startIndex));


On Thu, Sep 22, 2011 at 5:57 PM, Jeffrey Posnick <jeffy@google.com> wrote:
Hello,

 Please see my response at

 http://groups.google.com/group/youtube-api-gdata/browse_thread/thread/8e0056f5f6787cc5#

for a link to the docs on how to properly implement paging.

Cheers,
-Jeff Posnick, YouTube API Team
groups.google.com/group/youtube-api-gdata | apiblog.youtube.com |
@YouTubeDev


On Sep 22, 1:01 pm, fachhoch <fachh...@gmail.com> wrote:
> I am trying  to search youtube using
> org.apache.http.client.HttpClient   (  apache httpclient)
>
> In order to search more than 50 records I am incrementing start-index
> for every search request.
>
> I noticed the results returned are  the same irrespective of start-
> index
>
> her is the code
>
>         public static String getResponse(String startIndex) throws Exception
> {
>
>                 HttpClient httpclient = new DefaultHttpClient();
>                 List<NameValuePair> qparams = new ArrayList<NameValuePair>();
>                 qparams.add(new BasicNameValuePair("q", "telugu movies"));
>                 qparams.add(new BasicNameValuePair("fields",
> "entry(media:group(media:title,media:player,yt:duration))"));
>                 qparams.add(new BasicNameValuePair("max-results", "50"));
>                 qparams.add(new BasicNameValuePair("start-index=", startIndex));
>
>                 URI uri = URIUtils.createURI("http", "gdata.youtube.com", -1, "feeds/
> api/videos", URLEncodedUtils.format(qparams, "UTF-8"), null);
>                 HttpGet httpget = new HttpGet(uri);
>                 System.out.println(httpget.getURI());
>                 HttpResponse response = httpclient.execute(httpget);
>                 HttpEntity entity = response.getEntity();
>                 String value=EntityUtils.toString(entity);
>                 System.out.println(value);
>                 return value;//StringUtils.removeStart(value, "<?xml version='1.0'
> encoding='UTF-8'?>");
>         }
>
>         public static List<String> getResults(int noOfTimes) throws
> Exception{
>                 List<String>  results= Lists.newArrayList();
>                 int count=0;
>                 while(count<noOfTimes){
>                         int startIndex=(50*count)+1;
>                         results.add(getResponse(String.valueOf(startIndex)));
>                         count++;
>                 }
>                 return results;
>         }
>
>  if this is not the right   way how to search more than 50 records ?
>
> I call the method   getResults    here I pass number of times to
> search , for every search I am calculating start-index as   (50*count)
> +1;
>
>   here the url I am searching
>
> http://gdata.youtube.com/feeds/api/videos?q=telugu+movies&fields=entr...http://gdata.youtube.com/feeds/api/videos?q=telugu+movies&fields=entr...http://gdata.youtube.com/feeds/api/videos?q=telugu+movies&fields=entr...
>   and so....on.
>
> its the same url   except for  start-index value   , is this the right
> way to search more than 50?

--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.




--
G. Bert Bonkowski
Founder, Screenius Inc.

--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment