Skip to content

Commit f1e6d74

Browse files
committed
Implemented the already in queue logic minus the refactor from #141
1 parent 7af4e67 commit f1e6d74

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

soularr.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,40 @@ def get_records(missing: bool) -> list:
692692
os.remove(lock_file_path)
693693

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

696730
return wanted_records
697731

0 commit comments

Comments
 (0)