Merge 3 libraries into one with sqlite updates only

Hello, let’s get straight into point :slight_smile:
I give here simplified example, struggled yesterday few hours, almost succeeded, but still …

I have for example 3 movie libraries: Movies, Estonian, Italian.
For each library I have my own movie descriptions, matching (using Plex movie scanner & agent) has been done, everything works like a charm.
I have solid amount of movies in each library, and movies are not “usual easy” automatically-matching ones in Estonian and Italian library. So linking them using standard plex logic simply destroys my matches and therefore also all added metadata I have added manually. Using “duplicating” joining method it also needs tons of manual matching after I have the same movies in “old” and “new” library. This is the last option for me. Dont talk about renaming and re-adjusting everything, this is not a point of that topic. I only wanted ask basically about one thing.

Found one manual db tables updating thread and used that in my example. Of course did backups etc before experimenting,

Let’s assume library_section_id values are:
Movies = 1
Estonian = 2
Italian = 3

So “joining” Estonian library to Movies means for me:
stop plex server and
UPDATE section_locations SET library_section_id = 1 WHERE library_section_id = 2;
UPDATE directories SET library_section_id = 1 WHERE library_section_id = 2;
UPDATE media_items SET library_section_id = 1 WHERE library_section_id = 2;
UPDATE metadata_item_views SET library_section_id = 1 WHERE library_section_id = 2;
UPDATE metadata_items SET library_section_id = 1 WHERE library_section_id = 2;
and optionally
DELETE FROM library_sections WHERE id = 2; (it could be done also after starting plex server again).

File locations remained the same, neither directories or files I didnt change.
Everything was perfect, all Estonian movies were under Movies after that.

And now comes BUT :slight_smile:
When I went to Movies library edit under plex (Manage Library → Edit → Add Folders) just to see, is Estonian folder also added, then it was certainly here, and when I pressed SAVE CHANGES then the Movies library started refreshing procedure and … all my Movies disappeared from there, only Estonian one remained.
And when I repeated this step, then plex started grab all information for Movies into Movies library again, but without any previously inserted metadata. Basically 1/4 of matches were lost, also my own descriptions etc. (I have all descriptions, titles locked for that reason).

Could anybody say, which step I missed? I worked with databases most of my life and feel myself very comfy in them. Why it start with big refresh after pressing save?
When I refreshed manually both libraries before my experiments, it just worked 1-2 sec and nothing changed, all was ok.
The same will happen when I try join Italian library, i.e. “update library_section_id = 1 where library_section_id = 3” everywhere.

Long story, but I tried to describe my point as accurate as I could.
Maybe there are something I forgot to update, which triggering the full library scan again? Plex gurus, help please :wink:

Server Version#: 1.23.0.4459
Player Version#: web 4.55.1

So my simplified question is, which trigger will execute when I press “Save changes” button in plex web client library edit mode? How does it consider that “now is the right time to re-scan everything”? Some hashes changes after my “library_section_id” update, or some hidden “bits” somewhere I must update as well?
Directories, their structure and files didn’t change, only library_section_id references.

This may be relevant.

Thanks!
It was exactly my source example, only without any physical moving of movie files :slight_smile:

I’m just trying move the references only and join several libraries into one without touching files.
Like manually you will just create new library called “All Movies” and add several existing movie folders into this without any re-scan ning everything.
I definitely miss something, but what could it be?

Did you see my last comment in that other thread? You can’t have 2 library_section_id in the directory table. You need to reuse the existing one. Then change the parent_id for those entries to also point to that same existing entry.

True! Thank you reminding me that. Finally I just imitated natural joining and made the snapshot of database after each move. Played also a bit with sequence table (inserted something into section_locations) and now everything is smooth :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.