diff --git a/src/jellyfin_emby.py b/src/jellyfin_emby.py index 777629e..c33c49c 100644 --- a/src/jellyfin_emby.py +++ b/src/jellyfin_emby.py @@ -127,9 +127,7 @@ class JellyfinEmby: self.session = requests.Session() self.users = self.get_users() - def query( - self, query, query_type, identifiers=None, json=None - ): + def query(self, query, query_type, identifiers=None, json=None): try: results = None @@ -148,7 +146,10 @@ class JellyfinEmby: elif query_type == "post": response = self.session.post( - self.baseurl + query, headers=self.headers, json=json, timeout=self.timeout + self.baseurl + query, + headers=self.headers, + json=json, + timeout=self.timeout, ) if response.status_code not in [200, 204]: raise Exception( @@ -626,12 +627,13 @@ class JellyfinEmby: if not dryrun: logger(msg, 5) playback_position_payload = { - "PlaybackPositionTicks": movie_status['time'] * 10_000, + "PlaybackPositionTicks": movie_status["time"] + * 10_000, } self.query( f"/Users/{user_id}/Items/{jellyfin_video_id}/UserData", "post", - json=playback_position_payload + json=playback_position_payload, ) else: logger(msg, 6) @@ -755,16 +757,19 @@ class JellyfinEmby: f"{self.server_type}: {jellyfin_episode['SeriesName']} {jellyfin_episode['SeasonName']} Episode {jellyfin_episode.get('IndexNumber')} {jellyfin_episode.get('Name')}" + f" as partially watched for {floor(episode_status['time'] / 60_000)} minutes for {user_name} in {library}" ) - + if not dryrun: logger(msg, 5) playback_position_payload = { - "PlaybackPositionTicks": episode_status['time'] * 10_000, + "PlaybackPositionTicks": episode_status[ + "time" + ] + * 10_000, } self.query( f"/Users/{user_id}/Items/{jellyfin_episode_id}/UserData", "post", - json=playback_position_payload + json=playback_position_payload, ) else: logger(msg, 6) @@ -773,7 +778,7 @@ class JellyfinEmby: user_name, library, jellyfin_episode.get("SeriesName"), - jellyfin_episode.get('Name'), + jellyfin_episode.get("Name"), duration=floor(episode_status["time"] / 60_000), ) else: diff --git a/src/main.py b/src/main.py index c56a0c2..0ee4b9c 100644 --- a/src/main.py +++ b/src/main.py @@ -319,7 +319,9 @@ def main_loop(): # Start server_2 at the next server in the list for server_2 in servers[servers.index(server_1) + 1 :]: # Check if server 1 and server 2 are going to be synced in either direction, skip if not - if not should_sync_server(server_1[0], server_2[0]) and not should_sync_server(server_2[0], server_1[0]): + if not should_sync_server( + server_1[0], server_2[0] + ) and not should_sync_server(server_2[0], server_1[0]): continue logger(f"Server 1: {server_1[0].capitalize()}: {server_1[1].info()}", 0) diff --git a/test/validate_ci_marklog.py b/test/validate_ci_marklog.py index 5d18785..801b134 100644 --- a/test/validate_ci_marklog.py +++ b/test/validate_ci_marklog.py @@ -4,12 +4,24 @@ import os, argparse def parse_args(): - parser = argparse.ArgumentParser(description="Check the mark.log file that is generated by the CI to make sure it contains the expected values") - parser.add_argument("--dry", action="store_true", help="Check the mark.log file for dry-run") - parser.add_argument("--write", action="store_true", help="Check the mark.log file for write-run") - parser.add_argument("--plex", action="store_true", help="Check the mark.log file for Plex") - parser.add_argument("--jellyfin", action="store_true", help="Check the mark.log file for Jellyfin") - parser.add_argument("--emby", action="store_true", help="Check the mark.log file for Emby") + parser = argparse.ArgumentParser( + description="Check the mark.log file that is generated by the CI to make sure it contains the expected values" + ) + parser.add_argument( + "--dry", action="store_true", help="Check the mark.log file for dry-run" + ) + parser.add_argument( + "--write", action="store_true", help="Check the mark.log file for write-run" + ) + parser.add_argument( + "--plex", action="store_true", help="Check the mark.log file for Plex" + ) + parser.add_argument( + "--jellyfin", action="store_true", help="Check the mark.log file for Jellyfin" + ) + parser.add_argument( + "--emby", action="store_true", help="Check the mark.log file for Emby" + ) return parser.parse_args() @@ -72,8 +84,11 @@ def main(): "jellyplex_watched/TV Shows/Monarch: Legacy of Monsters/Departure/300741", # Plex -> Jellyfin "JellyUser/Movies/Big Buck Bunny", + "JellyUser/Movies/Killers of the Flower Moon/4", "JellyUser/Shows/Doctor Who/The Unquiet Dead", + "JellyUser/Shows/Doctor Who/Aliens of London (1)/4", "JellyUser/Shows/Monarch: Legacy of Monsters/Secrets and Lies", + "JellyUser/Shows/Monarch: Legacy of Monsters/Parallels and Interiors/4", # Emby -> Plex "jellyplex_watched/Movies/Tears of Steel", "jellyplex_watched/TV shows/Doctor Who (2005)/World War Three (2)", @@ -81,11 +96,13 @@ def main(): # Plex -> Emby "jellyplex_watched/Movies/Big Buck Bunny", "jellyplex_watched/Movies/The Family Plan", + "jellyplex_watched/Movies/Killers of the Flower Moon/4", # Emby -> Jellyfin "JellyUser/Movies/Tears of Steel", # Jellyfin -> Emby "jellyplex_watched/Movies/The Family Plan", - "jellyplex_watched/Movies/Five Nights at Freddy's" + "jellyplex_watched/Movies/Five Nights at Freddy's", + "jellyplex_watched/Movies/The Hunger Games: The Ballad of Songbirds & Snakes/5", ], "write": [ "jellyplex_watched/Movies/Five Nights at Freddy's", @@ -95,24 +112,34 @@ def main(): "jellyplex_watched/TV Shows/Monarch: Legacy of Monsters/Aftermath", "jellyplex_watched/TV Shows/Monarch: Legacy of Monsters/Departure/300741", "JellyUser/Movies/Big Buck Bunny", + "JellyUser/Movies/Killers of the Flower Moon/4", "JellyUser/Shows/Doctor Who/The Unquiet Dead", + "JellyUser/Shows/Doctor Who/Aliens of London (1)/4", "JellyUser/Shows/Monarch: Legacy of Monsters/Secrets and Lies", + "JellyUser/Shows/Monarch: Legacy of Monsters/Parallels and Interiors/4", "jellyplex_watched/Movies/Tears of Steel", "jellyplex_watched/TV shows/Doctor Who (2005)/World War Three (2)", "jellyplex_watched/TV shows/Monarch: Legacy of Monsters/Parallels and Interiors/240429", "jellyplex_watched/Movies/Big Buck Bunny", "jellyplex_watched/Movies/The Family Plan", "jellyplex_watched/Movies/Five Nights at Freddy's", + "jellyplex_watched/Movies/The Hunger Games: The Ballad of Songbirds & Snakes/5", + "jellyplex_watched/Movies/Killers of the Flower Moon/4", "JellyUser/Movies/Tears of Steel", + "JellyUser/Shows/Monarch: Legacy of Monsters/Parallels and Interiors/4", "jellyplex_watched/TV shows/Doctor Who (2005)/World War Three (2)", - "jellyplex_watched/TV shows/Monarch: Legacy of Monsters/Parallels and Interiors/240429" + "jellyplex_watched/TV shows/Monarch: Legacy of Monsters/Parallels and Interiors/240429", ], "plex": [ "JellyUser/Movies/Big Buck Bunny", + "JellyUser/Movies/Killers of the Flower Moon/4", "JellyUser/Shows/Doctor Who/The Unquiet Dead", + "JellyUser/Shows/Doctor Who/Aliens of London (1)/4", "JellyUser/Shows/Monarch: Legacy of Monsters/Secrets and Lies", + "JellyUser/Shows/Monarch: Legacy of Monsters/Parallels and Interiors/4", "jellyplex_watched/Movies/Big Buck Bunny", "jellyplex_watched/Movies/The Family Plan", + "jellyplex_watched/Movies/Killers of the Flower Moon/4", ], "jellyfin": [ "jellyplex_watched/Movies/Five Nights at Freddy's", @@ -122,14 +149,15 @@ def main(): "jellyplex_watched/TV Shows/Monarch: Legacy of Monsters/Aftermath", "jellyplex_watched/TV Shows/Monarch: Legacy of Monsters/Departure/300741", "jellyplex_watched/Movies/The Family Plan", - "jellyplex_watched/Movies/Five Nights at Freddy's" + "jellyplex_watched/Movies/Five Nights at Freddy's", + "jellyplex_watched/Movies/The Hunger Games: The Ballad of Songbirds & Snakes/5", ], "emby": [ "jellyplex_watched/Movies/Tears of Steel", "jellyplex_watched/TV shows/Doctor Who (2005)/World War Three (2)", "jellyplex_watched/TV shows/Monarch: Legacy of Monsters/Parallels and Interiors/240429", - "JellyUser/Movies/Tears of Steel" - ] + "JellyUser/Movies/Tears of Steel", + ], } # Expected values for the mark.log file, dry-run is slightly different than write-run