Set "lock" fields via sqlite?

Hi

I wrote a small python script to pull some additional genres and write them onto my tv shows. However, I don’t see a way to “lock” the genre field via the options in sqlite and it seems that whenever a new episode is added, Plex will refresh the whole series, wiping out my changes.

Is there any way to programatically set these locks? I’m assuming that lock will prevent the full-series-refresh that happens during the new episode refresh? (please correct me if I’m wrong!)

Thanks in advance!

Locking the fields will prevent the data changing during a refresh. Locking the fields is not an on/off thing. It’s in the “metadata_items” table, “user_fields” field. A locked entry looks like this:

lockedFields=2|6

Where the 2 and 6 are the specific fields. Lock the fields you want manually then check this field to identify the number you want to use. Then add this to the entries you want.

Edit: that is the pipe character between the values.

2 Likes

Because lockedFields is pipe-delimited, I dislike editing it directly with SQLite.

So another option is to use the Plex HTTP API. There’s a nice example of how to do so, including locking genre, here:

I usually prefer to use the (unofficial) Python PlexAPI for this sort of thing.

1 Like

For tv shows, you will need the right type number.
I think it is 2 for shows, 3 for seasons and 4 for episodes. I could be wrong though.

2 Likes

thank you! that’s exactly what I need!!

thanks! I liked someone else’s suggestion of lock the fields via the gui then check the table to see which number is dropped. “application is where the theory rubber meets the road” etc etc :slight_smile:

Some of the metadata_item field IDs are listed here.

1 Like