YouTube channel & video details extractor
Project description
YTchannel
YouTube channel & video details extractor
Features
Retrieve:-
- Youtube Channel details
- Youtube Video details
Requirements
You need to install requests module
pip install requests
Installation
pip install YTchannel
Importing
import YTchannel.YT as yt
For Channel details
channel = yt.Channel()
Calling with a Id and API key
The first parameter must be the Channel id Check below example https://www.youtube.com/channel/UC_channel_id here in this example the channel id is UC_channel_id
try:
channel.startChannel(UC_channel_id,YOUR_API_KEY)
except KeyError:
#Invalid channel id
except ConnectionError:
#Connection error
except:
#Something went wrong
Check if the request is success
result = channel.getChannel() #this will return all details in a dictionary
if result['result'] == 'OK':
#No problem do your thing
else:
#Something wrong like - no channel found or invalid api key
#use result['code'] to get the error code or result['message'] to know the message
How to get details
print(result) #this will print all the details of a channel in a dictionary
For video details
video = yt.Video()
Calling with a Id and API key
The first parameter must be the video id Check below example https://www.youtube.com/watch?v=video_id here in this example the video id is video_id
try:
video.startVideo(video_id,YOUR_API_KEY)
except KeyError:
#Invalid video id
except ConnectionError:
#Connection error
except:
#Something went wrong
Check if the request is success
resultVideo = video.getVideo() #this will return all details in a dictionary
if resultVideo['result'] == 'OK':
#No problem do your thing
else:
#Something wrong like - no video found or invalid api key
#use resultVideo['code'] to get the error code or resultVideo['message'] to know the message
How to get details
print(resultVideo) #this will print all the details of a video in a dictionary
Any issues?
Create an issue on github
Contact me
- On twitter https://twitter.com/SanjayDevTech
Happy coding
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
YTchannel-0.0.6.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for YTchannel-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72fa2a520a7e9ce7b171ef5071a1e961540d7d3e588f059c082cc27fd0cfcbd9 |
|
MD5 | 1b1dd6eab3185edd459286d9598a3c25 |
|
BLAKE2b-256 | e260f53c477a4e0d4ee2392dc821ab8fa8d476e2c0e4c7e0176442e6dc85297f |