Import fix if empty release group
This commit is contained in:
parent
9b7a5360bc
commit
c91d1219d0
@ -43,9 +43,13 @@ class ImportController < ApplicationController
|
|||||||
|
|
||||||
# Get album releases from MB
|
# Get album releases from MB
|
||||||
releases_mb = brainz.release(nil, {'release-group' => mb_album['id']})['release_list']['release']
|
releases_mb = brainz.release(nil, {'release-group' => mb_album['id']})['release_list']['release']
|
||||||
|
|
||||||
|
unless releases_mb.empty? or releases_mb.nil?
|
||||||
|
|
||||||
if releases_mb.is_a? Hash
|
if releases_mb.is_a? Hash
|
||||||
releases_mb = [releases_mb]
|
releases_mb = [releases_mb]
|
||||||
end
|
end
|
||||||
|
|
||||||
releases_mb.delete_if { |a| a['date'].nil? }
|
releases_mb.delete_if { |a| a['date'].nil? }
|
||||||
releases_mb.each do |release|
|
releases_mb.each do |release|
|
||||||
if release['date'].length == 4
|
if release['date'].length == 4
|
||||||
@ -55,8 +59,6 @@ class ImportController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
unless releases_mb.empty?
|
|
||||||
|
|
||||||
# Sorting releases by date
|
# Sorting releases by date
|
||||||
releases_mb.sort! { |a, b| a['date'].to_date <=> b['date'].to_date }
|
releases_mb.sort! { |a, b| a['date'].to_date <=> b['date'].to_date }
|
||||||
main_release = releases_mb.shift
|
main_release = releases_mb.shift
|
||||||
|
Loading…
x
Reference in New Issue
Block a user