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

How to retrieve a channel id from a channel name or url

$
0
0

I'm trying to retrieve the channel id of a YouTube channel using the new v3 API. I'm using the Python client and it seems that there is no straightforward way to find the mapping of a YouTube channel URL or name to its channel Id.

Using the Python API client, it seems that I have to issue a search query of type 'channel' for the channel name, then iterate through each search result until I find a match.

I'm going to use the http://youtube.com/atgoogletalks channel as an example

search_channel_name = 'atgoogletalks'     #Parsed from http://youtube.com/atgoogletalkssearch_response = youtube.search().list(    type='channel',    part='id,snippet',    q=search_channel_name,    maxResults=50    ).execute()for sri in search_response["items"]:    channels_response = youtube.channels().list(        id=sri["id"]["channelId"],        part="id, snippet, statistics, contentDetails, topicDetails"        ).execute()    for cr in channels_response["items"]:        channelname = cr["snippet"]["title"]        if channelname.lower() == search_channel_name:            return 'Success'

I've crawled the documentation looking for one a more straightforward way of doing this and come up short. Is there an easier way? If not, is there a plan to add this functionality to the API?


Viewing all articles
Browse latest Browse all 3637

Trending Articles



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