How to get video id using youtube .net api - c#

I'm trying to find a way to give my application a YouTube URL (as copied from the address bar in a browser) and extract the unique video ID from that URL. I want to stay away from regex or any other string manipulation as a solution since not all YouTube URLs are the same and may continue to change.
There has to be some way to use the YouTube API for .NET (specifically C# for my solution) to simply call a method/function, pass the method the URL for the video, and finally the method would return the video ID as a string.
I've been trying to find documentation on this and so far I can only find info on using methods to retrieve data about a video based on already having and providing the video ID - which I do not have at this point.
I recognize which part of the YouTube URLs identify the video, but the users of my application should not have to be concerned with that.
It would be greatly appreciated if anybody could help me find a solution here.
Thanks!

Unfortunately I do not think this will work. But then again, I don´t understand the problem you have with using the URL. The URL in itself is a kind of an ID and the v property of the URL specifies which video it is. It seems you already know this.
Regarding your problems with using an URL:
Not all YouTube URLs are the same
R: No, but it doesn´t matter because using RegEx you would only read the v property (v=-l6P7VFKnW8), alternatively the short be variant
YouTube URLs may continue to change
R: Yes, they may. However it is unlikely that YouTube would change the identifier anytime soon because of the effects it would have on API's and other infrastructure. Besides, if you have a pure and modular generic solution you wouldn´t have to change more than one RegEx to comply with the new Id.
Related: Youtube .NET Data API: Retrieve only videoID?
Related: C# regex to get video id from youtube and vimeo by url

Related

Getting a track ID on Spotify for using it in the Spotify API

I'm trying to use the Spotify API and I need the id of a specific track but I don't find any solution regarding how to obtain that ID.
Any ideas?
Read a lot of documentation. The information was useful, but I didn't find anything regarding to my topic
Found a pretty simple method. For anyone interested, if you use the desktop app you can drag the name of the song in a text editor and it will give you the id

It is possible to utilize google search engine directly in C#

I've been trying to see all day if it's possible to write a web app in C#/asp.net that uses the google search engine. I've been googling about it all day. I don't want the custom search api because I'm not looking to have a search engine search through a site. I want to have my web app pass input to the basic google web search that search the entire net not a particular site so I can then parse through the first page of the search results. I put that in bold because it seems like the custom search api is for searching a particular site (my own site) which is not what I want to do and yet the only thing I could find. (well for the most part at least) The closest answer I found to my question is this https://stackoverflow.com/a/4082976/5607333 Which might do the trick for me but I don't know how to do that. How do I send search input to google search and get results using html? (or in my case asp.net) If you think it's the answer to my question can you please post an example of how it's done? I say "think" because I'm not sure it's the answer to what I'm asking.
I hope this question isn't considered a dupe to the question I linked to as I have been way more specific than it.
Also if this task isn't possible in C#/asp.net but possible in another language can someone please post an example of how it's done in that language or a link to it?
Update: I figured out what an easy solution is to this it hit while I was looking at another question similar to my problem. The solution is to edit the url and then i assume you could just concatenate it in C# with the + sign.
Update: 2 Even though I figured what I specifically was having trouble with at the moment of writing this question I still doesn't why I can't find a google equivalent of this https://msdn.microsoft.com/en-us/library/dd251020.aspx that's not depreciated. I read an answer to another question on here where someone said it's because that's how they make their money off the ad results but if that's true it still surprises me.
Look this question:
Adding Google's standard search (not custom) to my website
you can use your own XML parser to customize the display for your search users.
with an http request like this:
GET /search?q=bill+material&output=xml&client=test&site=operations
But it has a limitation on number of requests per day, 500 or 1000 I guess

search several web sites using C#

Can I use C# to auto search websites, then return the search results?
Is there a web crawler that would do the same thing if I give it a top domain (ex: I tell it find the word "funny" on stackoverflow.com, and it would tell me all the times "funny" appeared)?
These web sites allow searching via their search bar.
Do I need the web sites cooperation to automate searches?
NOTE: I only plan to be doing about one or two searches a day, so I doubt I'll be blocked, or asked to authenticate myself.
If your planning on crawling through an entire website to count words like that if you dont cache it you will get blocked, youll be requesting every page of the website essentially. Perhaps consider integrating google domain search's instead?
Here is a link to googles page detailing how to interface with c#
http://code.google.com/apis/gdata/client-cs.html
EDIT: Sorry that wasn't quite right : http://gsalib.codeplex.com/
http://answers.oreilly.com/topic/2165-how-to-search-google-and-bing-in-c/
I would look into building an RSS aggregator. RSS is standardized, so that's probably the most reliable way to collect search results from various sources.
EDIT: For sites that don't support RSS
For the sites that don't support RSS, you can look into using a screen scraper. Check out this article on The Code Project to get you started:
http://www.codeproject.com/KB/aspnet/weather.aspx
...web sites allow searching via their search bar ... Can I use C# to auto search websites, then return the search results?
Yes, if the website provides a URL where the search-term is provided as a query-string argument to a URL.
http://yourTargetDomain?searchterm=foo
But unless the website has specifically designed the search results from that URL to be structured data, the website won't "tell [you] all the times 'funny' appeared" but will send you back a search response that is suitable for a browser to display, so you would have to parse the results out of this stream of HTML.
For example:
http://philadelphia.craigslist.org/search/tls?query=ladder&srchType=A&minAsk=&maxAsk=

C# - Xbox Live Stat Grabber

I'm working on an xbl stat grabber. I have a problem I dont understand how to get the "gamer card"
Heres an example : http://www.youtube.com/watch?v=6HA-uz_v6A0&feature=related
I already have the avatar but I don't get how you can grab the stats and recent games...
You need access to the Xbox Live API, I think you have to apply to Microsoft to get on their 'Community Developer' programme, although it's a bit hazy on the site as to whether they are accepting applications or not.
One kind fellow (who I think is a Microsoft employee) saw that this was a terrible oversight from his employers decided to offer as web service that plugged into the Xbox Live network so you can pull statistics down, you can find info about it and a website here: -
http://duncanmackenzie.net/Blog/put-up-a-rest-api-for-xbox-gamertag-data
It's very comprehensive and should give you all the data you need (Gamerscore, current status, last game played etc)
EDIT: Extra stuff that might help
I'm not too familiar with C# but the process of using the service would be to do the following in your application: -
Construct your URL with a/your gamertag as the argument
Use some URL/Networking API (C#/.NET must have something like this somewhere) to load the URL and retrieve the contents. This should return you a big string containing a bunch of XML
Parse the XML into your application using some sort of XML parsing API (again, I'd imagine C#/.NET has these things built into the framework)
From the looks of the program, the gamercard info looks as if it is just an embedding based upon the gamer tag. You can find info on embedding your Xbox Live gamercard here.
The video author said the Halo stat information is coming courtesy of a site called HaloCharts.com. I don't know if he is embedding the information, perhaps reading an RSS feed, or if he is extracting data from the HTML.

Getting an FLV from YouTube in .NET

I'm writting FLV media player and want to know if there is there anyway of accessing the underlying FLV files used by YouTube from a URL? There used to be a bunch of ways of doing it, but YouTube have changed things about and I now can't find any way of doing it...
From what I've seen so far, the YouTube API doesn't seem to give access either. Has anyone found a way of doing it?
Cheers!
There are two values associated with a YouTube video: an ID and a signature. The ID is simple to get, as it's in the URI itself. The signature is a bit trickier to get. It's embedded in a Javascript statement in the source code of each video page.
For example, let's take the Numa Numa video.
It has an ID of KmtzQCSh6xk, as can be seen from the URI.
To get the signature, we have to dig into the source code of the HTML. To easily do this in Firefox, load the source of the page by right clicking anywhere on the page and click "View Page Source." After that, press Ctrl+F, and type in "t":. It will take you to the signature of the page: the value directly after that in quotes is the signature.
In the case of the Numa Numa Dance, it's signature is vjVQa1PpcFOSvCcjdAYSc3ZQgK-6EG9yQM7RLSYqJk4%3D
To get the actual FLV, you enter this URI:
http://www.youtube.com/get_video?fmt=5&video_id={ID}&t={SIGNATURE}
The complete URI to get the FLV video is:
http://www.youtube.com/get_video?fmt=5&video_id=KmtzQCSh6xk&t=vjVQa1PpcFOSvCcjdAYSc3ZQgK-6EG9yQM7RLSYqJk4%3D
You can use this information to help you get the signature and ID you need to download the FLV programatically. Whether it's doing a simple String.Find for the value "t": or using RegEx, it should be simple to find until they change it.

Categories