update file names, add uploader.py
This commit is contained in:
@@ -4,6 +4,9 @@ import sqlite3
|
|||||||
import subprocess
|
import subprocess
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
import uploader
|
||||||
|
from uploader import CategoryId
|
||||||
|
|
||||||
CHANNEL_NAME = 'teampgp' # Replace with the streamer's username
|
CHANNEL_NAME = 'teampgp' # Replace with the streamer's username
|
||||||
|
|
||||||
# Stores data locally
|
# Stores data locally
|
||||||
@@ -52,10 +55,33 @@ def download_clips():
|
|||||||
print(f"Slug: {slug} | Was successfully downloaded.")
|
print(f"Slug: {slug} | Was successfully downloaded.")
|
||||||
mark_as_downloaded(slug)
|
mark_as_downloaded(slug)
|
||||||
else:
|
else:
|
||||||
print(f"Slug: {slug} | Process failed.")
|
print(f"Slug: {slug} | Download Process failed.")
|
||||||
|
|
||||||
print("Finished Downloading Clips...")
|
print("Finished Downloading Clips...")
|
||||||
|
|
||||||
|
def upload_clips():
|
||||||
|
"""Loops over the downloaded videos entries and uploaded them to youtube."""
|
||||||
|
print("Uploading Clips...")
|
||||||
|
|
||||||
|
unpuloaded_clips = get_unuploaded_clips()
|
||||||
|
|
||||||
|
for slug, record_date, title, game_name, clip_by, views, downloaded, uploaded_yt in unpuloaded_clips:
|
||||||
|
print(f"Slug: {slug} | Date: {record_date} | Game: {game_name} | By: {clip_by} | Views: {views} | Title: {title}")
|
||||||
|
|
||||||
|
file_path = f"save/clips/{slug}/{slug}.mp4"
|
||||||
|
title = title
|
||||||
|
description = f"Game: {game_name}, Cliped By: {clip_by}, on {record_date}"
|
||||||
|
categoryId = CategoryId.SHORTS
|
||||||
|
privatcyStatus = 'private'
|
||||||
|
tags = ['#SHORT', '#GAMING', '#TeamPGP', f'#{game_name}', f'#{clip_by}']
|
||||||
|
|
||||||
|
if (uploader.upload_video(file_path, title, description, categoryId, privatcyStatus, tags) is True):
|
||||||
|
print(f"Slug: {slug} | Was successfully uploaded.")
|
||||||
|
|
||||||
|
mark_as_uploaded(slug)
|
||||||
|
else:
|
||||||
|
print(f"Slug: {slug} | Upload Process failed.")
|
||||||
|
|
||||||
def run_linux_command(command: str):
|
def run_linux_command(command: str):
|
||||||
"""Executes a Linux command, waits for completion, and returns output."""
|
"""Executes a Linux command, waits for completion, and returns output."""
|
||||||
try:
|
try:
|
||||||
@@ -65,6 +91,14 @@ def run_linux_command(command: str):
|
|||||||
return {"success": True, "stdout": result.stdout, "stderr": result.stderr}
|
return {"success": True, "stdout": result.stdout, "stderr": result.stderr}
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
return {"success": False, "stdout": e.stdout, "stderr": e.stderr}
|
return {"success": False, "stdout": e.stdout, "stderr": e.stderr}
|
||||||
|
|
||||||
|
def mark_as_uploaded(slug: str):
|
||||||
|
"""Flags a specific clip row record to uploaded (1)."""
|
||||||
|
CURSOR.execute(
|
||||||
|
"UPDATE clips SET uploaded_yt = 1 WHERE slug = ?",
|
||||||
|
(slug,)
|
||||||
|
)
|
||||||
|
CONN.commit()
|
||||||
|
|
||||||
def mark_as_downloaded(slug: str):
|
def mark_as_downloaded(slug: str):
|
||||||
"""Flags a specific clip row record to downloaded (1)."""
|
"""Flags a specific clip row record to downloaded (1)."""
|
||||||
@@ -74,6 +108,13 @@ def mark_as_downloaded(slug: str):
|
|||||||
)
|
)
|
||||||
CONN.commit()
|
CONN.commit()
|
||||||
|
|
||||||
|
def get_unuploaded_clips():
|
||||||
|
"""Retrieves all clip rows remaining to be uploaded."""
|
||||||
|
CURSOR.execute(
|
||||||
|
"SELECT slug, date, title, gamename, clip_by, view_count, downloaded, uploaded_yt FROM clips WHERE downloaded = 1 AND uploaded_yt = 0"
|
||||||
|
)
|
||||||
|
return CURSOR.fetchall()
|
||||||
|
|
||||||
def get_undownloaded_clips():
|
def get_undownloaded_clips():
|
||||||
"""Retrieves all clip rows remaining to be captured."""
|
"""Retrieves all clip rows remaining to be captured."""
|
||||||
CURSOR.execute(
|
CURSOR.execute(
|
||||||
@@ -187,4 +228,5 @@ if __name__ == "__main__":
|
|||||||
create_database()
|
create_database()
|
||||||
get_channel_clips(CHANNEL_NAME)
|
get_channel_clips(CHANNEL_NAME)
|
||||||
download_clips()
|
download_clips()
|
||||||
|
upload_clips()
|
||||||
close_database()
|
close_database()
|
||||||
Reference in New Issue
Block a user