You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Plex analayze all files that are missing analyzation info
4
+
# OS: Ubunti 16.04 ( in case of other OS's make sure to change paths )
5
+
# Usage: python3 plex-analyze-cli.py
6
+
7
+
importsubprocess
8
+
importsqlite3
9
+
10
+
# Define some variables
11
+
DBPath='/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db'# This is the default path.
12
+
concurrentCount=100# This is how many files will be analyzed in 1 command. Plex handles them one at a time but this reduces the number of calls to the scanner and speeds things up.
13
+
analyzeScript="/scripts/plex/reanalyzeItem.sh"# Path to your refreshMetadataItem script.
14
+
15
+
conn=sqlite3.connect(DBPath)
16
+
17
+
c=conn.cursor()
18
+
c.execute('''Select media_items.metadata_item_id As id, metadata_items.title As title
19
+
From media_items Inner Join metadata_items On media_items.metadata_item_id = metadata_items.id
20
+
Where media_items.bitrate Is Null And Not metadata_items.metadata_type = "12"''')
21
+
22
+
items=c.fetchall()
23
+
conn.close()
24
+
25
+
defanalyzeThese(ids):
26
+
ids=ids[:-1]
27
+
print("Going to analyze the following ID's: {0}".format(ids))
28
+
subprocess.check_call([analyzeScript, ids])
29
+
30
+
print("There are {0} files that need to be analyzed.".format(str(len(items))))
31
+
32
+
itemString=''
33
+
itemCount=len(items)
34
+
count=0
35
+
forrowinitems:
36
+
itemString=itemString+str(row[0]) +','# This adds the current item to the ongoing string.
37
+
count=count+1
38
+
itemCount=itemCount-1# Keep an up to date number of remaining items.
0 commit comments