|
|
|
|
@ -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.")
|