If you'll issue the following command (at any GNU/Linux bash
prompt):
$ wget \
--quiet \
--output-document=- \
--content-on-error \
"https://www.googleapis.com/youtube/v3/channels?key=$APP_KEY&id=UCk8LWzqGcHz21FWysiXuCHw&part=brandingSettings,contentDetails,id,snippet,statistics,status,topicDetails&maxResults=1"
you'll see that лучшиедокументальныефильмы
is not the channel's user name, but its customUrl
!
The forUsername
property does not function for a given channel's custom URL since these URLs are not guaranteed to uniquely represent any given channel.
Do convince yourself by querying on Google's issue tracker for either of these two phrases channels forusername
or vanity URL
to see the terse/raw official responses users got from Google's staff.
Indeed, at times, the official docs and staff responses do lack useful/meaningful clear-cut specifications and/or formulations. (I already experienced all these myself too!)
As a final note, you may scrape out of the HTML page obtained from https://www.youtube.com/c/лучшиедокументальныефильмы
the channel ID of your interest, but please bear in mind that this activity is forbidden by Google, as per its DTOS docs
:
Scraping
You and your API Clients must not, and must not encourage, enable, or require others to, directly or indirectly, scrape YouTube Applications or Google Applications, or obtain scraped YouTube data or content. Public search engines may scrape data only in accordance with YouTube's robots.txt file or with YouTube's prior written permission.
Instead of scraping, I'd recommend using the Search.list
API endpoint, invoked with the q
parameter being лучшиедокументальныефильмы
and the type
parameter being channel
(if you're able to cope with the fuzziness implied).
Update upon answering to a related SO question
Here is a simple Python3 script implementing the functionality that you're looking for. Applying your custom URL to this script produces the expected result:
$ python3 youtube-search.py \
--custom-url Лучшиедокументальныефильмы \
--app-key ...
UCk8LWzqGcHz21FWysiXuCHw
$ python3 youtube-search.py \
--user-name Лучшиедокументальныефильмы \
--app-key ...
youtube-search.py: error: user name "Лучшиедокументальныефильмы": no associated channel found
Note that you have to pass to this script your application key as argument to the command line option --app-key
(use --help
for brief help info).