Searching for music videos yields many results that are not music videos - e.g. interviews with the searched for artist. In my opinion only music videos should be in the Music category, or there should be a separate category for Music videos, or videos should be tagged with multiple categories upon which we can logically filter.
Is there any functionality/filter which I can use along with the API to return only the music videos.
Following is my code:-
def search_videos(self,keyword,maxResults=10):
youtube = build('youtube','v3',developerKey=KEY)
response = youtube.search().list(q=keyword,
part="id,snippet",
maxResults=maxResults
).execute().get("items", [])
videos = []
for record in response:
if record["id"]["kind"] == "youtube#video":
title = record["snippet"]["title"].encode(encoding='UTF-8',errors='strict')
youtube_id = record["id"]["videoId"].encode(encoding='UTF-8',errors='strict')
videos.append({
'youtube_id': youtube_id,
'title' : title
})
return videos