Jump to content

Youtube Data Api V3 Ile Arama Yapma ?


IIMyErenII
 Share

Recommended Posts

  • Editor

Hocam baktım onlara ama olmuyor hemde consol uygulaması bana form lazım.Örnek proje atan olursa sevinirim.

 

Console uygulamasındaki C# ile Formdaki C# farklı şeylermi onu anlayamadım ben :D

Link to comment
Share on other sites

ben de ufak bir örnek hazırladım:
 
zKJ0AFk.png
 
SqxB8f7.png
 
XooVQ4Y.png
 
 
[spoiler]
 

using Google.Apis.Services;
using Google.Apis.YouTube.v3;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
 
 
namespace Youtube_Search_API
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
 
 
        private void Run(string aranan)
        {
            var youtubeService = new YouTubeService(new BaseClientService.Initializer()
            {
                ApiKey = "AIzaSyCY7Gw6BaCL6rGvsewEwBjhE_BkKVJyXXg",
                ApplicationName = this.GetType().ToString()
            });
 
            var searchListRequest = youtubeService.Search.List("snippet");
            searchListRequest.Q = aranan; // Replace with your search term.
            searchListRequest.MaxResults = 50;
 
            // Call the search.list method to retrieve results matching the specified query term.
            var searchListResponse = searchListRequest.Execute();
 
            List<string> videos = new List<string>();
            List<string> channels = new List<string>();
            List<string> playlists = new List<string>();
 
            // Add each result to the appropriate list, and then display the lists of
            // matching videos, channels, and playlists.
            foreach (var searchResult in searchListResponse.Items)
            {
                switch (searchResult.Id.Kind)
                {
                    case "youtube#video":
                        videos.Add(String.Format("{0} ({1})", searchResult.Snippet.Title, searchResult.Id.VideoId));
                        break;
 
                    case "youtube#channel":
                        channels.Add(String.Format("{0} ({1})", searchResult.Snippet.Title, searchResult.Id.ChannelId));
                        break;
 
                    case "youtube#playlist":
                        playlists.Add(String.Format("{0} ({1})", searchResult.Snippet.Title, searchResult.Id.PlaylistId));
                        break;
                }
            }
 
            foreach (string item in videos)
                listView1.Items.Add(item);
 
            foreach (string item in channels)
                listView2.Items.Add(item);
            
            foreach (string item in playlists)
                listView3.Items.Add(item);
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            Run(textBox1.Text);
        }
 
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                button1_Click(null, null);
        }
    }
}
 
[/spoiler]
https://yadi.sk/d/DW_4rEVrgqb5F
Not: API keyi değiştirmeyi unutmayın, örnektir.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...