Fix tests to include partially watched jellyfin and emby

This commit is contained in:
Luis Garcia
2024-06-02 18:19:48 -06:00
parent 3fdcc99304
commit 4185f5fc94
3 changed files with 57 additions and 22 deletions

View File

@@ -127,9 +127,7 @@ class JellyfinEmby:
self.session = requests.Session() self.session = requests.Session()
self.users = self.get_users() self.users = self.get_users()
def query( def query(self, query, query_type, identifiers=None, json=None):
self, query, query_type, identifiers=None, json=None
):
try: try:
results = None results = None
@@ -148,7 +146,10 @@ class JellyfinEmby:
elif query_type == "post": elif query_type == "post":
response = self.session.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]: if response.status_code not in [200, 204]:
raise Exception( raise Exception(
@@ -626,12 +627,13 @@ class JellyfinEmby:
if not dryrun: if not dryrun:
logger(msg, 5) logger(msg, 5)
playback_position_payload = { playback_position_payload = {
"PlaybackPositionTicks": movie_status['time'] * 10_000, "PlaybackPositionTicks": movie_status["time"]
* 10_000,
} }
self.query( self.query(
f"/Users/{user_id}/Items/{jellyfin_video_id}/UserData", f"/Users/{user_id}/Items/{jellyfin_video_id}/UserData",
"post", "post",
json=playback_position_payload json=playback_position_payload,
) )
else: else:
logger(msg, 6) 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"{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}" + f" as partially watched for {floor(episode_status['time'] / 60_000)} minutes for {user_name} in {library}"
) )
if not dryrun: if not dryrun:
logger(msg, 5) logger(msg, 5)
playback_position_payload = { playback_position_payload = {
"PlaybackPositionTicks": episode_status['time'] * 10_000, "PlaybackPositionTicks": episode_status[
"time"
]
* 10_000,
} }
self.query( self.query(
f"/Users/{user_id}/Items/{jellyfin_episode_id}/UserData", f"/Users/{user_id}/Items/{jellyfin_episode_id}/UserData",
"post", "post",
json=playback_position_payload json=playback_position_payload,
) )
else: else:
logger(msg, 6) logger(msg, 6)
@@ -773,7 +778,7 @@ class JellyfinEmby:
user_name, user_name,
library, library,
jellyfin_episode.get("SeriesName"), jellyfin_episode.get("SeriesName"),
jellyfin_episode.get('Name'), jellyfin_episode.get("Name"),
duration=floor(episode_status["time"] / 60_000), duration=floor(episode_status["time"] / 60_000),
) )
else: else:

View File

@@ -319,7 +319,9 @@ def main_loop():
# Start server_2 at the next server in the list # Start server_2 at the next server in the list
for server_2 in servers[servers.index(server_1) + 1 :]: 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 # 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 continue
logger(f"Server 1: {server_1[0].capitalize()}: {server_1[1].info()}", 0) logger(f"Server 1: {server_1[0].capitalize()}: {server_1[1].info()}", 0)

View File

@@ -4,12 +4,24 @@ import os, argparse
def parse_args(): 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 = argparse.ArgumentParser(
parser.add_argument("--dry", action="store_true", help="Check the mark.log file for dry-run") description="Check the mark.log file that is generated by the CI to make sure it contains the expected values"
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(
parser.add_argument("--jellyfin", action="store_true", help="Check the mark.log file for Jellyfin") "--dry", action="store_true", help="Check the mark.log file for dry-run"
parser.add_argument("--emby", action="store_true", help="Check the mark.log file for Emby") )
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() return parser.parse_args()
@@ -72,8 +84,11 @@ def main():
"jellyplex_watched/TV Shows/Monarch: Legacy of Monsters/Departure/300741", "jellyplex_watched/TV Shows/Monarch: Legacy of Monsters/Departure/300741",
# Plex -> Jellyfin # Plex -> Jellyfin
"JellyUser/Movies/Big Buck Bunny", "JellyUser/Movies/Big Buck Bunny",
"JellyUser/Movies/Killers of the Flower Moon/4",
"JellyUser/Shows/Doctor Who/The Unquiet Dead", "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/Secrets and Lies",
"JellyUser/Shows/Monarch: Legacy of Monsters/Parallels and Interiors/4",
# Emby -> Plex # Emby -> Plex
"jellyplex_watched/Movies/Tears of Steel", "jellyplex_watched/Movies/Tears of Steel",
"jellyplex_watched/TV shows/Doctor Who (2005)/World War Three (2)", "jellyplex_watched/TV shows/Doctor Who (2005)/World War Three (2)",
@@ -81,11 +96,13 @@ def main():
# Plex -> Emby # Plex -> Emby
"jellyplex_watched/Movies/Big Buck Bunny", "jellyplex_watched/Movies/Big Buck Bunny",
"jellyplex_watched/Movies/The Family Plan", "jellyplex_watched/Movies/The Family Plan",
"jellyplex_watched/Movies/Killers of the Flower Moon/4",
# Emby -> Jellyfin # Emby -> Jellyfin
"JellyUser/Movies/Tears of Steel", "JellyUser/Movies/Tears of Steel",
# Jellyfin -> Emby # Jellyfin -> Emby
"jellyplex_watched/Movies/The Family Plan", "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": [ "write": [
"jellyplex_watched/Movies/Five Nights at Freddy's", "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/Aftermath",
"jellyplex_watched/TV Shows/Monarch: Legacy of Monsters/Departure/300741", "jellyplex_watched/TV Shows/Monarch: Legacy of Monsters/Departure/300741",
"JellyUser/Movies/Big Buck Bunny", "JellyUser/Movies/Big Buck Bunny",
"JellyUser/Movies/Killers of the Flower Moon/4",
"JellyUser/Shows/Doctor Who/The Unquiet Dead", "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/Secrets and Lies",
"JellyUser/Shows/Monarch: Legacy of Monsters/Parallels and Interiors/4",
"jellyplex_watched/Movies/Tears of Steel", "jellyplex_watched/Movies/Tears of Steel",
"jellyplex_watched/TV shows/Doctor Who (2005)/World War Three (2)", "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",
"jellyplex_watched/Movies/Big Buck Bunny", "jellyplex_watched/Movies/Big Buck Bunny",
"jellyplex_watched/Movies/The Family Plan", "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",
"jellyplex_watched/Movies/Killers of the Flower Moon/4",
"JellyUser/Movies/Tears of Steel", "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/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": [ "plex": [
"JellyUser/Movies/Big Buck Bunny", "JellyUser/Movies/Big Buck Bunny",
"JellyUser/Movies/Killers of the Flower Moon/4",
"JellyUser/Shows/Doctor Who/The Unquiet Dead", "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/Secrets and Lies",
"JellyUser/Shows/Monarch: Legacy of Monsters/Parallels and Interiors/4",
"jellyplex_watched/Movies/Big Buck Bunny", "jellyplex_watched/Movies/Big Buck Bunny",
"jellyplex_watched/Movies/The Family Plan", "jellyplex_watched/Movies/The Family Plan",
"jellyplex_watched/Movies/Killers of the Flower Moon/4",
], ],
"jellyfin": [ "jellyfin": [
"jellyplex_watched/Movies/Five Nights at Freddy's", "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/Aftermath",
"jellyplex_watched/TV Shows/Monarch: Legacy of Monsters/Departure/300741", "jellyplex_watched/TV Shows/Monarch: Legacy of Monsters/Departure/300741",
"jellyplex_watched/Movies/The Family Plan", "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": [ "emby": [
"jellyplex_watched/Movies/Tears of Steel", "jellyplex_watched/Movies/Tears of Steel",
"jellyplex_watched/TV shows/Doctor Who (2005)/World War Three (2)", "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",
"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 # Expected values for the mark.log file, dry-run is slightly different than write-run