Move ViewHistory from One Install to Another

Is there a way to export the View History like we have for View State ?

The move for viewstate export is very good for what it does but unfortunately is a little limited as it does not export the history which means the continue watching / on deck is not populated via the procedure. Also all previously viewing history stored in the dashboard is not copied via this process.

Anyone know of a way to do this ? Maybe @BigWheel might know of a way (even if its somewhat unsupported officially) ?

I don’t know of a way but I am not particularly good at editing DB. I’ll ask some folks I think might know.

Oh okay, thank you for checking. For some reason I thought you were one of the db experts :slight_smile:

I think history is more Library-dependent than the media-guid based View state.

Why would you want to move it, if not the entire DB?

(Merging would be one reason, I suppose.)

Someone told me that using those same instructions but using metadata_item_views instead of metadata_item_settings should work but they are not positive.

Thanks @BigWheel, I’ll give it a go.

@Volts my reason is a little odd. I’m in the process of renaming all my media’s folders adding tmdb ids for my movies and TV shows. I’ve scripted it and once I do it the intro detection, thumbnails and deep analysis will all need to be redone as plex sees it as a folder move.

So was thinking that after I do the change I then export my view status (and history if possible). Nuke the server completely, add media libraries, import and then let it redo the stuff above cleanly again on a new db rather than cleanup on the old one.

I recently added IDs to my show directory names too. I used Sonarr to rename them.

I added them only at the Show folder level, not to individual episodes.

/Show Name (Year) {tt123456}/

I didn’t have a single problem. Nothing was unmatched, no history was lost, no manual steps were required in Plex. (As always, make sure Empty Trash Automatically… is disabled.)

Plex didn’t regenerate video preview thumbnails. It recognized that the files hadn’t changed and used the thumbnail that already existed. Plex is clever about thumbnails, even across libraries.

Deep analysis too.

I’m pretty sure it ignores the filename. I think it does a cheat-hash of the file length + first block + last block of the file. If those match: same file.

Plex performed intro analysis again only for shows that didn’t have intros. It still didn’t find any intros for them - they don’t have consistent intros. :slight_smile: Shows that already had detected intros didn’t reprocess anything.

1 Like

Mmmm, your experience of intro detection is different to me. If I change a folder name when it runs as a nightly scheduled task I can see in the logs it’s been redone. I’ve done a fair bit of testing with it already :sweat_smile:

Does it re-analyze, or just indicate that it’s checking if intro analysis is needed?

I’ll confirm. But mine happened WAY too fast for it to have analyzed everything.

I’ll rename a folder today and let it run overnight and see what happens. But it usually says intro detection completed for x seasons… Or something to that effect.

Been thinking about this some more. The fact that history is not imported might be a good thing as I can start from a clean state on the dashboard rather than having loads been previously marked as watched. View state is way more important so that might be enough for me.

Thanks anyhow to you both for the replies.

2 Likes

I just tested, renamed a folder. Nearly instant!

Jun 19, 2021 16:00:07.799 [0x8099fa600] DEBUG - Scheduling an intro detection job for 173273
Jun 19, 2021 16:00:07.799 [0x8099fa600] DEBUG - BackgroundTaskQueue: creating activity container for "media.generate.intros"
Jun 19, 2021 16:00:07.799 [0x8099fa600] DEBUG - Activity: registered new activity e8d7f2e6-e37c-4beb-894a-007bfbd0b5c4 - "Detecting intros"
Jun 19, 2021 16:00:07.800 [0x8099fa600] DEBUG - Activity: registered new sub-activity c8db03c7-598d-43fe-a719-6c388de347d6 - "The Show Name S1" parent: c8db03c7-598d-43fe-a719-6c388de347d6 overall progress: 0.0% (0/1)
Jun 19, 2021 16:00:07.800 [0x8099fa600] DEBUG - Media Analyzer: Background analysis completed in 0.6 seconds, removing 1 IDs
Jun 19, 2021 16:00:07.800 [0x8099fa600] DEBUG - Media Analyzer: Performing on-the-fly analysis on 1 item.
Jun 19, 2021 16:00:07.800 [0x8099fa600] DEBUG - [JobRunner] Job running: FFMPEG_EXTERNAL_LIBS='/usr/local/plexdata/Plex\ Media\ Server/Codecs/fa235d6-3858-freebsd-x86_64/' X_PLEX_TOKEN='xxxxxxxxxxxxxxxxxxxx' '/usr/local/share/PlexMediaServer-1.23.5.4702-efe9a58fb/Plex Media Scanner' '--analyze' '--log-file-suffix' ' Analysis' '--no-thumbs' '--item' '173274'
Jun 19, 2021 16:00:07.801 [0x8099f8300] DEBUG - Activity: updated activity e8d7f2e6-e37c-4beb-894a-007bfbd0b5c4 - completed 0.0% - Detecting intros
Jun 19, 2021 16:00:07.803 [0x8099f8300] DEBUG - IntroDetector: Running intro detection for [173273] [The Show Name] [1]
Jun 19, 2021 16:00:07.807 [0x8099f8300] DEBUG - IntroDetector: Skipping intro detection for item 173273. Already up to date
Jun 19, 2021 16:00:07.810 [0x8099f8300] DEBUG - Activity: ended sub-activity c8db03c7-598d-43fe-a719-6c388de347d6 parent: e8d7f2e6-e37c-4beb-894a-007bfbd0b5c4 overall progress: 100.0% (1/1)
Jun 19, 2021 16:00:07.810 [0x8099f8300] DEBUG - Activity: updated activity e8d7f2e6-e37c-4beb-894a-007bfbd0b5c4 - completed 100.0% - Detecting intros

The structure for metadata_item_views is different from metadata_item_settings.

CREATE TABLE IF NOT EXISTS "metadata_item_views" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "account_id" integer, "guid" varchar(255), "metadata_type" integer, "library_section_id" integer, "grandparent_title" varchar(255), "parent_index" integer, "parent_title" varchar(255), "index" integer, "title" varchar(255), "thumb_url" varchar(255), "viewed_at" datetime, 'grandparent_guid' varchar(255), 'originally_available_at' datetime, 'device_id' integer);

CREATE TABLE IF NOT EXISTS "metadata_item_settings" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "account_id" integer, "guid" varchar(255), "rating" float, "view_offset" integer, "view_count" integer, "last_viewed_at" datetime, "created_at" datetime, "updated_at" datetime, "skip_count" integer DEFAULT 0, "last_skipped_at" datetime DEFAULT NULL, "changed_at" integer(8) DEFAULT 0, 'extra_data' varchar(255), 'last_rated_at' datetime);

If you tried to migrate it I think you’d need to adjust library_section_id (easy) and maybe index and parent_index (a real chore) to match your new database details.

So the clean slate sounds like a great plan.

1 Like

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