feat:add flags to control the direction of syncing
parent
a4365e59f3
commit
dca54cf4fb
|
|
@ -55,6 +55,12 @@ PLEX_TOKEN = "SuperSecretToken, SuperSecretToken2"
|
||||||
## Set to True if running into ssl certificate errors
|
## Set to True if running into ssl certificate errors
|
||||||
SSL_BYPASS = "False"
|
SSL_BYPASS = "False"
|
||||||
|
|
||||||
|
## control the direction of syncing. e.g. SYNC_FROM_PLEX_TO_JELLYFIN set to true will cause the updates from plex
|
||||||
|
## to be updated in jellyfin. SYNC_FROM_PLEX_TO_PLEX set to true will sync updates between multiple plex servers
|
||||||
|
SYNC_FROM_PLEX_TO_JELLYFIN = "True"
|
||||||
|
SYNC_FROM_JELLYFIN_TO_PLEX = "True"
|
||||||
|
SYNC_FROM_PLEX_TO_PLEX = "True"
|
||||||
|
SYNC_FROM_JELLYFIN_TO_JELLYFIN = "True"
|
||||||
|
|
||||||
|
|
||||||
# Jellyfin
|
# Jellyfin
|
||||||
|
|
|
||||||
59
src/main.py
59
src/main.py
|
|
@ -264,6 +264,35 @@ def update_server_watched(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def should_sync_server(server_1_type, server_2_type):
|
||||||
|
sync_from_plex_to_jellyfin = str_to_bool(
|
||||||
|
os.getenv("SYNC_FROM_PLEX_TO_JELLYFIN", "True"))
|
||||||
|
sync_from_jelly_to_plex = str_to_bool(
|
||||||
|
os.getenv("SYNC_FROM_JELLYFIN_TO_PLEX", "True"))
|
||||||
|
sync_from_plex_to_plex = str_to_bool(
|
||||||
|
os.getenv("SYNC_FROM_PLEX_TO_PLEX", "True"))
|
||||||
|
sync_from_jelly_to_jellyfin = str_to_bool(
|
||||||
|
os.getenv("SYNC_FROM_JELLYFIN_TO_JELLYFIN", "True"))
|
||||||
|
|
||||||
|
if server_1_type == "plex" and server_2_type == "plex" and not sync_from_plex_to_plex:
|
||||||
|
logger("Sync between plex and plex is disabled", 1)
|
||||||
|
return False
|
||||||
|
|
||||||
|
if server_1_type == "plex" and server_2_type == "jellyfin" and not sync_from_jelly_to_plex:
|
||||||
|
logger("Sync from jellyfin to plex disabled", 1)
|
||||||
|
return False
|
||||||
|
|
||||||
|
if server_1_type == "jellyfin" and server_2_type == "jellyfin" and not sync_from_jelly_to_jellyfin:
|
||||||
|
logger("Sync between jellyfin and jellyfin is disabled", 1)
|
||||||
|
return False
|
||||||
|
|
||||||
|
if server_1_type == "jellyfin" and server_2_type == "plex" and not sync_from_plex_to_jellyfin:
|
||||||
|
logger("Sync from plex to jellyfin is disabled", 1)
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def main_loop():
|
def main_loop():
|
||||||
logfile = os.getenv("LOGFILE", "log.log")
|
logfile = os.getenv("LOGFILE", "log.log")
|
||||||
# Delete logfile if it exists
|
# Delete logfile if it exists
|
||||||
|
|
@ -370,21 +399,23 @@ def main_loop():
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
|
|
||||||
update_server_watched(
|
if should_sync_server(server_1[0], server_2[0]):
|
||||||
server_1,
|
update_server_watched(
|
||||||
server_2_watched_filtered,
|
server_1,
|
||||||
user_mapping,
|
server_2_watched_filtered,
|
||||||
library_mapping,
|
user_mapping,
|
||||||
dryrun,
|
library_mapping,
|
||||||
)
|
dryrun,
|
||||||
|
)
|
||||||
|
|
||||||
update_server_watched(
|
if should_sync_server(server_2[0], server_1[0]):
|
||||||
server_2,
|
update_server_watched(
|
||||||
server_1_watched_filtered,
|
server_2,
|
||||||
user_mapping,
|
server_1_watched_filtered,
|
||||||
library_mapping,
|
user_mapping,
|
||||||
dryrun,
|
library_mapping,
|
||||||
)
|
dryrun,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue