This commit is contained in:
deathbybandaid 2024-02-21 11:30:13 -05:00
parent baf4ab5d30
commit 3ea882896c
3 changed files with 15 additions and 19 deletions

View File

@ -2,11 +2,8 @@
# Plex analayze all files that are missing analyzation info # Plex analayze all files that are missing analyzation info
# OS: Ubunti 16.04 ( in case of other OS's make sure to change paths ) # OS: Ubunti 16.04 ( in case of other OS's make sure to change paths )
from subprocess import call
import os import os
import requests
import sqlite3 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') 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() items = c.fetchall()
conn.close() conn.close()
print("To analyze: " + str( len(items) ))
print("To analyze: %s" % len(items))
for row in 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('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') os.system('sleep 1')
print(str(row[0])) print(str(row[0]))

View File

@ -1,9 +1,9 @@
#!/usr/bin/env python3
# Plex analayze all files that are missing analyzation info using CURL calls # 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 ) # 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: # 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 # grep -E -o "PlexOnlineToken=.{0,22}" /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml
#!/usr/bin/env python3
import requests import requests
import sqlite3 import sqlite3
@ -14,8 +14,9 @@ c.execute('select metadata_item_id from media_items where bitrate is null')
items = c.fetchall() items = c.fetchall()
conn.close() conn.close()
print("To analyze: " + str( len(items) ))
print("To analyze: %s" % len(items))
for row in 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.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') requests.get(url='http://127.0.0.1:32400/library/metadata/' + str(row[0]) + '/refresh?X-Plex-Token=xxx')
print(str(row[0])) print(str(row[0]))

View File

@ -1,10 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# analyzedeeply.cli will preform deep analyzation only on files that were not processed yet # analyzedeeply.cli will preform deep analyzation only on files that were not processed yet
from subprocess import call
import os import os
import requests
import sqlite3 import sqlite3
import sys
import time import time
conn = sqlite3.connect('/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db') 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() conn.close()
print("ANALYZE DEEPLY START") 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() start_time = time.time()
for row in items: for row in items:
print ("Processing video id: " + str(row[0])) print("Processing video id: %s" % row[0])
start_row = time.time() start_row = time.time()
os.system('LD_LIBRARY_PATH=/usr/lib/plexmediaserver \ os.system('LD_LIBRARY_PATH=/usr/lib/plexmediaserver \
PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application\ Support \ PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application\ Support \
/usr/lib/plexmediaserver/Plex\ Media\ Scanner --analyze-deeply -o ' + str(row[0])) /usr/lib/plexmediaserver/Plex\ Media\ Scanner --analyze-deeply -o ' + str(row[0]))
end_row = time.time() 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() 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)))