From 3ea882896cd90bb598efe2321829923db0d4e0fd Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 21 Feb 2024 11:30:13 -0500 Subject: [PATCH] test --- untested scripts/plex-analyze-cli.py | 12 +++++------- untested scripts/plex-analyze-curl.py | 11 ++++++----- untested scripts/plex-analyzedeeply-cli.py | 11 ++++------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/untested scripts/plex-analyze-cli.py b/untested scripts/plex-analyze-cli.py index 6ab2d4f..dcce61a 100644 --- a/untested scripts/plex-analyze-cli.py +++ b/untested scripts/plex-analyze-cli.py @@ -2,11 +2,8 @@ # Plex analayze all files that are missing analyzation info # OS: Ubunti 16.04 ( in case of other OS's make sure to change paths ) -from subprocess import call import os -import requests import sqlite3 -import sys conn = sqlite3.connect('/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db') @@ -15,9 +12,10 @@ c.execute('Select media_items.metadata_item_id As id, metadata_items.title As ti items = c.fetchall() conn.close() -print("To analyze: " + str( len(items) )) + +print("To analyze: %s" % len(items)) for row in items: - os.system('LD_LIBRARY_PATH=/usr/lib/plexmediaserver PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application\ Support /usr/lib/plexmediaserver/Plex\ Media\ Scanner -a -o ' + str(row[0])) - os.system('sleep 1') - print(str(row[0])) + os.system('LD_LIBRARY_PATH=/usr/lib/plexmediaserver PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application\ Support /usr/lib/plexmediaserver/Plex\ Media\ Scanner -a -o ' + str(row[0])) + os.system('sleep 1') + print(str(row[0])) diff --git a/untested scripts/plex-analyze-curl.py b/untested scripts/plex-analyze-curl.py index 69851f0..a5172d9 100644 --- a/untested scripts/plex-analyze-curl.py +++ b/untested scripts/plex-analyze-curl.py @@ -1,9 +1,9 @@ +#!/usr/bin/env python3 # Plex analayze all files that are missing analyzation info using CURL calls # OS: Ubunti 16.04 ( in case of other OS's make sure to change paths ) # Replace xxx with your plex token, you can get it by: # grep -E -o "PlexOnlineToken=.{0,22}" /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml -#!/usr/bin/env python3 import requests import sqlite3 @@ -14,8 +14,9 @@ c.execute('select metadata_item_id from media_items where bitrate is null') items = c.fetchall() conn.close() -print("To analyze: " + str( len(items) )) + +print("To analyze: %s" % len(items)) for row in items: - requests.put(url='http://127.0.0.1:32400/library/metadata/' + str(row[0]) + '/analyze?X-Plex-Token=xxx') - requests.get(url='http://127.0.0.1:32400/library/metadata/' + str(row[0]) + '/refresh?X-Plex-Token=xxx') - print(str(row[0])) + requests.put(url='http://127.0.0.1:32400/library/metadata/' + str(row[0]) + '/analyze?X-Plex-Token=xxx') + requests.get(url='http://127.0.0.1:32400/library/metadata/' + str(row[0]) + '/refresh?X-Plex-Token=xxx') + print(str(row[0])) diff --git a/untested scripts/plex-analyzedeeply-cli.py b/untested scripts/plex-analyzedeeply-cli.py index 35bd369..14d88ac 100644 --- a/untested scripts/plex-analyzedeeply-cli.py +++ b/untested scripts/plex-analyzedeeply-cli.py @@ -1,10 +1,7 @@ #!/usr/bin/env python3 # analyzedeeply.cli will preform deep analyzation only on files that were not processed yet -from subprocess import call import os -import requests import sqlite3 -import sys import time conn = sqlite3.connect('/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db') @@ -20,16 +17,16 @@ items = c.fetchall() conn.close() print("ANALYZE DEEPLY START") -print("Number of video files to process: " + str( len(items) )) +print("Number of video files to process: %s" % len(items)) start_time = time.time() for row in items: - print ("Processing video id: " + str(row[0])) + print("Processing video id: %s" % row[0]) start_row = time.time() os.system('LD_LIBRARY_PATH=/usr/lib/plexmediaserver \ PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application\ Support \ /usr/lib/plexmediaserver/Plex\ Media\ Scanner --analyze-deeply -o ' + str(row[0])) end_row = time.time() - print ("Video id:" + str(row[0]) + " took {:.2f} seconds to process".format(end_row - start_row)) + print("Video id: %s took %s seconds to process" % (row[0], "{:.2f}".format(end_row - start_row))) end_time = time.time() -print ("Files proccessed:" + str(row[0]) + " in {:.2f} seconds".format(end_row - start_row)) +print("Files proccessed: %s in %s seconds" % (row[0], "{:.2f}".format(end_row - start_row)))