I forgot what I chanagerd
This commit is contained in:
1 parent
24081e1576
commit
c4f5018833
20 files changed
+678
-77
No files matched your search
@@ -14,9 +14,10 @@ from package.youtube.uploader import CategoryId as CategoryId
|
||||
|
||||
from package.database import TwitchVideo, YoutubeInfo, Data
|
||||
|
||||
def process_videos(video_type: bool = True):
|
||||
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/clips" if video_type else "download/video"
|
||||
file_type = "download/video" if video_type else "download/clips"
|
||||
meta_data: Data = DB.get_data()[0]
|
||||
|
||||
current_time = datetime.now(TZ)
|
||||
@@ -29,6 +30,10 @@ def process_videos(video_type: bool = True):
|
||||
release_time += timedelta(days=1)
|
||||
|
||||
for video in videos:
|
||||
#We reached limit stop uploading videos
|
||||
if count >= limit:
|
||||
break
|
||||
|
||||
base_path = Path(f"{file_type}/{video.id}/{video.id}")
|
||||
original_path = base_path.with_suffix(".mp4")
|
||||
|
||||
@@ -66,6 +71,7 @@ def process_videos(video_type: bool = True):
|
||||
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])
|
||||
|
||||
if srt_path.exists():
|
||||
try:
|
||||
@@ -78,7 +84,8 @@ def process_videos(video_type: bool = True):
|
||||
if youtube_info.yt_id:
|
||||
main_video_id = youtube_info.yt_id
|
||||
else:
|
||||
main_video_id = upload_video(str(original_path), video.title, category_id, description, 'unlisted', tags)
|
||||
main_video_id = upload_video(str(original_path), video.title, category_id, f"{description} \n\n({video.id})", 'unlisted', tags)
|
||||
count += 1
|
||||
if not main_video_id:
|
||||
print(f"❌ Error: main video upload failed for {original_path}")
|
||||
continue
|
||||
@@ -86,7 +93,7 @@ def process_videos(video_type: bool = True):
|
||||
youtube_info.yt_date = datetime.now(TZ)
|
||||
|
||||
# Upload secondary
|
||||
secondary_desc = f"{description} Original Full size @ https://youtu.be/{main_video_id}"
|
||||
secondary_desc = f"{description} Original Full size @ https://youtu.be/{main_video_id} \n\n({video.id})"
|
||||
secondary_video_id = upload_video(str(file_path), video.title, category_id, secondary_desc, 'private', tags, release_time)
|
||||
|
||||
if not secondary_video_id:
|
||||
@@ -94,6 +101,8 @@ def process_videos(video_type: bool = True):
|
||||
DB.insert(youtube_info) # save main id at least
|
||||
continue
|
||||
|
||||
count += 1
|
||||
|
||||
# Success - write CSV and DB
|
||||
data_csv = [main_video_id, secondary_video_id, release_time.isoformat()]
|
||||
utils.write_csv([data_csv], str(file_csv))
|
||||
|
||||
Reference in new issue
Block a user