What is the problem ?
Here I remade it using CLI command instead of curl calls, however this will take longer as with curl the call is being made and scripts processed to next request with CLI call it will wait until analyzation is done before continuing.
from subprocess import call
conn = sqlite3.connect('/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db')
c = conn.cursor()
c.execute('select metadata_item_id from media_items where bitrate is null')
items = c.fetchall()
print("To analyze: " + str( 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))
p.s Since its python it could be when you copy paste some tabs are not ok.