mirror of
https://github.com/sigma67/ytmusicapi.git
synced 2026-04-24 23:06:13 +03:00
[GH-ISSUE #861] Add get_channel_type method #526
Labels
No labels
a/b
bug
documentation
enhancement
good first issue
help wanted
invalid
pull-request
question
wontfix
yt-error
yt-update
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ytmusicapi#526
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mayty on GitHub (Jan 28, 2026).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/861
Is your feature request related to a problem? Please describe.
I have a workflow that goes like this:
channelIdfrom YouTube handle usingv3/channelsYouTube data apichannelIdusingytmusicapiThe issue happens on step 2, as
channelIdproduced in the first step can lead to channels of different types, which need to be scraped using different methods:@RammsteinOfficial->UCYp3rk70ACGXQ4gFAiMr1SQ->YTMusic.get_artist()@4tunenocopyrightmusic881->UC44hbeRoCZVVMVg5z0FfIww->YTMusic.get_user()@LinusTechTips->UCXuqSBlHAE6Xw-yeJA0Tunw->YTMusic.get_channel()Describe the solution you'd like
A method to determine channel type:
YTMusic.get_channel_type(channelId: str) -> ChannelTypeDescribe alternatives you've considered
If for determining channel type the same request is required as for channel scraping, scraping result can be returned instead of type only:
YTMusic.get_generic_channel(channelId: str) -> tuple[ChannelType, GetArtistResponse | GetUserResponse | GetChannelResponse]@sigma67 commented on GitHub (Jan 29, 2026):
Sure, any suggestion how to achieve it other than trial and error? Because that can be done by the user easily right now.
@mayty commented on GitHub (Jan 29, 2026):
From what I can see, it can go like this (based on the html I see in my browser):
While it can be done on the user side, implementing it this way seems pretty sketchy and requires multiple network calls:
@sigma67 commented on GitHub (Jan 31, 2026):
Right, the
guess_account_typeis obviously not an option.Just to make it clear, this library doesn't operate on the HTML page. It uses the JSON API that YouTube Music is built on.
@sigma67 commented on GitHub (Jan 31, 2026):
They all use the
/browseendpoint, so if you can figure out a surefire way based on the JSON response to tell which of the three types it is, feel free to submit a PR.Please use an enum for the return value. I do wonder if it might not be more convenient to simply return the correct response after determining the type of the account (because that's what the user would most likely do anyway?)
@Daveson217 commented on GitHub (Feb 1, 2026):
@mayty, what are possible value/options for proposed ChannelType other than artist? Is there a classification somewhere?
@mayty commented on GitHub (Feb 1, 2026):
@Daveson217 artist, user, and channel, corresponding to
get_artist,get_user, andget_channelmethods. In my PR I called enumProfileTypes, so there is no weird ambiguity of channel type "channel"