Thread: Not getting ALL the Youtube results

  1. #1
    Android geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470

    Not getting ALL the Youtube results

    Hi

    I'm using below code snippet to fetch Youtube video titles, when you enter a query into a listbox, and press the search button:

    Code:
    private void button_search_Click(object sender, EventArgs e)
            {
                YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
    
    
                //order results by the number of views (most viewed first)
                //query.OrderBy = "viewCount";
    
    
                query.Query = textBox_query.Text; // get query from the text box. ex. "Joe Rogan"
                query.SafeSearch = YouTubeQuery.SafeSearchValues.None;
    
    
                Feed<Video> videoFeed = request.Get<Video>(query);
    
    
                printVideoFeed(videoFeed);
            }
    
    // Enumerate feeds
    void printVideoFeed(Feed<Video> feed)
            {
                foreach (Video entry in feed.Entries)
                {
                    printVideoEntry(entry);
                }
            }
    
    // Put the video titles into the listbox
    void printVideoEntry(Video video)
            {
                listBox_result.Items.Add(video.Title);
            }
    But what i get is like 50 results, while when i search the same query on YT, i get 1000s of results. What's the wrong with my code?

    Thanks for any help.
    GameJolt: https://gamejolt.com/@KasunL
    Game Development Youtube:
    https://is.gd/XyhYoP
    Amateur IT Blog: http://everything-geeky.blogspot.com/



    (and, sorry for my amateur English)

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Can you give some detail on which API you're using?
    If you understand what you're doing, you're not learning anything.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Without knowing what library you're using, we really can't help but guess. If it's a client library, then post a link to its documentation. If it's your own library, then show the implementation.
    Also be aware that Youtube's API limits the result per query to some number of videos. It also sends nextPageToken and prevPageToken. You need to take the nextPageToken and send it as part of your call to get the next set of the results.
    Can you get all results with one query? No. Does this API suck? Yes.
    Basically read this unless you're using a client library.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Android geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470
    Thx for the replies.

    I'm using these libs (the top 2 APIs in the page) : https://code.google.com/p/google-gdata/downloads/list

    And i'm using this guide: https://developers.google.com/youtube/2.0/developers_guide_dotnet#Searching_for_Videos
    GameJolt: https://gamejolt.com/@KasunL
    Game Development Youtube:
    https://is.gd/XyhYoP
    Amateur IT Blog: http://everything-geeky.blogspot.com/



    (and, sorry for my amateur English)

  5. #5
    Android geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470
    I used this code in above documentation, and modified it hoping to fit my need:

    Code:
    YouTubeQuery query =newYouTubeQuery(YouTubeQuery.DefaultVideoUri);
    
    //order results by the number of views (most viewed first)
    query.OrderBy="viewCount";
    
    // search for puppies and include restricted content in the search results
    // query.SafeSearch could also be set to YouTubeQuery.SafeSearchValues.Moderate
    query.Query="puppy";
    query.SafeSearch=YouTubeQuery.SafeSearchValues.None;
    
    Feed<Video> videoFeed = request.Get<Video>(query);
    
    printVideoFeed(videoFeed);
    
    
    GameJolt: https://gamejolt.com/@KasunL
    Game Development Youtube:
    https://is.gd/XyhYoP
    Amateur IT Blog: http://everything-geeky.blogspot.com/



    (and, sorry for my amateur English)

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I suggest you use this guide: https://developers.google.com/api-cl...et/get_started
    You can get the client library from nuget: https://www.nuget.org/packages?q=goo...rder=relevance
    Here you can find samples: https://github.com/youtube/api-sampl.../master/dotnet
    You should be using version 3.0 as 2.0 is deprecated (your link points to version 2.0).
    Last edited by Elysia; 11-06-2014 at 05:04 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. YouTube video info
    By geek@02 in forum C# Programming
    Replies: 2
    Last Post: 11-02-2014, 08:19 AM
  2. cws youtube problem
    By kryptkat in forum Tech Board
    Replies: 6
    Last Post: 05-26-2010, 09:43 AM
  3. My First Youtube video
    By abachler in forum Tech Board
    Replies: 17
    Last Post: 10-04-2009, 03:02 AM
  4. C++ youtube video
    By kypronite in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 08-18-2008, 11:05 PM
  5. Youtube magic
    By Magos in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 05-01-2008, 01:38 PM