From ec68cd8a316ea733c106d074960609f2f2fd14b1 Mon Sep 17 00:00:00 2001 From: vijay Date: Wed, 10 Jun 2026 07:22:22 +0000 Subject: [PATCH] Delete plexdb.py --- plexdb.py | 80 ------------------------------------------------------- 1 file changed, 80 deletions(-) delete mode 100644 plexdb.py diff --git a/plexdb.py b/plexdb.py deleted file mode 100644 index 89a647f..0000000 --- a/plexdb.py +++ /dev/null @@ -1,80 +0,0 @@ -import os -import sys -import sqlite3 - -def run_db_injection(db_path): - if not os.path.exists(db_path): - print("[-] Error: Plex database not found at {}".format(db_path)) - return False - - print("[*] Connecting to Plex database: {}...".format(db_path)) - try: - conn = sqlite3.connect(db_path) - cursor = conn.cursor() - - # Print table columns for debugging - cursor.execute("PRAGMA table_info(media_parts)") - print("[*] media_parts columns: {}".format([row[1] for row in cursor.fetchall()])) - - # Inspect some STRM entries - cursor.execute("SELECT file, extra_data FROM media_parts WHERE file LIKE '%.strm' LIMIT 3") - for row in cursor.fetchall(): - print("[*] STRM Part - File: {}, Extra Data: {}".format(row[0], row[1])) - - # Find unanalyzed STRM files - cursor.execute(""" - SELECT media_parts.id, media_items.id, media_parts.file - FROM media_parts - JOIN media_items ON media_parts.media_item_id = media_items.id - WHERE media_parts.file LIKE '%.strm' AND (media_items.width IS NULL OR media_items.width = '') - """) - unanalyzed = cursor.fetchall() - - if not unanalyzed: - print("[+] All STRM files are already analyzed in the database.") - conn.close() - return True - - print("[*] Found {} unanalyzed STRM files. Injecting metadata...".format(len(unanalyzed))) - - for part_id, item_id, file_path in unanalyzed: - cursor.execute(""" - UPDATE media_items - SET width=1920, height=1080, duration=7200000, container='mkv', video_codec='h264', audio_codec='aac', - size=112 - WHERE id = ? - """, (item_id,)) - - # 2. Delete existing streams for this part to prevent duplicates - cursor.execute("DELETE FROM media_streams WHERE media_part_id = ?", (part_id,)) - - # 3. Insert Video Stream record - cursor.execute(""" - INSERT INTO media_streams ( - media_part_id, media_item_id, stream_type_id, codec, [index], language, - bitrate, created_at, updated_at - ) VALUES (?, ?, 1, 'h264', 0, 'eng', 5000000, datetime('now'), datetime('now')) - """, (part_id, item_id)) - - # 4. Insert Audio Stream record - cursor.execute(""" - INSERT INTO media_streams ( - media_part_id, media_item_id, stream_type_id, codec, [index], language, - channels, bitrate, created_at, updated_at - ) VALUES (?, ?, 2, 'aac', 1, 'eng', 2, 192000, datetime('now'), datetime('now')) - """, (part_id, item_id)) - - conn.commit() - print("[+] Successfully injected analysis metadata for {} files.".format(len(unanalyzed))) - conn.close() - return True - - except Exception as e: - print("[-] Database operation failed: {}".format(e)) - return False - -if __name__ == "__main__": - if len(sys.argv) < 2: - print("Usage: python plex_db_helper.py ") - sys.exit(1) - run_db_injection(sys.argv[1])