connect watchlist settings to scan
This commit is contained in:
parent
4684408439
commit
27f115d719
2 changed files with 57 additions and 6 deletions
|
|
@ -299,7 +299,13 @@ class WatchlistScanner:
|
||||||
|
|
||||||
tracks = album_data['tracks']['items']
|
tracks = album_data['tracks']['items']
|
||||||
logger.debug(f"Checking album: {album_data.get('name', 'Unknown')} ({len(tracks)} tracks)")
|
logger.debug(f"Checking album: {album_data.get('name', 'Unknown')} ({len(tracks)} tracks)")
|
||||||
|
|
||||||
|
# Check if user wants this type of release
|
||||||
|
if not self._should_include_release(len(tracks), watchlist_artist):
|
||||||
|
release_type = "album" if len(tracks) >= 7 else ("EP" if len(tracks) >= 4 else "single")
|
||||||
|
logger.debug(f"Skipping {release_type}: {album_data.get('name', 'Unknown')} - user preference")
|
||||||
|
continue
|
||||||
|
|
||||||
# Check each track
|
# Check each track
|
||||||
for track in tracks:
|
for track in tracks:
|
||||||
if self.is_track_missing_from_library(track):
|
if self.is_track_missing_from_library(track):
|
||||||
|
|
@ -454,11 +460,48 @@ class WatchlistScanner:
|
||||||
timestamp = timestamp.replace(tzinfo=timezone.utc)
|
timestamp = timestamp.replace(tzinfo=timezone.utc)
|
||||||
|
|
||||||
return album_date > timestamp
|
return album_date > timestamp
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Error comparing album date {album.release_date} with timestamp {timestamp}: {e}")
|
logger.warning(f"Error comparing album date {album.release_date} with timestamp {timestamp}: {e}")
|
||||||
return True # Include if we can't determine
|
return True # Include if we can't determine
|
||||||
|
|
||||||
|
def _should_include_release(self, track_count: int, watchlist_artist: WatchlistArtist) -> bool:
|
||||||
|
"""
|
||||||
|
Check if a release should be included based on user's preferences.
|
||||||
|
|
||||||
|
Categorization:
|
||||||
|
- Singles: 1-3 tracks
|
||||||
|
- EPs: 4-6 tracks
|
||||||
|
- Albums: 7+ tracks
|
||||||
|
|
||||||
|
Args:
|
||||||
|
track_count: Number of tracks in the release
|
||||||
|
watchlist_artist: WatchlistArtist object with user preferences
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
True if release should be included, False if should be skipped
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
# Default to including everything if preferences aren't set (backwards compatibility)
|
||||||
|
include_albums = getattr(watchlist_artist, 'include_albums', True)
|
||||||
|
include_eps = getattr(watchlist_artist, 'include_eps', True)
|
||||||
|
include_singles = getattr(watchlist_artist, 'include_singles', True)
|
||||||
|
|
||||||
|
# Determine release type based on track count
|
||||||
|
if track_count >= 7:
|
||||||
|
# This is an album
|
||||||
|
return include_albums
|
||||||
|
elif track_count >= 4:
|
||||||
|
# This is an EP (4-6 tracks)
|
||||||
|
return include_eps
|
||||||
|
else:
|
||||||
|
# This is a single (1-3 tracks)
|
||||||
|
return include_singles
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Error checking release inclusion: {e}")
|
||||||
|
return True # Default to including on error
|
||||||
|
|
||||||
def is_track_missing_from_library(self, track) -> bool:
|
def is_track_missing_from_library(self, track) -> bool:
|
||||||
"""
|
"""
|
||||||
Check if a track is missing from the local Plex library.
|
Check if a track is missing from the local Plex library.
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,11 @@ class WatchlistScanWorker(QThread):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
track_count = len(album_data['tracks'].get('items', []))
|
track_count = len(album_data['tracks'].get('items', []))
|
||||||
|
|
||||||
|
# Check if user wants this type of release
|
||||||
|
if not scanner._should_include_release(track_count, watchlist_artist):
|
||||||
|
continue # Skip counting this release
|
||||||
|
|
||||||
# Categorize based on track count - COUNT RELEASES not tracks
|
# Categorize based on track count - COUNT RELEASES not tracks
|
||||||
if track_count >= 4:
|
if track_count >= 4:
|
||||||
total_albums += 1
|
total_albums += 1
|
||||||
|
|
@ -198,10 +202,14 @@ class WatchlistScanWorker(QThread):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
tracks = album_data['tracks']['items']
|
tracks = album_data['tracks']['items']
|
||||||
|
|
||||||
|
# Check if user wants this type of release
|
||||||
|
if not scanner._should_include_release(len(tracks), watchlist_artist):
|
||||||
|
continue # Skip this release
|
||||||
|
|
||||||
# Emit album progress with track count
|
# Emit album progress with track count
|
||||||
self.album_scan_started.emit(watchlist_artist.artist_name, album.name, len(tracks))
|
self.album_scan_started.emit(watchlist_artist.artist_name, album.name, len(tracks))
|
||||||
|
|
||||||
# Check each track
|
# Check each track
|
||||||
for track in tracks:
|
for track in tracks:
|
||||||
if self.should_stop:
|
if self.should_stop:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue