data and code update.
This commit is contained in:
@@ -163,7 +163,7 @@ def product_categorizer(product_lists: list, product_categories=product_categori
|
||||
return output
|
||||
|
||||
def get_youtube_channel_info(channel_name: str):
|
||||
API_KEY = 'YOUTUBE_API_KEY' # Replace with your API key
|
||||
API_KEY = YOUTUBE_API_KEY # Replace with your API key
|
||||
|
||||
url = 'https://www.googleapis.com/youtube/v3/search'
|
||||
params = {
|
||||
@@ -214,7 +214,7 @@ def get_youtube_channel_info(channel_name: str):
|
||||
|
||||
def get_channel_videos(channel_name, max_results=5):
|
||||
try:
|
||||
API_KEY = 'YOUTUBE_API_KEY'
|
||||
API_KEY = YOUTUBE_API_KEY
|
||||
# Build the YouTube service object
|
||||
youtube = build('youtube', 'v3', developerKey=API_KEY)
|
||||
|
||||
@@ -262,8 +262,27 @@ def get_channel_videos(channel_name, max_results=5):
|
||||
print(f"An HTTP error occurred: {e}")
|
||||
return []
|
||||
|
||||
def get_channel_details(channel_name):
|
||||
def get_channel_details(channel_name: str):
|
||||
channel_info = get_youtube_channel_info(channel_name)
|
||||
recent_videos = get_channel_videos(channel_name)
|
||||
channel_info['recent_videos'] = recent_videos
|
||||
return channel_info
|
||||
|
||||
# Ensure channel_info is a dictionary
|
||||
if isinstance(channel_info, dict):
|
||||
if recent_videos != "No channel found with that name.":
|
||||
channel_info['recent_videos'] = recent_videos
|
||||
else:
|
||||
channel_info['recent_videos'] = "None"
|
||||
else:
|
||||
# If channel_info is not a dict, set it to a default structure
|
||||
channel_info = {
|
||||
"Title": "Not Found",
|
||||
"Description": "Channel not found.",
|
||||
"Subscribers": "NA",
|
||||
"Total Views": "NA",
|
||||
"Total Videos": "NA",
|
||||
"recent_videos": "None"
|
||||
}
|
||||
|
||||
return channel_info
|
||||
|
||||
# print(get_channel_details("UCb1j-wdogEnOXXS5B5EhnGg"))
|
||||
Reference in New Issue
Block a user