alexmercerind / youtube-search-python

🔎 Search for YouTube videos, channels & playlists. Get 🎞 video & 📑 playlist info using link. Get search suggestions. WITHOUT YouTube Data API v3.
MIT License
740 stars 164 forks source link

Total views of a channel #172

Closed BrianLi009 closed 2 years ago

BrianLi009 commented 2 years ago

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

mytja commented 2 years ago

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

mytja commented 2 years ago

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