update system to use find Highlights *not tested
This commit is contained in:
1 parent
38e0cc6764
commit
7c96a5131b
8 files changed
+211
-86
No files matched your search
@@ -11,14 +11,25 @@ from package.config import DB as DB
|
||||
from package.hash_tags import get_top_nouns as get_top_nouns
|
||||
from package.youtube.uploader import upload_video as upload_video
|
||||
from package.youtube.uploader import CategoryId as CategoryId
|
||||
from package.tiktok.uploader import upload_to_tiktok as upload_to_tiktok
|
||||
|
||||
from package.database import TwitchVideo, YoutubeInfo, Data
|
||||
from package.database import TwitchVideo, YoutubeInfo, TiktokInfo, Data, TiktokInfo
|
||||
|
||||
def process_videos(video_type: bool = True, limit: int = 22):
|
||||
count = 0 # count how many videos we have upload and stop at var: limit
|
||||
videos = DB.get_unuploaded_chats() if video_type else DB.get_unuploaded_shorts()
|
||||
file_type = "download/video" if video_type else "download/clips"
|
||||
meta_data: Data = DB.get_data()[0]
|
||||
meta_data: Data = DB.get_data()
|
||||
|
||||
#current_time = datetime.now(TZ)
|
||||
#current_time = current_time.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
|
||||
#meta_data.date_videos = current_time
|
||||
#meta_data.date_shorts = current_time
|
||||
#meta_data.date_tiktok = current_time
|
||||
#meta_data.date_videos_chats = current_time
|
||||
|
||||
#DB.insert(meta_data) # ensure we have a record in the database
|
||||
|
||||
current_time = datetime.now(TZ)
|
||||
next_time = meta_data.date_videos if video_type else meta_data.date_shorts
|
||||
@@ -62,17 +73,14 @@ def process_videos(video_type: bool = True, limit: int = 22):
|
||||
|
||||
if video_type:
|
||||
origin_clipped = "Originally Streamed on"
|
||||
hashs = "#Twitch"
|
||||
else:
|
||||
origin_clipped = f"Clipped By: {video.creator_name}, on"
|
||||
hashs = "#Shorts #Clips #Twitch"
|
||||
|
||||
description = f"Game: {video.game_name}, {origin_clipped} {created_at.strftime("%Y-%m-%d %H:%M:%S %Z (%:z)")}, {hashs} Every Friday and Sunday @7:30 ET https://twitch.tv/teampgp"
|
||||
privatcyStatus = 'private'
|
||||
tags = ['gaming', 'TeamPGP', f'{video.game_name}', f'{video.creator_name}', 'Level1Techs', 'twitch']
|
||||
if not video_type:
|
||||
tags.extend(['shorts', 'twitch_clips', 'clips'])
|
||||
tags.extend([video.id])
|
||||
tags.extend([video.id])
|
||||
|
||||
if srt_path.exists():
|
||||
try:
|
||||
@@ -80,7 +88,11 @@ def process_videos(video_type: bool = True, limit: int = 22):
|
||||
except Exception as e:
|
||||
print(f"⚠️ Could not get nouns from {srt_path}: {e}")
|
||||
|
||||
youtube_info = DB.get_youtube_info(video.id) or YoutubeInfo(id=video.id)
|
||||
hashs = " ".join([f"#{t}" for t in tags])
|
||||
|
||||
description = f"Game: {video.game_name}, {origin_clipped} {created_at.strftime("%Y-%m-%d %H:%M:%S %Z (%:z)")}, {hashs} Every Friday and Sunday @7:30 ET https://twitch.tv/teampgp"
|
||||
|
||||
youtube_info = DB.get_youtube_info_for_video(video.id) or YoutubeInfo(twitch_video_id=video.id)
|
||||
|
||||
if youtube_info.yt_id:
|
||||
main_video_id = youtube_info.yt_id
|
||||
@@ -118,8 +130,7 @@ def process_videos(video_type: bool = True, limit: int = 22):
|
||||
youtube_info.yt_short_date = datetime.now(TZ)
|
||||
|
||||
DB.insert(youtube_info)
|
||||
#release_time += timedelta(days=1)
|
||||
release_time += timedelta(hours=12) # release every 12 hours instead of every day
|
||||
release_time += timedelta(days=0.5)
|
||||
|
||||
# Update global release pointer once at end
|
||||
if video_type:
|
||||
@@ -127,6 +138,49 @@ def process_videos(video_type: bool = True, limit: int = 22):
|
||||
else:
|
||||
DB.update_date_shorts(release_time)
|
||||
|
||||
def process_tiktoks():
|
||||
tiktoks = DB.get_unuploaded_tiktok()
|
||||
data = DB.get_data()
|
||||
meta_data: Data = data[0]
|
||||
|
||||
release_time = meta_data.date_tiktok
|
||||
|
||||
current_time = datetime.now(TZ)
|
||||
release_time = datetime.strptime(release_time, "%Y-%m-%d %H:%M:%S%z")
|
||||
|
||||
count = 0
|
||||
|
||||
if current_time > release_time:
|
||||
release_time = current_time
|
||||
release_time = release_time.replace(hour=12, minute=0, second=0, microsecond=0)
|
||||
|
||||
for tiktok in tiktoks:
|
||||
if count >= 10:
|
||||
break
|
||||
created_at = datetime.strptime(tiktok.created_at, "%Y-%m-%d %H:%M:%S%z").astimezone(TZ)
|
||||
tags = ["Twitch", "TeamPGP", f"{tiktok.game_name}", f"{tiktok.creator_name}", "Level1Techs", "clips"]
|
||||
origin_clipped = f"Clipped By: {tiktok.creator_name}, on"
|
||||
description = f"Game: {tiktok.game_name}, {origin_clipped} {created_at.strftime("%Y-%m-%d %H:%M:%S %Z (%:z)")}, Every Friday and Sunday @7:30 ET https://twitch.tv/teampgp"
|
||||
original_path = f"download/clips/{tiktok.id}/{tiktok.id}.mp4"
|
||||
file_path = f"download/clips/{tiktok.id}/{tiktok.id}_gaussian_9_16.mp4"
|
||||
file_csv = f"download/clips/{tiktok.id}/{tiktok.id}_{meta_data.name}.csv"
|
||||
|
||||
srt_path = f"download/clips/{tiktok.id}/{tiktok.id}.srt"
|
||||
|
||||
try:
|
||||
tags.extend(get_top_nouns(str(srt_path), (15 - len(tags))))
|
||||
except Exception as e:
|
||||
print(f"⚠️ Could not get nouns from {srt_path}: {e}")
|
||||
|
||||
if not os.path.exists(file_path):
|
||||
file_path = f"download/clips/{tiktok.id}/{tiktok.id}_black_9_16.mp4"
|
||||
if not os.path.exists(file_path):
|
||||
continue
|
||||
if tiktok_video_id := upload_to_tiktok(file_path, description, tags, "teampgpunofficialarchive"):
|
||||
tiktok_info = TiktokInfo(twitch_video_id=tiktok.id, tiktok_id=tiktok_video_id, tiktok_date=datetime.now(TZ))
|
||||
DB.insert(tiktok_info)
|
||||
count += 1
|
||||
|
||||
def process_shorts():
|
||||
process_videos(False)
|
||||
return
|
||||
@@ -275,6 +329,7 @@ def process_chats():
|
||||
|
||||
|
||||
def process_uploads():
|
||||
#process_tiktoks()
|
||||
process_shorts()
|
||||
#process_chats()
|
||||
|
||||
|
||||
Reference in new issue
Block a user