From ff0d7905701fc9e74cd4279662cd522ee9651480 Mon Sep 17 00:00:00 2001 From: oscar <> Date: Mon, 22 Sep 2025 04:33:27 -0700 Subject: [PATCH] updated missing to active --- cleanup.py | 27 ++++++++++++--------------- concater.py | 4 ++-- helpers/db.py | 2 +- sorter.py | 2 +- superencoderav.py | 12 ++++++------ 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/cleanup.py b/cleanup.py index 4024201..5862613 100644 --- a/cleanup.py +++ b/cleanup.py @@ -34,7 +34,7 @@ def find_video_path(video_id: str): return all_videos[video_id] if video_id in all_videos else None def mark_missing_videos(cursor, conn): - cursor.execute("SELECT video_id, filepath FROM videos WHERE status != 'missing'") + cursor.execute("SELECT video_id, filepath FROM videos WHERE status = 'active'") videos = cursor.fetchall() with tqdm(videos, desc="Scanning for missing videos...") as pbar: @@ -51,17 +51,14 @@ def update_video_paths(cursor, conn): videos = cursor.fetchall() with tqdm(videos, desc="Updating filepaths...") as pbar: - for vid in videos: - filepath = vid['filepath'] - status = vid['status'] - + for vid in videos: path = find_video_path(vid['video_id']) if not path: continue path = path.replace("\\", "/") - if path == filepath and status != 'missing': # change this + if path == vid['filepath']: continue cursor.execute("UPDATE videos SET filepath = %s, status = 'active' WHERE id = %s", (path, vid['id'])) @@ -69,7 +66,7 @@ def update_video_paths(cursor, conn): pbar.update(1) def fill_missing_hashes(cursor, conn): - cursor.execute("SELECT video_id, filepath FROM videos WHERE (hash IS NULL OR hash = '') AND status != 'missing'") + cursor.execute("SELECT video_id, filepath FROM videos WHERE (hash IS NULL OR hash = '') AND status = 'active'") videos = cursor.fetchall() with tqdm(videos, desc="Updating hashes...") as pbar: @@ -82,7 +79,7 @@ def fill_missing_hashes(cursor, conn): pbar.update(1) def fill_missing_sizes(cursor, conn): - cursor.execute("SELECT video_id, filepath FROM videos WHERE size = 0 AND status != 'missing'") + cursor.execute("SELECT video_id, filepath FROM videos WHERE size = 0 AND status = 'active'") videos = cursor.fetchall() with tqdm(videos, desc="Updating sizes...") as pbar: @@ -95,7 +92,7 @@ def fill_missing_sizes(cursor, conn): pbar.update(1) def fill_missing_durations(cursor, conn): - cursor.execute("SELECT video_id, filepath FROM videos WHERE duration = 0 AND status != 'missing' ORDER BY size ASC") + cursor.execute("SELECT video_id, filepath FROM videos WHERE duration = 0 AND status = 'active' ORDER BY size ASC") videos = cursor.fetchall() with tqdm(videos, desc="Updating durations...") as pbar: @@ -139,7 +136,7 @@ def fill_missing_gender(cursor, conn): return False return data - cursor.execute("SELECT DISTINCT username, site FROM videos WHERE gender IS NULL AND status != 'missing'") + cursor.execute("SELECT DISTINCT username, site FROM videos WHERE gender IS NULL AND status = 'active'") videos = cursor.fetchall() api_fetches = 10 @@ -168,7 +165,7 @@ def fill_missing_gender(cursor, conn): pbar.update(1) def generate_thumbnails_for_videos(cursor, conn): - cursor.execute("SELECT video_id, filepath FROM videos WHERE status != 'missing' AND thumbnail IS NULL") + cursor.execute("SELECT video_id, filepath FROM videos WHERE status = 'active' AND thumbnail IS NULL") videos = cursor.fetchall() tasks = [] @@ -279,16 +276,16 @@ if __name__ == '__main__': all_videos = get_all_video_files() update_video_paths(cursor, conn) mark_missing_videos(cursor, conn) - - move_edited_videos(cursor, conn) - move_concated_videos(cursor, conn) - + generate_thumbnails_for_videos(cursor, conn) fill_missing_sizes(cursor, conn) fill_missing_durations(cursor, conn) fill_missing_gender(cursor, conn) # fill_missing_hashes(cursor, conn) + move_edited_videos(cursor, conn) + move_concated_videos(cursor, conn) + cursor.close() conn.close() print("✅ All cleanup tasks completed.") \ No newline at end of file diff --git a/concater.py b/concater.py index b3c79a0..054a89a 100644 --- a/concater.py +++ b/concater.py @@ -7,10 +7,10 @@ sort_type = {"size": lambda x: sum([video['size'] for video in x]),"count": lamb def get_videos(cursor, username=None): if username: - cursor.execute("SELECT * FROM videos WHERE username = %s AND status != 'missing';", (username,)) + cursor.execute("SELECT * FROM videos WHERE username = %s AND status = 'active';", (username,)) return cursor.fetchall() - cursor.execute("SELECT * FROM videos WHERE status != 'missing';") + cursor.execute("SELECT * FROM videos WHERE status = 'active';") return cursor.fetchall() def organize_videos(): diff --git a/helpers/db.py b/helpers/db.py index 0e8c2a2..5403137 100644 --- a/helpers/db.py +++ b/helpers/db.py @@ -16,7 +16,7 @@ def db_get_videos(username: str = None, start=None, end=None): filepath, size, duration, gender, created_at, updated_at, thumbnail FROM videos - WHERE status != 'missing' + WHERE status = 'active' """ params = [] diff --git a/sorter.py b/sorter.py index 8ce8ffb..151424f 100644 --- a/sorter.py +++ b/sorter.py @@ -5,7 +5,7 @@ if __name__ == "__main__": output_dir = 'U:/streamaster/streams/' conn, cursor = config.get_local_db_connection() - cursor.execute("SELECT * FROM videos WHERE status != 'missing' AND filepath NOT LIKE %s ORDER BY size ASC;", ("%" + output_dir + "%",)) + cursor.execute("SELECT * FROM videos WHERE status = 'active' AND filepath NOT LIKE %s ORDER BY size ASC;", ("%" + output_dir + "%",)) videos = cursor.fetchall() # process the videos diff --git a/superencoderav.py b/superencoderav.py index 57418cb..a09f0c5 100644 --- a/superencoderav.py +++ b/superencoderav.py @@ -149,7 +149,7 @@ def smart_choice(cursor, small_mb=250): SELECT v.* FROM videos v WHERE v.codec IS NULL - AND v.status <> 'missing' + AND v.status = 'active' AND v.filepath IS NOT NULL AND v.created_at >= NOW() - make_interval(days => %s) ), @@ -189,7 +189,7 @@ def smart_choice(cursor, small_mb=250): SELECT v.* FROM videos v WHERE v.codec IS NULL - AND v.status <> 'missing' + AND v.status = 'active' AND v.filepath IS NOT NULL ), by_streamer AS ( @@ -231,7 +231,7 @@ def smart_choice_by_count(cursor, small_mb=250): SELECT v.* FROM videos v WHERE v.codec IS NULL - AND v.status <> 'missing' + AND v.status = 'active' AND v.filepath IS NOT NULL AND v.created_at >= NOW() - make_interval(days => %s) ), @@ -271,7 +271,7 @@ def smart_choice_by_count(cursor, small_mb=250): SELECT v.* FROM videos v WHERE v.codec IS NULL - AND v.status <> 'missing' + AND v.status = 'active' AND v.filepath IS NOT NULL ), by_streamer AS ( @@ -300,9 +300,9 @@ def smart_choice_by_count(cursor, small_mb=250): def select_user_videos(username, cursor): if username == "all": - cursor.execute("SELECT * FROM videos WHERE status != 'missing' AND codec IS NULL ORDER BY size ASC") + cursor.execute("SELECT * FROM videos WHERE status = 'active' AND codec IS NULL ORDER BY size ASC") else: - cursor.execute("SELECT * FROM videos WHERE username = %s AND status != 'missing' AND codec IS NULL ORDER BY size ASC", (username,)) + cursor.execute("SELECT * FROM videos WHERE username = %s AND status = 'active' AND codec IS NULL ORDER BY size ASC", (username,)) return cursor.fetchall() def reencode_videos_av1():