update file names, add uploader.py
This commit is contained in:
@@ -4,6 +4,9 @@ import sqlite3
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
|
||||
import uploader
|
||||
from uploader import CategoryId
|
||||
|
||||
CHANNEL_NAME = 'teampgp' # Replace with the streamer's username
|
||||
|
||||
# Stores data locally
|
||||
@@ -52,10 +55,33 @@ def download_clips():
|
||||
print(f"Slug: {slug} | Was successfully downloaded.")
|
||||
mark_as_downloaded(slug)
|
||||
else:
|
||||
print(f"Slug: {slug} | Process failed.")
|
||||
print(f"Slug: {slug} | Download Process failed.")
|
||||
|
||||
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):
|
||||
"""Executes a Linux command, waits for completion, and returns output."""
|
||||
try:
|
||||
@@ -66,6 +92,14 @@ def run_linux_command(command: str):
|
||||
except subprocess.CalledProcessError as e:
|
||||
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):
|
||||
"""Flags a specific clip row record to downloaded (1)."""
|
||||
CURSOR.execute(
|
||||
@@ -74,6 +108,13 @@ def mark_as_downloaded(slug: str):
|
||||
)
|
||||
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():
|
||||
"""Retrieves all clip rows remaining to be captured."""
|
||||
CURSOR.execute(
|
||||
@@ -187,4 +228,5 @@ if __name__ == "__main__":
|
||||
create_database()
|
||||
get_channel_clips(CHANNEL_NAME)
|
||||
download_clips()
|
||||
upload_clips()
|
||||
close_database()
|
||||
Reference in New Issue
Block a user