Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[Tutorial] How To Use Youtube Api [Tutorial][ Create your own Bot ]

Greetings HackForums


I just made a Youtube API bot, it was fun to make.You can check my bot HERE. It's your turn now. Before getting started you should know some basics and definitions.


What's API ?
Application Programming Interface. A language and message format used by an application program to communicate with the operating system or some other control program such as a database management system (DBMS) or communications protocol. APIs are implemented by writing function calls in the program, which provide the linkage to the required subroutine for execution. Read More Here

YouTube Data API
The YouTube Data API allows client applications to retrieve and update YouTube content in the form of Google Data API feeds. Your client application can use the YouTube Data API to fetch video feeds, comments, responses, and playlists, as well as query for videos that match particular criteria. You can also use the API to make authenticated requests to modify this information and to upload new video content to the site. Read More Here

Preparations
We first need to install the Google Data Libraries. Head up to http://code.google.com/p/google-gdata/downloads/list then download and install the latest version ( Google_Data_API_Setup_2.0.1.0.msi ). Once done go to http://code.google.com/apis/youtube/dashboard/ ( you need a Gmail for this ) and get yourself an API key.

Getting Started
Open a New VB.net Project and add Google.GData.Client.dll, Google.GData.Extensions.dll, Google.GData.YouTube.dll to the references they are located where you installed the Libraries( mine were in C:\Program Files\Google\Google Data API SDK\Samples )

Step 1

Import the libraries to your project :
Code
Imports Google.GData.Client
Imports Google.GData.Extensions
Imports Google.GData.YouTube
Imports Google.GData.YouTube.YouTubeService
Imports Google.GData.Extensions.MediaRss
Imports Google.YouTube
Imports System.Management
Imports System.Net
Imports System.IO

Step 2

We should authenticate our account by adding our credentials settings, the key you made before.

Code
Dim Settings As YouTubeRequestSettings
Dim Request As YouTubeRequest
Settings = New YouTubeRequestSettings("Application Name", "Your Api Key", "Any Youtube Username", "Any's Password")
Request = New YouTubeRequest(settings)
So basically every time you want to execute something ( like,comment,subscribtion..) you'll have to define the user credentials (Username and Password )

Step 3

After we declared ourselves to the API it's time to define the YT (YouTube) video we will be using.
Code
Dim VideoUri As Uri
Dim TheVideo As Video
VideoUri = New Uri("http://gdata.youtube.com/feeds/api/videos/" + "Video ID")
TheVideo = request.Retrieve(Of Video)(VideoUri)

Define Uri : Provides an object representation of a uniform resource identifier (URI) and easy access to the parts of the URI.
Read more About Uri
Video ID : Let's take http://www.youtube.com/watch?v=cPi85qp-V1A as example. The Video ID is cPi85qp-V1A


Step 4
Step 3 was the final step in the authentication, the funny parts can now get started.

To Like (Rate) a Video:
Code
TheVideo.Rating = 5;
request.Insert(TheVideo.RatingsUri, TheVideo);

To Dislike a Video:
Code
TheVideo.Rating = 1;
request.Insert(TheVideo.RatingsUri, TheVideo);

To Retrieve video comments:
Code
Dim comments = request.GetComments(TheVideo)
Dim c As Comment
  For Each c In comments.Entries
    MsgBox(c.Content)
  Next

To Add video comment:
Code
Dim c As Comment = New Comment()
c.Content = "Comment Content"
request.AddComment(TheVideo, c)

To Subscribe to a Video channel:
Code
Dim s As Subscription = New Subscription
s.Type = SubscriptionEntry.SubscriptionType.channel
s.UserName = TheVideo.Uploader
request.Insert(New Uri(YouTubeQuery.CreateSubscriptionUri("The Username you authenticated with")), s)
"The Username you authenticated with" cleary means that you should use the username in Step 2 ( Any Youtube Username )

To Subscribe to a Video channel:
Code
Dim s As Subscription = New Subscription
s.Type = SubscriptionEntry.SubscriptionType.channel
s.UserName = TheVideo.Uploader
request.Delete(s)

To Add a Video as Favorite:
Code
Dim videoEntryUrl As String = "http://gdata.youtube.com/feeds/api/videos/" + "Video ID"
Dim service As YouTubeService = request.Service
Dim videoEntry As YouTubeEntry = service.Get(videoEntryUrl)
Dim feedUrl As String = "http://gdata.youtube.com/feeds/api/users/default/favorites"
service.Insert(New Uri(feedUrl), videoEntry)

To Remove a Video as Favorite:
Code
Dim videoEntryUrl As String = "http://gdata.youtube.com/feeds/api/videos/" + "Video ID"
Dim service As YouTubeService = request.Service
Dim videoEntry As YouTubeEntry = service.Get(videoEntryUrl)
Dim feedUrl As String = "http://gdata.youtube.com/feeds/api/users/default/favorites"
request.Delete(videoEntry)

To Flagg a Video:
Code
Dim c As Complaint = New Complaint
c.Type = ComplaintEntry.ComplaintType.PORN
c.Content = "This video contain pornographic scenes"
request.Insert(TheVideo.ComplaintUri, c)
You can change the complaintype to Hate,Porn,Rights,Spam,Violence,Unknown.


Well these are the most basic things you can do, to learn more go to
https://developers.google.com/youtube/2....ide_dotnet
and let me know if you need any help converting the code language


Enjoy and don't forget to say thanks
very nice..appreciate your effort sir!!!
(May 23, 2012 12:24 AM)ytlayol Wrote:  very nice..appreciate your effort sir!!!

Thanks loyalty
Yeah that took me a while to do ^^ but it's totally worth it
You should write an API key creator to go along with this since the YT API is basically useless without 239462934692364982364 API keys. Well... unless you are OK with every account you use getting suspended due to abuse of the API.
Need a custom software? Check out my freelance service here! 6+ years and counting, never a complaint :)

STOP STEALING CODE.

FREE NATHAN

People who report posts are lamers.
(May 23, 2012 03:43 AM)idb. Wrote:  You should write an API key creator to go along with this since the YT API is basically useless without 239462934692364982364 API keys. Well... unless you are OK with every account you use getting suspended due to abuse of the API.

Wait a second ... so if i change the API on every command execution ( like/comment/subscribe..) the accounts wont get banned ??
(May 23, 2012 04:25 AM)Lambasoft Wrote:  Wait a second ... so if i change the API on every command execution ( like/comment/subscribe..) the accounts wont get banned ??

No... but if you use the same API key across multiple accounts and for abusive purposes (aka a bot) your accounts will get banned quick as fuck. Use 1 API key per account and ONLY use that key for that specific account.

You can't just interchange API keys during a session either... you need to auth using the key before you can do anything. Super gay.

Every action you make when using an API key is logged. When that key raises suspicion of foul play guess what information is available for YT to see? Every account that has used that API key. Then guess what happens? API key = suspended and accounts = disabled. This is why using API's for anything involving a bot that is against the TOS is pretty retarded. Just use the regular site. I realize that sounds a bit scary due to the fact that YT constantly updates (at a pretty annoying rate to be honest), but what's more annoying... updating a few lines of code or having all of your accounts and API keys drop at the same time?

Why do you think that every source I release having to do with shit like this uses the actual websites instead of API keys? API keys are just another unnecessary step in the process. API are also just a good way to get your proxies blacklisted, accounts killed, and yourself tracked down.

Just my 2 cents.
Need a custom software? Check out my freelance service here! 6+ years and counting, never a complaint :)

STOP STEALING CODE.

FREE NATHAN

People who report posts are lamers.
(May 23, 2012 04:33 AM)idb. Wrote:  No... but if you use the same API key across multiple accounts and for abusive purposes (aka a bot) your accounts will get banned quick as fuck. Use 1 API key per account and ONLY use that key for that specific account.

You can't just interchange API keys during a session either... you need to auth using the key before you can do anything. Super gay.

Every action you make when using an API key is logged. When that key raises suspicion of foul play guess what information is available for YT to see? Every account that has used that API key. Then guess what happens? API key = suspended and accounts = disabled. This is why using API's for anything involving a bot that is against the TOS is pretty retarded. Just use the regular site. I realize that sounds a bit scary due to the fact that YT constantly updates (at a pretty annoying rate to be honest), but what's more annoying... updating a few lines of code or having all of your accounts and API keys drop at the same time?

Why do you think that every source I release having to do with shit like this uses the actual websites instead of API keys? API keys are just another unnecessary step in the process. API are also just a good way to get your proxies blacklisted, accounts killed, and yourself tracked down.

Just my 2 cents.

Totally right with this, i never though about my API's account getting banned all i cared of was not banning the fake accounts ( the funniest thing is that i'm using my main account XD ) I guess i should fix this ASAP , and i do think i might use your classes for this ^^
One problem persist, how to correctly create to accounts.
pretty nice find on that tutorial. nice tut. likes your tutorial lol. nicely done.
It really sucks that this thread dies. It's a well made thread!
Thanks for this, now I can create my own Youtube bot.
awsome posting keep it up bro , iv bookmarked this for ever and ever
This is a quality post, I woukld +rep you if I could.
I have a question: Does youtube add a view to the counter if you only let the code run to this point:

Code
Dim VideoUri As Uri
Dim TheVideo As Video
VideoUri = New Uri("http://gdata.youtube.com/feeds/api/videos/" + "Video ID")
TheVideo = request.Retrieve(Of Video)(VideoUri)

What does this line of code do? Does it grant you access to the video's commands/database/functions/etc, or does it really load the video to your computer and let it count as a view?

Regards,
c0ffee
Cool tut keep the good work are you giving the source out?
It is barelly old threat. But i need to ask. Is this BOT still working? i have got error here:
Code
dVideo = request.Retrieve(Of Video)(VideoFeedUri)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by HackooAug 5, 2021 09:54 PM 4 252 Aug 5, 2021 09:54 PM
Last Post: PurpleNurples
[Python] by F.A.S.TJul 8, 2018 11:21 AM 2 89 Jul 8, 2018 11:21 AM
Last Post: F.A.S.T
[Java] by GlushkoJun 13, 2018 11:13 PM 3 642 Jun 13, 2018 11:13 PM
Last Post: hostov