updated missing to active

main
oscar 1 month ago
parent 6c1c2970e8
commit ff0d790570

@ -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:
@ -52,16 +52,13 @@ def update_video_paths(cursor, conn):
with tqdm(videos, desc="Updating filepaths...") as pbar:
for vid in videos:
filepath = vid['filepath']
status = vid['status']
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 = []
@ -280,15 +277,15 @@ if __name__ == '__main__':
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.")

@ -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():

@ -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 = []

@ -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

@ -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():

Loading…
Cancel
Save