Is it possible to get the video title using the video ID with API v3 without the API key? I could not find any information or example of getting the title in the API documentation.
To get the video title, you will need an API key, and you'll need to make a request to:
https://www.googleapis.com/youtube/v3/videos?part=snippet&id={COMMA_DELIMITED_LIST_OF_IDS}&key={YOUR_API_KEY}
In the returned packet, the title will be at items.snippet.title
You can't retrieve any API data without an API key; all API requests are on a quota system, and the key is used to determine how much to charge your app's daily limit. A call like the above, however, is quite inexpensive; it's a total of 3 units (2 for the snippet and 1 for the request itself). Since you get 50,000,000 units a day and can retrieve up to 50 snippets for that same 3 units, it's not much of a burden to use the API key.
No need for API key
To get the video title, you will NOT need an API key, and you'll need to make a request to:
https://noembed.com/embed?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ
Change the YouTube URL for the video that you need.
It also works with Vimeo and many other supported sites with URLs like:
https://noembed.com/embed?url=https://vimeo.com/45196609
Details
It is not possible to get the video title using the video ID with API v3 without the API key if you use the API directly. The YouTube Data API v2 is deprecated (see: YouTube Data API v2 Deprecation: Frequently Asked Questions) and currently the YouTube API doesn't support oEmbed with JSONP as it should (see Issue 4329: oEmbed callback for JSONP).
But fortunately there is the Noembed service that lets you get the titles (and other data) of YouTube videos with JSONP and without the API key.
Demo
Here is a simple demo to get the title with jQuery:
var id = 'dQw4w9WgXcQ';
var url = 'https://www.youtube.com/watch?v=' + id;
$.getJSON('https://noembed.com/embed',
{format: 'json', url: url}, function (data) {
alert(data.title);
});
See DEMO on JS Bin.
See also these questions:
This is precisely the meaning of the oEmbed protocol.
oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.
This document is stored on GitHub.
More informations on the format at: https://oembed.com
https://www.youtube.com/oembed?url=http%3A//youtube.com/watch%3Fv%3DM3r2XDceM6A&format=json
Sample output:
{
"version": "1.0",
"type": "video",
"provider_name": "YouTube",
"provider_url": "http://youtube.com/",
"width": 425,
"height": 344,
"title": "Amazing Nintendo Facts",
"author_name": "ZackScott",
"author_url": "http://www.youtube.com/user/ZackScott",
"html":
"<object width=\"425\" height=\"344\">
<param name=\"movie\" value=\"http://www.youtube.com/v/M3r2XDceM6A&fs=1\"></param>
<param name=\"allowFullScreen\" value=\"true\"></param>
<param name=\"allowscriptaccess\" value=\"always\"></param>
<embed src=\"http://www.youtube.com/v/M3r2XDceM6A&fs=1\"
type=\"application/x-shockwave-flash\" width=\"425\" height=\"344\"
allowscriptaccess=\"always\" allowfullscreen=\"true\"></embed>
</object>",
}
Here is a list of content providers that declared adhere to the format:
"provider_name": "23HQ",
"provider_name": "Adways",
"provider_name": "Alpha App Net",
"provider_name": "amCharts Live Editor",
"provider_name": "Animatron",
"provider_name": "Animoto",
"provider_name": "Audiomack",
"provider_name": "AudioSnaps",
"provider_name": "Blackfire.io",
"provider_name": "Box Office Buz",
"provider_name": "Buttondown",
"provider_name": "Cacoo",
"provider_name": "Carbon Health",
"provider_name": "CatBoat",
"provider_name": "ChartBlocks",
"provider_name": "chirbit.com",
"provider_name": "CircuitLab",
"provider_name": "Clipland",
"provider_name": "Clyp",
"provider_name": "Codepen",
"provider_name": "Codepoints",
"provider_name": "CodeSandbox",
"provider_name": "CollegeHumor",
"provider_name": "Commaful",
"provider_name": "Coub",
"provider_name": "Crowd Ranking",
"provider_name": "Cyrano Systems",
"provider_name": "Daily Mile",
"provider_name": "Dailymotion",
"provider_name": "Deviantart.com",
"provider_name": "Didacte",
"provider_name": "Dipity",
"provider_name": "DocDroid",
"provider_name": "Docs",
"provider_name": "Dotsub",
"provider_name": "edocr",
"provider_name": "eduMedia",
"provider_name": "EgliseInfo",
"provider_name": "Embed Articles",
"provider_name": "Embedly",
"provider_name": "Ethfiddle",
"provider_name": "Eyrie",
"provider_name": "Facebook (Video)",
"provider_name": "Flat",
"provider_name": "Flickr",
"provider_name": "FOX SPORTS Australia",
"provider_name": "FrameBuzz",
"provider_name": "FunnyOrDie",
"provider_name": "Geograph Britain and Ireland",
"provider_name": "Geograph Channel Islands",
"provider_name": "Geograph Germany",
"provider_name": "Getty Images",
"provider_name": "Gfycat",
"provider_name": "GIPHY",
"provider_name": "Gyazo",
"provider_name": "HuffDuffer",
"provider_name": "Hulu",
"provider_name": "iFixit",
"provider_name": "IFTTT",
"provider_name": "Indaco",
"provider_name": "Infogram",
"provider_name": "Inoreader",
"provider_name": "inphood",
"provider_name": "Instagram",
"provider_name": "iSnare Articles",
"provider_name": "ivlismusic",
"provider_name": "Kickstarter",
"provider_name": "Kidoju",
"provider_name": "Kit",
"provider_name": "Kitchenbowl",
"provider_name": "Knacki",
"provider_name": "LearningApps.org",
"provider_name": "Ludus",
"provider_name": "MathEmbed",
"provider_name": "me.me",
"provider_name": "Meetup",
"provider_name": "MixCloud",
"provider_name": "Moby Picture",
"provider_name": "Modelo",
"provider_name": "myBeweeg",
"provider_name": "nanoo.tv",
"provider_name": "nfb.ca",
"provider_name": "Odds.com.au",
"provider_name": "Office Mix",
"provider_name": "Official FM",
"provider_name": "On Aol",
"provider_name": "Ora TV",
"provider_name": "Orbitvu",
"provider_name": "Oumy",
"provider_name": "Pastery",
"provider_name": "Pixdor",
"provider_name": "Poll Daddy",
"provider_name": "Port",
"provider_name": "Portfolium",
"provider_name": "Punters",
"provider_name": "Quiz.biz",
"provider_name": "Quizz.biz",
"provider_name": "RapidEngage",
"provider_name": "Reddit",
"provider_name": "ReleaseWire",
"provider_name": "RepubHub",
"provider_name": "ReverbNation",
"provider_name": "Roomshare",
"provider_name": "Rumble",
"provider_name": "Sapo Videos",
"provider_name": "Screen9",
"provider_name": "Screencast.com",
"provider_name": "Screenr",
"provider_name": "ScribbleMaps",
"provider_name": "Scribd",
"provider_name": "ShortNote",
"provider_name": "Shoudio",
"provider_name": "Show the Way, actionable location info",
"provider_name": "Silk",
"provider_name": "Simplecast",
"provider_name": "Sizzle",
"provider_name": "Sketchfab",
"provider_name": "SlideShare",
"provider_name": "SmugMug",
"provider_name": "SocialExplorer",
"provider_name": "Songlink",
"provider_name": "SoundCloud",
"provider_name": "Soundsgood",
"provider_name": "SpeakerDeck",
"provider_name": "Spotful",
"provider_name": "Spreaker",
"provider_name": "Streamable",
"provider_name": "StreamOneCloud",
"provider_name": "Sutori",
"provider_name": "Sway",
"provider_name": "Ted",
"provider_name": "The New York Times",
"provider_name": "They Said So",
"provider_name": "TickCounter",
"provider_name": "Toornament",
"provider_name": "Topy",
"provider_name": "Twitch",
"provider_name": "Twitter",
"provider_name": "Ubideo",
"provider_name": "UOL",
"provider_name": "Ustream",
"provider_name": "Utposts",
"provider_name": "Uttles",
"provider_name": "VeeR VR",
"provider_name": "Verse",
"provider_name": "VEVO",
"provider_name": "VideoJug",
"provider_name": "Vidlit",
"provider_name": "Vimeo",
"provider_name": "Vlipsy",
"provider_name": "wecandeo",
"provider_name": "Wiredrive",
"provider_name": "wizer.me",
"provider_name": "Wootled",
"provider_name": "WordPress.com",
"provider_name": "Yes, I Know IT!",
"provider_name": "YFrog",
"provider_name": "YouTube",
"provider_name": "ZProvider",
Note that this doesn't mean that CORS is enabled on this websites.
This datas are mostly made to be parsed server side.
Most of this information can also be obtained by parsing the <meta og>
open graph html attributes of a given page.
See http://ogp.me/ for info about open graph.
To get the video title, you will need an API key, and you'll need to make a request to:
https://www.googleapis.com/youtube/v3/videos?part=snippet&id={COMMA_DELIMITED_LIST_OF_IDS}&key={YOUR_API_KEY}
In the returned packet, the title will be at items.snippet.title
You can't retrieve any API data without an API key; all API requests are on a quota system, and the key is used to determine how much to charge your app's daily limit. A call like the above, however, is quite inexpensive; it's a total of 3 units (2 for the snippet and 1 for the request itself). Since you get 50,000,000 units a day and can retrieve up to 50 snippets for that same 3 units, it's not much of a burden to use the API key.
Yes You Can Without Any API Just Requests an re Modules
Code In Python:
import requests,re
video_url = "https://www.youtube.com/watch?v=2i2khp_npdE"
response = requests.get(video_url).text
title = re.findall(r'"title":"[^>]*",',response)[0].split(',')[0][9:-1]
print("\n[+] Video Title: {}".format(title))
Output:
[+] Video Title: Alan Walker - Sing Me To Sleep
Yes, it is possible.
I made some rework of excellent Porto's answer here, and wrote this snippet on Python:
import urllib, urllib.request, json
input = "C:\\urls.txt"
output = "C:\\tracks.csv"
urls=[line.strip() for line in open(input)]
for url in urls:
ID = url.split('=')
VideoID = ID[1]
params = {"format": "json", "url": "https://www.youtube.com/watch?v=%s" % VideoID}
url = "https://www.youtube.com/oembed"
query_string = urllib.parse.urlencode(params)
url = url + "?" + query_string
with urllib.request.urlopen(url) as response:
response_text = response.read()
try:
data = json.loads(response_text.decode())
except ValueError as e:
continue # skip faulty url
if data is not None:
author = data['author_name'].split(' - ')
author = author[0].rstrip()
f = open(output, "a", encoding='utf-8')
print(author, ',', data['title'], sep="", file=f)
It picks a text file containing Youtube URL list:
https://www.youtube.com/watch?v=F_Vfgdfgg
https://www.youtube.com/watch?v=RndfgdfN8
...
and returns a CSV file with Artist-Title pairs:
Beyonce,Pretty hurts
Justin Timberlake,Cry me a river
P.S. filepath format in the snippet is intended for Windows, for Linux just use ~/tracks.csv
print(author, ",'", data['title'], "'", "sep="", file=f)
or apply whatever rules you want –
Guadalajara © 2022 - 2024 — McMap. All rights reserved.