Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

youtube api - retrieve "music in this video" info from video metadata?

Tags:

I have done some search on the web but could not find a way to retrieve information about a piece of music used in a video (NOT music video), using youtube api.

For example, in the description of this video or this video, there is a separate section about "music in this video", and there one can find information about the title of the song, the artist, the album, license, etc..

enter image description here

What I would like to do is to retrieve this information using youtube api. Unfortunately, so far I have not had any success spotting this piece of information using youtube api. The metadata returned simply does not contain the music information (I can retrieve information such as commentCount, dislikeCount, etc..).

Is it possible to retrieve the information of music used in a video, if such information is present in the video description? Thanks in advance!

like image 228
moonlightlane Avatar asked Jun 06 '18 03:06

moonlightlane


1 Answers

There is no documented official API method, but you can use youtube-dl from a Python program to get this information, e. g.

import youtube_dl

url = 'https://www.youtube.com/watch?v=6_b7RDuLwcI'
ydl = youtube_dl.YoutubeDL({})
with ydl:
    video = ydl.extract_info(url, download=False)

print('{} - {}'.format(video['artist'], video['track']))
like image 134
ramiro Avatar answered Oct 02 '22 12:10

ramiro