@@ -695,6 +695,40 @@ def get_records(missing: bool) -> list:
695695 os .remove (lock_file_path )
696696
697697 raise ValueError (f'[Search Settings] - { search_type = } is not valid' )
698+
699+ try :
700+
701+ queued_records = lidarr .get_queue (sort_dir = 'ascending' ,sort_key = 'albums.title' )
702+ total_queued = queued_records ['totalRecords' ]
703+ current_queue = queued_records ['records' ]
704+
705+ if queued_records ['pageSize' ] < total_queued :
706+ page = 2
707+ while len (current_queue ) < total_queued :
708+ try :
709+ next_page = lidarr .get_queue (page = page ,sort_key = 'albums.title' ,sort_dir = 'ascending' )
710+ except ConnectionError as ex :
711+ logger .error (f"Failed to get queue details: { ex } " )
712+ break
713+ current_queue .extend (next_page ['records' ])
714+ page += 1
715+
716+ queued_album_ids = [record ['album_id' ] for record in current_queue ]
717+ wanted_records_not_queued = []
718+ for record in wanted_records :
719+ for release in record ['releases' ]:
720+ if release ['album_id' ] in queued_album_ids :
721+ logging .info (f"Skipping record '{ record ['title' ]} ' because it's already in download queue" )
722+ break
723+ else : #This only runs if the loop is broken out of. Saves on all the boolean found= stuff
724+ wanted_records_not_queued .append (record )
725+ if len (wanted_records_not_queued ) > 0 :
726+ wanted_records = wanted_records_not_queued
727+ else :
728+ logging .info ("No records wanted that arent already queued" )
729+ wanted_records = []
730+ except ConnectionError as ex :
731+ logger .error (f"Failed to get queue details so not filtering based on queue: { ex } " )
698732
699733 return wanted_records
700734
0 commit comments