Plex-scripts icon indicating copy to clipboard operation
Plex-scripts copied to clipboard

plex_sync.py add sync intro markers

Open splitsec2 opened this issue 3 years ago • 2 comments

In what file should the feature be added? plex_sync.py

What is the feature request? One of the more intensive things Plex can do is scan all the files for the intro's. It would be great if this script could be extended to allow one server to scan for intro's, and for this scrypt to be able to propogate them to one or more additional servers.

splitsec2 avatar Jul 28 '22 22:07 splitsec2

I was looking at the plex_sync.py and it looks like the requested feature may be implemented already... But from the info available I am not sure how it would work..

in the README.md it says this: bolding is mine plex_sync.py, keep two plex instances synced where you can sync collections, posters (e.g. custom posters set for media), watch history and playlists. You can select, for the last two, which users you want to sync it for as those are user specific.

and in the file plex_sync.py itself there is this documentation:

The use case of this script is the following:
	Keep data between two plex servers synced. Multiple things can be synced at the same time with multiuser support
Requirements (python3 -m pip install [requirement]):
	requests
	aiohttp
Setup:
	Fill the variables below firstly, then run the script with -h to see the arguments that you need to give.
	Run this script at an interval. Decide for yourself what the interval is (e.g. every day or every week)
Example:
	Examples are assuming that main server name is 'Batman server' and backup server name is 'Robin server'
	python3 plex_sync.py -s 'Batman server' --Sync watch_history --User @all
		Sync watch history of every user from 'Batman server' to 'Robin server'
	python3 plex_sync.py -s 'Robin server' --Sync posters
		Taking 'Robin server' as the source and 'Batman server' as the sync target
		Sync the posters of the media (movies, shows and seasons)(posters of playlists and collections are synced with the Playlists and Collections action respectively)
		No need to specify users as this sync action is a general sync action and not a user specific action
	python3 plex_sync.py --SourceName 'Batman server' --User @me --User 'user2' --Sync collections --Sync playlists --Sync watch_history
		Taking 'Batman server' as the source and 'Robin server' as the sync target
		Apply the user specific sync actions (in this case playlists and watch history) to yourself and 'user2'
		Sync the collections, playlists and watch history

So no indication that it can do intro's, but then in the code there is this tidbit:

if any(s not in ('collections','posters','watch_history','playlists','intro_markers') for s in sync):
			return 'Invalid value in "sync" list'
		if not source in (main_plex_name, backup_plex_name):
			return 'Invalid value for "source"'
		if 'intro_markers' in sync and geteuid() != 0:
			return 'Script needs to be run as root when you want to sync intro_markers'

so it looks like it does to this. Does this need to be run on the source server, or the destination server? And is this going directly to the database_folder?

#ADVANCED SETTINGS
#Hardcode the folder where the plex database is in
#Leave empty unless really needed
database_folder = '' 

ie. Is intro syncing a "advanced feature"?

splitsec2 avatar Jul 28 '22 23:07 splitsec2

Syncing intro markers is indeed already a feature.

In the README, the text just hasn't been updated yet. And i realise that it would be smart to add a list of things you can sync inside the documentation in the file.

To make syncing intro markers work, the script needs to be run on the target server (the server that the markers need to be imported to). It needs to be run as root/administrator.

It directly edits the database of the target server to add/edit the markers. The script can, most of the time, figure out on its own where the database is. But in some special situations where it can't find out, you can hardcode the folder where the database is in yourself with that advanced variable.

So run as root (administrator) on the target server, use -S intro_markers and it should work. If it doesn't, hardcode the database folder and then it should work. Run the script with -h to get info on the arguments.

Casvt avatar Jul 29 '22 08:07 Casvt

Hey, I just updated README.md, plex_exporter_importer.py and plex_sync.py and added/changed the documentation on the capabilities (what they can sync) and the special cases (with intro markers and chapter thumbnails). Just wanted to let you know.

Casvt avatar Aug 24 '22 22:08 Casvt