Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Total views of a channel #172

Closed
BrianLi009 opened this issue Apr 16, 2022 · 2 comments
Closed

Total views of a channel #172

BrianLi009 opened this issue Apr 16, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@BrianLi009
Copy link

When calling ChannelsSearch, is it possible to obtain the total views of a channel? Thank you!

@mytja
Copy link
Collaborator

mytja commented Apr 16, 2022

It would certainly be possible by using Channel class, though we don't provide this feature currently.

@mytja mytja self-assigned this Apr 16, 2022
@mytja mytja added the enhancement New feature or request label Apr 16, 2022
@mytja mytja closed this as completed in 77518c5 Apr 16, 2022
@mytja
Copy link
Collaborator

mytja commented Apr 16, 2022

You can now retrieve views within Channel class. But warning - YouTube doesn't return an integer of views, so you are going to have to parse it by yourself.

Something like this should work fine:

from youtubesearchpython import Channel

c = Channel.get("UC_aEa8K-EOJ3D6gOs7HcyNg")
views = c["views"]
views = views.split(" ")
views = views[0]
views = views.replace(",", "")
views = int(views)
print(views)

As this hasn't been published to PyPI, you are going to have to install from source pip install git+https://github.com/alexmercerind/youtube-search-python

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants