v1.0.171 - new feature "searchSort"

Change how the list is processed by changing the sort order...
pull/16/head
RandomNinjaAtk 3 years ago committed by GitHub
parent 517b8d518c
commit 2ee35f95a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
scriptVersion="1.0.170" scriptVersion="1.0.171"
lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)"
if [ "$lidarrUrlBase" = "null" ]; then if [ "$lidarrUrlBase" = "null" ]; then
lidarrUrlBase="" lidarrUrlBase=""
@ -24,6 +24,7 @@ musicbrainzMirror=https://musicbrainz.org
#numberOfRelatedArtistsToAddPerArtist=1 #numberOfRelatedArtistsToAddPerArtist=1
#beetsMatchPercentage=85 #beetsMatchPercentage=85
#requireQuality=true #requireQuality=true
#searchSort=album
sleepTimer=0.5 sleepTimer=0.5
@ -915,8 +916,19 @@ GetMissingCutOffList () {
mkdir -p /config/extended/cache/lidarr/list mkdir -p /config/extended/cache/lidarr/list
# Get missing album list # Get missing album list
lidarrMissingTotalRecords=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/wanted/missing?page=1&pagesize=1&sortKey=releaseDate&sortDirection=desc&apikey=${lidarrApiKey}" | jq -r .totalRecords) if [] $searchSort = date ]; then
log ":: FINDING MISSING ALBUMS" searchOrder=releaseDate
searchDirection=descending
fi
if [ $searchSort = album ]; then
searchOrder=albumType
searchDirection=ascending
fi
lidarrMissingTotalRecords=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/wanted/missing?page=1&pagesize=1&sortKey=$searchOrder&sortDirection=$searchDirection&apikey=${lidarrApiKey}" | jq -r .totalRecords)
log ":: FINDING MISSING ALBUMS :: sorted by $searchSort"
if [ $lidarrMissingTotalRecords -le 1000 ]; then if [ $lidarrMissingTotalRecords -le 1000 ]; then
amountPerPull=500 amountPerPull=500
@ -952,7 +964,8 @@ GetMissingCutOffList () {
dlnumber=$lidarrMissingTotalRecords dlnumber=$lidarrMissingTotalRecords
fi fi
log ":: Downloading page $page... ($offset - $dlnumber of $lidarrMissingTotalRecords Results)" log ":: Downloading page $page... ($offset - $dlnumber of $lidarrMissingTotalRecords Results)"
lidarrRecords=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/wanted/missing?page=$page&pagesize=$amountPerPull&sortKey=releaseDate&sortDirection=desc&apikey=${lidarrApiKey}" | jq -r '.records[].id') lidarrRecords=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/wanted/missing?page=$page&pagesize=$amountPerPull&sortKey=$searchOrder&sortDirection=$searchDirection&apikey=${lidarrApiKey}" | jq -r '.records[].id')
for lidarrRecordId in $(echo $lidarrRecords); do for lidarrRecordId in $(echo $lidarrRecords); do
touch /config/extended/cache/lidarr/list/${lidarrRecordId}-missing touch /config/extended/cache/lidarr/list/${lidarrRecordId}-missing
done done
@ -962,9 +975,8 @@ GetMissingCutOffList () {
log ":: ${lidarrMissingTotalRecords} MISSING ALBUMS FOUND" log ":: ${lidarrMissingTotalRecords} MISSING ALBUMS FOUND"
# Get cutoff album list # Get cutoff album list
lidarrCutoffTotalRecords=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/wanted/cutoff?page=1&pagesize=1&sortKey=releaseDate&sortDirection=desc&apikey=${lidarrApiKey}" | jq -r .totalRecords) lidarrCutoffTotalRecords=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/wanted/cutoff?page=1&pagesize=1&sortKey=$searchOrder&sortDirection=$searchDirection&apikey=${lidarrApiKey}" | jq -r .totalRecords)
log ":: FINDING CUTOFF ALBUMS sorted by $searchSort"
log ":: FINDING CUTOFF ALBUMS"
if [ $lidarrCutoffTotalRecords -ge 1 ]; then if [ $lidarrCutoffTotalRecords -ge 1 ]; then
offsetcount=$(( $lidarrCutoffTotalRecords / $amountPerPull )) offsetcount=$(( $lidarrCutoffTotalRecords / $amountPerPull ))
@ -976,7 +988,7 @@ GetMissingCutOffList () {
dlnumber=$lidarrCutoffTotalRecords dlnumber=$lidarrCutoffTotalRecords
fi fi
log ":: Downloading page $page... ($offset - $dlnumber of $lidarrCutoffTotalRecords Results)" log ":: Downloading page $page... ($offset - $dlnumber of $lidarrCutoffTotalRecords Results)"
lidarrRecords=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/wanted/cutoff?page=$page&pagesize=$amountPerPull&sortKey=releaseDate&sortDirection=desc&apikey=${lidarrApiKey}" | jq -r '.records[].id') lidarrRecords=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/wanted/cutoff?page=$page&pagesize=$amountPerPull&sortKey=$searchOrder&sortDirection=$searchDirection&apikey=${lidarrApiKey}" | jq -r '.records[].id')
for lidarrRecordId in $(echo $lidarrRecords); do for lidarrRecordId in $(echo $lidarrRecords); do
touch /config/extended/cache/lidarr/list/${lidarrRecordId}-cutoff touch /config/extended/cache/lidarr/list/${lidarrRecordId}-cutoff
done done

Loading…
Cancel
Save