Update version to 7.6.9 and modify tagging functionality across Eros, Lidarr, Radarr, Readarr, Sonarr, and Whisparr to use new tag labels ("huntarr-missing" and "huntarr-upgraded") for improved clarity and consistency in processing.

This commit is contained in:
Admin9705
2025-06-08 16:25:01 -04:00
parent de156e8706
commit dff2aa02a9
19 changed files with 137 additions and 119 deletions

View File

@@ -585,33 +585,36 @@ def add_tag_to_movie(api_url: str, api_key: str, api_timeout: int, movie_id: int
eros_logger.error(f"Error adding tag {tag_id} to movie {movie_id}: {e}")
return False
def tag_processed_movie(api_url: str, api_key: str, api_timeout: int, movie_id: int, tag_label: str = "huntarr-processed") -> bool:
def tag_processed_movie(api_url: str, api_key: str, api_timeout: int, movie_id: int, tag_label: str = "huntarr-missing") -> bool:
"""
Tag a movie as processed by Huntarr.
Tag a movie in Eros with the specified tag.
Args:
api_url: The base URL of the Eros API
api_key: The API key for authentication
api_key: The API key for authentication
api_timeout: Timeout for the API request
movie_id: The ID of the movie to tag
tag_label: The label of the tag to add (default: "huntarr-processed")
tag_label: The tag to apply (huntarr-missing, huntarr-upgraded)
Returns:
True if successful, False otherwise
True if the tagging was successful, False otherwise
"""
try:
# Get or create the tag
tag_id = get_or_create_tag(api_url, api_key, api_timeout, tag_label)
if not tag_id:
eros_logger.error(f"Failed to get or create tag '{tag_label}'")
if tag_id is None:
eros_logger.error(f"Failed to get or create tag '{tag_label}' in Eros")
return False
# Add the tag to the movie
success = add_tag_to_movie(api_url, api_key, api_timeout, movie_id, tag_id)
if success:
eros_logger.info(f"Successfully tagged movie {movie_id} with '{tag_label}'")
return success
eros_logger.debug(f"Successfully tagged Eros movie {movie_id} with '{tag_label}'")
return True
else:
eros_logger.error(f"Failed to add tag '{tag_label}' to Eros movie {movie_id}")
return False
except Exception as e:
eros_logger.error(f"Error tagging movie {movie_id} with '{tag_label}': {e}")
eros_logger.error(f"Error tagging Eros movie {movie_id} with '{tag_label}': {e}")
return False

View File

@@ -198,10 +198,10 @@ def process_missing_items(
# Tag the movie if enabled
if tag_processed_items:
try:
eros_api.tag_processed_movie(api_url, api_key, api_timeout, item_id)
eros_logger.debug(f"Tagged movie {item_id} as processed")
eros_api.tag_processed_movie(api_url, api_key, api_timeout, item_id, "huntarr-missing")
eros_logger.debug(f"Tagged movie {item_id} with 'huntarr-missing'")
except Exception as e:
eros_logger.warning(f"Failed to tag movie {item_id}: {e}")
eros_logger.warning(f"Failed to tag movie {item_id} with 'huntarr-missing': {e}")
# Log to history system
log_processed_media("eros", item_info, item_id, instance_name, "missing")

View File

@@ -178,10 +178,10 @@ def process_cutoff_upgrades(
# Tag the movie if enabled
if tag_processed_items:
try:
eros_api.tag_processed_movie(api_url, api_key, api_timeout, item_id)
eros_logger.debug(f"Tagged movie {item_id} as processed for upgrades")
eros_api.tag_processed_movie(api_url, api_key, api_timeout, item_id, "huntarr-upgraded")
eros_logger.debug(f"Tagged movie {item_id} with 'huntarr-upgraded'")
except Exception as e:
eros_logger.warning(f"Failed to tag movie {item_id}: {e}")
eros_logger.warning(f"Failed to tag movie {item_id} with 'huntarr-upgraded': {e}")
# Log to history so the upgrade appears in the history UI
log_processed_media("eros", item_info, item_id, instance_name, "upgrade")

View File

@@ -551,33 +551,36 @@ def add_tag_to_artist(api_url: str, api_key: str, api_timeout: int, artist_id: i
lidarr_logger.error(f"Error adding tag {tag_id} to artist {artist_id}: {e}")
return False
def tag_processed_artist(api_url: str, api_key: str, api_timeout: int, artist_id: int, tag_label: str = "huntarr-processed") -> bool:
def tag_processed_artist(api_url: str, api_key: str, api_timeout: int, artist_id: int, tag_label: str = "huntarr-missing") -> bool:
"""
Tag an artist as processed by Huntarr.
Tag an artist in Lidarr with the specified tag.
Args:
api_url: The base URL of the Lidarr API
api_key: The API key for authentication
api_key: The API key for authentication
api_timeout: Timeout for the API request
artist_id: The ID of the artist to tag
tag_label: The label of the tag to add (default: "huntarr-processed")
tag_label: The tag to apply (huntarr-missing, huntarr-upgraded)
Returns:
True if successful, False otherwise
True if the tagging was successful, False otherwise
"""
try:
# Get or create the tag
tag_id = get_or_create_tag(api_url, api_key, api_timeout, tag_label)
if not tag_id:
lidarr_logger.error(f"Failed to get or create tag '{tag_label}'")
if tag_id is None:
lidarr_logger.error(f"Failed to get or create tag '{tag_label}' in Lidarr")
return False
# Add the tag to the artist
success = add_tag_to_artist(api_url, api_key, api_timeout, artist_id, tag_id)
if success:
lidarr_logger.info(f"Successfully tagged artist {artist_id} with '{tag_label}'")
return success
lidarr_logger.debug(f"Successfully tagged Lidarr artist {artist_id} with '{tag_label}'")
return True
else:
lidarr_logger.error(f"Failed to add tag '{tag_label}' to Lidarr artist {artist_id}")
return False
except Exception as e:
lidarr_logger.error(f"Error tagging artist {artist_id} with '{tag_label}': {e}")
lidarr_logger.error(f"Error tagging Lidarr artist {artist_id} with '{tag_label}': {e}")
return False

View File

@@ -263,10 +263,10 @@ def process_missing_albums(
# Tag the artist if enabled
if tag_processed_items:
try:
lidarr_api.tag_processed_artist(api_url, api_key, api_timeout, artist_id)
lidarr_logger.debug(f"Tagged artist {artist_id} as processed")
lidarr_api.tag_processed_artist(api_url, api_key, api_timeout, artist_id, "huntarr-missing")
lidarr_logger.debug(f"Tagged artist {artist_id} with 'huntarr-missing'")
except Exception as e:
lidarr_logger.warning(f"Failed to tag artist {artist_id}: {e}")
lidarr_logger.warning(f"Failed to tag artist {artist_id} with 'huntarr-missing': {e}")
# Also mark all albums from this artist as processed
if artist_id in items_by_artist:
@@ -353,11 +353,11 @@ def process_missing_albums(
artist_id = album_info.get('artistId')
if artist_id and artist_id not in tagged_artists:
try:
lidarr_api.tag_processed_artist(api_url, api_key, api_timeout, artist_id)
lidarr_logger.debug(f"Tagged artist {artist_id} as processed (from album {album_id})")
lidarr_api.tag_processed_artist(api_url, api_key, api_timeout, artist_id, "huntarr-missing")
lidarr_logger.debug(f"Tagged artist {artist_id} with 'huntarr-missing'")
tagged_artists.add(artist_id)
except Exception as e:
lidarr_logger.warning(f"Failed to tag artist {artist_id}: {e}")
lidarr_logger.warning(f"Failed to tag artist {artist_id} with 'huntarr-missing': {e}")
# Log to history system
for album_id in album_ids_to_search:

View File

@@ -167,11 +167,11 @@ def process_cutoff_upgrades(
artist_id = album.get('artistId')
if artist_id and artist_id not in tagged_artists:
try:
lidarr_api.tag_processed_artist(api_url, api_key, api_timeout, artist_id)
lidarr_logger.debug(f"Tagged artist {artist_id} as processed for upgrades")
lidarr_api.tag_processed_artist(api_url, api_key, api_timeout, artist_id, "huntarr-upgraded")
lidarr_logger.debug(f"Tagged artist {artist_id} with 'huntarr-upgraded'")
tagged_artists.add(artist_id)
except Exception as e:
lidarr_logger.warning(f"Failed to tag artist {artist_id}: {e}")
lidarr_logger.warning(f"Failed to tag artist {artist_id} with 'huntarr-upgraded': {e}")
# Log to history
for album_id in album_ids_to_search:

View File

@@ -487,33 +487,36 @@ def add_tag_to_movie(api_url: str, api_key: str, api_timeout: int, movie_id: int
radarr_logger.error(f"Error adding tag {tag_id} to movie {movie_id}: {e}")
return False
def tag_processed_movie(api_url: str, api_key: str, api_timeout: int, movie_id: int, tag_label: str = "huntarr-processed") -> bool:
def tag_processed_movie(api_url: str, api_key: str, api_timeout: int, movie_id: int, tag_label: str = "huntarr-missing") -> bool:
"""
Tag a movie as processed by Huntarr.
Tag a movie in Radarr with the specified tag.
Args:
api_url: The base URL of the Radarr API
api_key: The API key for authentication
api_key: The API key for authentication
api_timeout: Timeout for the API request
movie_id: The ID of the movie to tag
tag_label: The label of the tag to add (default: "huntarr-processed")
tag_label: The tag to apply (huntarr-missing, huntarr-upgraded)
Returns:
True if successful, False otherwise
True if the tagging was successful, False otherwise
"""
try:
# Get or create the tag
tag_id = get_or_create_tag(api_url, api_key, api_timeout, tag_label)
if not tag_id:
radarr_logger.error(f"Failed to get or create tag '{tag_label}'")
if tag_id is None:
radarr_logger.error(f"Failed to get or create tag '{tag_label}' in Radarr")
return False
# Add the tag to the movie
success = add_tag_to_movie(api_url, api_key, api_timeout, movie_id, tag_id)
if success:
radarr_logger.info(f"Successfully tagged movie {movie_id} with '{tag_label}'")
return success
radarr_logger.debug(f"Successfully tagged Radarr movie {movie_id} with '{tag_label}'")
return True
else:
radarr_logger.error(f"Failed to add tag '{tag_label}' to Radarr movie {movie_id}")
return False
except Exception as e:
radarr_logger.error(f"Error tagging movie {movie_id} with '{tag_label}': {e}")
radarr_logger.error(f"Error tagging Radarr movie {movie_id} with '{tag_label}': {e}")
return False

View File

@@ -281,10 +281,10 @@ def process_missing_movies(
# Tag the movie if enabled
if tag_processed_items:
try:
radarr_api.tag_processed_movie(api_url, api_key, api_timeout, movie_id)
radarr_logger.debug(f"Tagged movie {movie_id} as processed")
radarr_api.tag_processed_movie(api_url, api_key, api_timeout, movie_id, "huntarr-missing")
radarr_logger.debug(f"Tagged movie {movie_id} with 'huntarr-missing'")
except Exception as e:
radarr_logger.warning(f"Failed to tag movie {movie_id}: {e}")
radarr_logger.warning(f"Failed to tag movie {movie_id} with 'huntarr-missing': {e}")
# Immediately add to processed IDs to prevent duplicate processing
success = add_processed_id("radarr", instance_name, str(movie_id))

View File

@@ -112,10 +112,10 @@ def process_cutoff_upgrades(
# Tag the movie if enabled
if tag_processed_items:
try:
radarr_api.tag_processed_movie(api_url, api_key, api_timeout, movie_id)
radarr_logger.debug(f"Tagged movie {movie_id} as processed for upgrades")
radarr_api.tag_processed_movie(api_url, api_key, api_timeout, movie_id, "huntarr-upgraded")
radarr_logger.debug(f"Tagged movie {movie_id} with 'huntarr-upgraded'")
except Exception as e:
radarr_logger.warning(f"Failed to tag movie {movie_id}: {e}")
radarr_logger.warning(f"Failed to tag movie {movie_id} with 'huntarr-upgraded': {e}")
# Log to history so the upgrade appears in the history UI
media_name = f"{movie_title} ({movie_year})"

View File

@@ -504,33 +504,36 @@ def add_tag_to_author(api_url: str, api_key: str, api_timeout: int, author_id: i
logger.error(f"Error adding tag {tag_id} to author {author_id}: {e}")
return False
def tag_processed_author(api_url: str, api_key: str, api_timeout: int, author_id: int, tag_label: str = "huntarr-processed") -> bool:
def tag_processed_author(api_url: str, api_key: str, api_timeout: int, author_id: int, tag_label: str = "huntarr-missing") -> bool:
"""
Tag an author as processed by Huntarr.
Tag an author in Readarr with the specified tag.
Args:
api_url: The base URL of the Readarr API
api_key: The API key for authentication
api_key: The API key for authentication
api_timeout: Timeout for the API request
author_id: The ID of the author to tag
tag_label: The label of the tag to add (default: "huntarr-processed")
tag_label: The tag to apply (huntarr-missing, huntarr-upgraded)
Returns:
True if successful, False otherwise
True if the tagging was successful, False otherwise
"""
try:
# Get or create the tag
# Get or create the tag
tag_id = get_or_create_tag(api_url, api_key, api_timeout, tag_label)
if not tag_id:
logger.error(f"Failed to get or create tag '{tag_label}'")
if tag_id is None:
readarr_logger.error(f"Failed to get or create tag '{tag_label}' in Readarr")
return False
# Add the tag to the author
success = add_tag_to_author(api_url, api_key, api_timeout, author_id, tag_id)
if success:
logger.info(f"Successfully tagged author {author_id} with '{tag_label}'")
return success
readarr_logger.debug(f"Successfully tagged Readarr author {author_id} with '{tag_label}'")
return True
else:
readarr_logger.error(f"Failed to add tag '{tag_label}' to Readarr author {author_id}")
return False
except Exception as e:
logger.error(f"Error tagging author {author_id} with '{tag_label}': {e}")
readarr_logger.error(f"Error tagging Readarr author {author_id} with '{tag_label}': {e}")
return False

View File

@@ -168,10 +168,10 @@ def process_missing_books(
# Tag the book's author if enabled (keep author tagging as it's still useful)
if tag_processed_items and author_id:
try:
readarr_api.tag_processed_author(api_url, api_key, api_timeout, author_id)
readarr_logger.debug(f"Tagged author {author_id} as processed")
readarr_api.tag_processed_author(api_url, api_key, api_timeout, author_id, "huntarr-missing")
readarr_logger.debug(f"Tagged author {author_id} with 'huntarr-missing'")
except Exception as e:
readarr_logger.warning(f"Failed to tag author {author_id}: {e}")
readarr_logger.warning(f"Failed to tag author {author_id} with 'huntarr-missing': {e}")
# Log history entry for this specific book
media_name = f"{author_name} - {book_title}"

View File

@@ -164,11 +164,11 @@ def process_cutoff_upgrades(
author_id = book.get('authorId')
if author_id and author_id not in tagged_authors:
try:
readarr_api.tag_processed_author(api_url, api_key, api_timeout, author_id)
readarr_logger.debug(f"Tagged author {author_id} as processed for upgrades")
readarr_api.tag_processed_author(api_url, api_key, api_timeout, author_id, "huntarr-upgraded")
readarr_logger.debug(f"Tagged author {author_id} with 'huntarr-upgraded'")
tagged_authors.add(author_id)
except Exception as e:
readarr_logger.warning(f"Failed to tag author {author_id}: {e}")
readarr_logger.warning(f"Failed to tag author {author_id} with 'huntarr-upgraded': {e}")
# Log to history system for each book
for book in books_to_process:

View File

@@ -1226,33 +1226,36 @@ def add_tag_to_series(api_url: str, api_key: str, api_timeout: int, series_id: i
sonarr_logger.error(f"Error adding tag {tag_id} to series {series_id}: {e}")
return False
def tag_processed_series(api_url: str, api_key: str, api_timeout: int, series_id: int, tag_label: str = "huntarr-processed") -> bool:
def tag_processed_series(api_url: str, api_key: str, api_timeout: int, series_id: int, tag_label: str = "huntarr-missing") -> bool:
"""
Tag a series as processed by Huntarr.
Tag a series in Sonarr with the specified tag.
Args:
api_url: The base URL of the Sonarr API
api_key: The API key for authentication
api_key: The API key for authentication
api_timeout: Timeout for the API request
series_id: The ID of the series to tag
tag_label: The label of the tag to add (default: "huntarr-processed")
tag_label: The tag to apply (huntarr-missing, huntarr-upgraded, huntarr-shows-missing)
Returns:
True if successful, False otherwise
True if the tagging was successful, False otherwise
"""
try:
# Get or create the tag
tag_id = get_or_create_tag(api_url, api_key, api_timeout, tag_label)
if not tag_id:
sonarr_logger.error(f"Failed to get or create tag '{tag_label}'")
if tag_id is None:
sonarr_logger.error(f"Failed to get or create tag '{tag_label}' in Sonarr")
return False
# Add the tag to the series
success = add_tag_to_series(api_url, api_key, api_timeout, series_id, tag_id)
if success:
sonarr_logger.info(f"Successfully tagged series {series_id} with '{tag_label}'")
return success
sonarr_logger.debug(f"Successfully tagged Sonarr series {series_id} with '{tag_label}'")
return True
else:
sonarr_logger.error(f"Failed to add tag '{tag_label}' to Sonarr series {series_id}")
return False
except Exception as e:
sonarr_logger.error(f"Error tagging series {series_id} with '{tag_label}': {e}")
sonarr_logger.error(f"Error tagging Sonarr series {series_id} with '{tag_label}': {e}")
return False

View File

@@ -222,10 +222,10 @@ def process_missing_seasons_packs_mode(
# Tag the series if enabled
if tag_processed_items:
try:
sonarr_api.tag_processed_series(api_url, api_key, api_timeout, series_id)
sonarr_logger.debug(f"Tagged series {series_id} as processed")
sonarr_api.tag_processed_series(api_url, api_key, api_timeout, series_id, "huntarr-missing")
sonarr_logger.debug(f"Tagged series {series_id} with 'huntarr-missing'")
except Exception as e:
sonarr_logger.warning(f"Failed to tag series {series_id}: {e}")
sonarr_logger.warning(f"Failed to tag series {series_id} with 'huntarr-missing': {e}")
# Log to history system
media_name = f"{series_title} - Season {season_number} (contains {episode_count} missing episodes)"
@@ -373,10 +373,10 @@ def process_missing_shows_mode(
# Tag the series if enabled
if tag_processed_items:
try:
sonarr_api.tag_processed_series(api_url, api_key, api_timeout, show_id)
sonarr_logger.debug(f"Tagged series {show_id} as processed")
sonarr_api.tag_processed_series(api_url, api_key, api_timeout, show_id, "huntarr-shows-missing")
sonarr_logger.debug(f"Tagged series {show_id} with 'huntarr-shows-missing'")
except Exception as e:
sonarr_logger.warning(f"Failed to tag series {show_id}: {e}")
sonarr_logger.warning(f"Failed to tag series {show_id} with 'huntarr-shows-missing': {e}")
# Add episode IDs to stateful manager IMMEDIATELY after processing each batch
for episode_id in episode_ids:

View File

@@ -204,10 +204,10 @@ def process_upgrade_seasons_mode(
# Tag the series if enabled
if tag_processed_items:
try:
sonarr_api.tag_processed_series(api_url, api_key, api_timeout, series_id)
sonarr_logger.debug(f"Tagged series {series_id} as processed for upgrades")
sonarr_api.tag_processed_series(api_url, api_key, api_timeout, series_id, "huntarr-upgraded")
sonarr_logger.debug(f"Tagged series {series_id} with 'huntarr-upgraded'")
except Exception as e:
sonarr_logger.warning(f"Failed to tag series {series_id}: {e}")
sonarr_logger.warning(f"Failed to tag series {series_id} with 'huntarr-upgraded': {e}")
# Log this as a season pack upgrade in the history
log_season_pack_upgrade(api_url, api_key, api_timeout, series_id, season_number, instance_name)
@@ -390,10 +390,10 @@ def process_upgrade_shows_mode(
# Tag the series if enabled
if tag_processed_items:
try:
sonarr_api.tag_processed_series(api_url, api_key, api_timeout, series_id)
sonarr_logger.debug(f"Tagged series {series_id} as processed for upgrades")
sonarr_api.tag_processed_series(api_url, api_key, api_timeout, series_id, "huntarr-upgraded")
sonarr_logger.debug(f"Tagged series {series_id} with 'huntarr-upgraded'")
except Exception as e:
sonarr_logger.warning(f"Failed to tag series {series_id}: {e}")
sonarr_logger.warning(f"Failed to tag series {series_id} with 'huntarr-upgraded': {e}")
# We'll increment stats individually for each episode instead of in batch
# increment_stat("sonarr", "upgraded", len(episode_ids))

View File

@@ -501,33 +501,36 @@ def add_tag_to_series(api_url: str, api_key: str, api_timeout: int, series_id: i
whisparr_logger.error(f"Error adding tag {tag_id} to series {series_id}: {e}")
return False
def tag_processed_series(api_url: str, api_key: str, api_timeout: int, series_id: int, tag_label: str = "huntarr-processed") -> bool:
def tag_processed_series(api_url: str, api_key: str, api_timeout: int, series_id: int, tag_label: str = "huntarr-missing") -> bool:
"""
Tag a series as processed by Huntarr.
Tag a series in Whisparr with the specified tag.
Args:
api_url: The base URL of the Whisparr API
api_key: The API key for authentication
api_key: The API key for authentication
api_timeout: Timeout for the API request
series_id: The ID of the series to tag
tag_label: The label of the tag to add (default: "huntarr-processed")
tag_label: The tag to apply (huntarr-missing, huntarr-upgraded)
Returns:
True if successful, False otherwise
True if the tagging was successful, False otherwise
"""
try:
# Get or create the tag
tag_id = get_or_create_tag(api_url, api_key, api_timeout, tag_label)
if not tag_id:
whisparr_logger.error(f"Failed to get or create tag '{tag_label}'")
if tag_id is None:
whisparr_logger.error(f"Failed to get or create tag '{tag_label}' in Whisparr")
return False
# Add the tag to the series
success = add_tag_to_series(api_url, api_key, api_timeout, series_id, tag_id)
if success:
whisparr_logger.info(f"Successfully tagged series {series_id} with '{tag_label}'")
return success
whisparr_logger.debug(f"Successfully tagged Whisparr series {series_id} with '{tag_label}'")
return True
else:
whisparr_logger.error(f"Failed to add tag '{tag_label}' to Whisparr series {series_id}")
return False
except Exception as e:
whisparr_logger.error(f"Error tagging series {series_id} with '{tag_label}': {e}")
whisparr_logger.error(f"Error tagging Whisparr series {series_id} with '{tag_label}': {e}")
return False

View File

@@ -182,10 +182,10 @@ def process_missing_items(
series_id = item.get('seriesId')
if series_id:
try:
whisparr_api.tag_processed_series(api_url, api_key, api_timeout, series_id)
whisparr_logger.debug(f"Tagged series {series_id} as processed")
whisparr_api.tag_processed_series(api_url, api_key, api_timeout, series_id, "huntarr-missing")
whisparr_logger.debug(f"Tagged series {series_id} with 'huntarr-missing'")
except Exception as e:
whisparr_logger.warning(f"Failed to tag series {series_id}: {e}")
whisparr_logger.warning(f"Failed to tag series {series_id} with 'huntarr-missing': {e}")
# Log to history system
media_name = f"{title} - {season_episode}"

View File

@@ -159,10 +159,10 @@ def process_cutoff_upgrades(
series_id = item.get('seriesId')
if series_id:
try:
whisparr_api.tag_processed_series(api_url, api_key, api_timeout, series_id)
whisparr_logger.debug(f"Tagged series {series_id} as processed for upgrades")
whisparr_api.tag_processed_series(api_url, api_key, api_timeout, series_id, "huntarr-upgraded")
whisparr_logger.debug(f"Tagged series {series_id} with 'huntarr-upgraded'")
except Exception as e:
whisparr_logger.warning(f"Failed to tag series {series_id}: {e}")
whisparr_logger.warning(f"Failed to tag series {series_id} with 'huntarr-upgraded': {e}")
# Log to history so the upgrade appears in the history UI
series_title = item.get("series", {}).get("title", "Unknown Series")

View File

@@ -1 +1 @@
7.6.8
7.6.9