created new files for transcribing videos , find tranding hashtags
This commit is contained in:
+98
-30
@@ -27,47 +27,115 @@ def run_linux_command(command: str):
|
||||
# Handles errors if the Linux command returns a non-zero exit code
|
||||
return {"success": False, "stdout": e.stdout, "stderr": e.stderr}
|
||||
|
||||
def download_vods():
|
||||
def transcribe(slug: str):
|
||||
"""Transcribes the Video File."""
|
||||
video_file = f"save/clips/{slug}/{slug}.mp4"
|
||||
|
||||
# Check if the video file exists
|
||||
if not os.path.exists(video_file):
|
||||
print(f"Error: File not found: {video_file}")
|
||||
return False
|
||||
|
||||
# no need to continue if srt transcribe file already exists
|
||||
if os.path.exists(f"save/clips/{slug}/transcribe_{slug}.srt"):
|
||||
print(f"video already transcribed:")
|
||||
return True
|
||||
|
||||
import transcribe_video
|
||||
transcribe_video.extract_audio(video_file, f"save/clips/{slug}/temp_{slug}_audio.wav")
|
||||
transcribe_video.transcribe_to_srt(f"save/clips/{slug}/temp_{slug}_audio.wav", f"save/clips/{slug}/", f"transcribe_{slug}")
|
||||
|
||||
return True
|
||||
|
||||
def top_hashtags(slug: str):
|
||||
file_srt = f"save/clips/{slug}/transcribe_{slug}.srt"
|
||||
|
||||
# if srt transcribe file not exists
|
||||
if not os.path.exists(file_srt):
|
||||
print(f"Transcribe file not found {file_srt}")
|
||||
return []
|
||||
|
||||
import youtube_hashtags
|
||||
|
||||
return youtube_hashtags.get_top_hashtags(file_srt)
|
||||
|
||||
def download():
|
||||
"""Find all undownload vods and download them."""
|
||||
undownloaded_vods = DB.get_undownloaded()
|
||||
undownloaded = DB.get_undownloaded()
|
||||
|
||||
print("Download VODs...")
|
||||
print(f"Download {DB.table}...")
|
||||
|
||||
for record_id, record_date, title, game_name, downloaded, uploaded_yt, chat_upload_yt in undownloaded_vods:
|
||||
print(f"ID: {record_id} | Date: {record_date} | Game: {game_name} | Title: {title}")
|
||||
output = run_linux_command(f"TwitchDownloaderCLI videodownload --id {record_id} -o save/vods/{record_id}/{title}.mp4")
|
||||
output2 = run_linux_command(f"TwitchDownloaderCLI chatdownload --id {record_id} -o save/vods/{record_id}/{title}_chat.json -E")
|
||||
if output["success"] is True:
|
||||
print(f"ID: {record_id} | Date: {record_date} | Game: {game_name} | Title: {title} | was successful")
|
||||
DB.mark_as_downloaded(record_id)
|
||||
else:
|
||||
print(f"ID: {record_id} | Date: {record_date} | Game: {game_name} | Title: {title} | was Failed")
|
||||
if DB.table == "vods":
|
||||
for record_id, record_date, title, game_name, downloaded, uploaded_yt, chat_upload_yt in undownloaded:
|
||||
print(f"ID: {record_id} | Date: {record_date} | Game: {game_name} | Title: {title}")
|
||||
output = run_linux_command(f"TwitchDownloaderCLI videodownload --id {record_id} -o save/vods/{record_id}/{title}.mp4")
|
||||
output2 = run_linux_command(f"TwitchDownloaderCLI chatdownload --id {record_id} -o save/vods/{record_id}/{title}_chat.json -E")
|
||||
if output["success"] is True:
|
||||
print(f"ID: {record_id} | Date: {record_date} | Game: {game_name} | Title: {title} | was successful")
|
||||
DB.mark_as_downloaded(record_id)
|
||||
else:
|
||||
print(f"ID: {record_id} | Date: {record_date} | Game: {game_name} | Title: {title} | was Failed")
|
||||
|
||||
print("Finished Downloading VODs...")
|
||||
elif DB.table == "clips":
|
||||
for slug, record_date, title, game_name, clip_by, views, downloaded, uploaded_yt, uploaded_shorts_yt in undownloaded:
|
||||
print(f"Slug: {slug} | Date: {record_date} | Game: {game_name} | By: {clip_by} | Views: {views} | Title: {title}")
|
||||
|
||||
# Uses standard clipdownload directive
|
||||
output = run_linux_command(f"TwitchDownloaderCLI clipdownload --id {slug} -o save/clips/{slug}/{title}.mp4")
|
||||
|
||||
if output["success"] is True:
|
||||
print(f"Slug: {slug} | Was successfully downloaded.")
|
||||
DB.mark_as_downloaded(slug)
|
||||
else:
|
||||
print(f"Slug: {slug} | Download Process failed. {output["stdout"]}. Error: {output["stderr"]}")
|
||||
|
||||
def upload_vods():
|
||||
|
||||
print(f"Finished Downloading {DB.table}...")
|
||||
|
||||
def upload():
|
||||
"""Loops over the downloaded videos entries and uploaded them to youtube."""
|
||||
print("Uploading Clips...")
|
||||
print(f"Uploading {DB.table}...")
|
||||
|
||||
unuploaded_vods = DB.get_unuploaded()
|
||||
unuploaded = DB.get_unuploaded()
|
||||
|
||||
for record_id, record_date, title, game_name, downloaded, uploaded_yt, chat_upload_yt in unuploaded_vods:
|
||||
print(f"ID: {record_id} | Date: {record_date} | Game: {game_name} | Title: {title}")
|
||||
if DB.table == "vods":
|
||||
for record_id, record_date, title, game_name, downloaded, uploaded_yt, chat_upload_yt in unuploaded_vods:
|
||||
print(f"ID: {record_id} | Date: {record_date} | Game: {game_name} | Title: {title}")
|
||||
|
||||
file_path = f"save/vods/{record_id}/{title}.mp4"
|
||||
title = title
|
||||
description = f"Game: {game_name}, on {record_date}, #Shorts"
|
||||
categoryId = CategoryId.GAMING
|
||||
privatcyStatus = 'private'
|
||||
tags = ['gaming', 'TeamPGP', f'{game_name}']
|
||||
file_path = f"save/vods/{record_id}/{title}.mp4"
|
||||
title = title
|
||||
description = f"Game: {game_name}, on {record_date}, #VODS #Twitch Every Friday and Sunday @7:30 EST https://twitch.tv/teampgp"
|
||||
categoryId = CategoryId.GAMING
|
||||
privatcyStatus = 'private'
|
||||
tags = ['gaming', 'TeamPGP', f'{game_name}', 'twitch_vods', 'vods', 'Level1Techs', 'twitch']
|
||||
|
||||
output = uploader.upload_video(file_path, title, description, categoryId, privatcyStatus, tags)
|
||||
output = uploader.upload_video(file_path, title, description, categoryId, privatcyStatus, tags)
|
||||
|
||||
if output is True:
|
||||
print(f"ID: {record_id} | Was successfully uploaded.")
|
||||
DB.mark_as_uploaded(record_id)
|
||||
else:
|
||||
print(f"ID: {record_id} | Upload Process failed.")
|
||||
if output is True:
|
||||
print(f"ID: {record_id} | Was successfully uploaded.")
|
||||
DB.mark_as_uploaded(record_id)
|
||||
else:
|
||||
print(f"ID: {record_id} | Upload Process failed.")
|
||||
elif DB.table == "clips":
|
||||
for slug, record_date, title, game_name, clip_by, views, downloaded, uploaded_yt in unuploaded_clips:
|
||||
print(f"Slug: {slug} | Date: {record_date} | Game: {game_name} | By: {clip_by} | Views: {views} | Title: {title}")
|
||||
|
||||
file_path = f"save/clips/{slug}/{title}.mp4"
|
||||
title = title
|
||||
description = f"Game: {game_name}, Cliped By: {clip_by}, on {record_date}, #Shorts #Clips #Twitch Every Friday and Sunday @7:30 EST https://twitch.tv/teampgp"
|
||||
categoryId = CategoryId.GAMING
|
||||
privatcyStatus = 'private'
|
||||
tags = ['shorts', 'gaming', 'TeamPGP', f'{game_name}', f'{clip_by}', 'twitch_clips', 'clips', 'Level1Techs', 'twitch']
|
||||
|
||||
tags.extend(top_hashtags({slug}))
|
||||
|
||||
#output = uploader.upload_video(file_path, title, categoryId, description, privatcyStatus, tags)
|
||||
|
||||
if output is True:
|
||||
print(f"Slug: {slug} | Was successfully uploaded.")
|
||||
DB.mark_as_uploaded(slug)
|
||||
else:
|
||||
print(f"Slug: {slug} | Upload Process failed.")
|
||||
|
||||
def create_chat_vods():
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user