Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3712

Youtube v3 Api Get video by ID

$
0
0

How can I get a single video by its ID using the Youtube API v3.

So far I've only come across search mechanisms and other, but not specifically one to get a single video, the code that I have currently is:

def youtube_search(q, max_results=1,order="relevance", token=None, location=None, location_radius=None):   youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, developerKey=DEVELOPER_KEY)   search_response = youtube.search().list(    q=q,    type="video",    pageToken=token,    order = order,    part="id,snippet",    maxResults=max_results,    location=location,    locationRadius=location_radius   ).execute()  videos = []  for search_result in search_response.get("items", []):    if search_result["id"]["kind"] == "youtube#video":        videos.append(search_result)  try:    nexttok = search_response["nextPageToken"]    return(nexttok, videos)  except Exception as e:    nexttok = "last_page"    return(nexttok, videos)

But I've realized that this method is not efficient but rather wastes time and resources. How can I go about it?


Viewing all articles
Browse latest Browse all 3712

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>