Playback, import fixes
This commit is contained in:
+7
-3
@@ -12,7 +12,7 @@ class Album < ActiveRecord::Base
|
||||
# .order('"albums"."year" ASC')
|
||||
}
|
||||
|
||||
attr_accessible :artist_id, :pic, :rovi_id, :title, :year, :is_hidden
|
||||
attr_accessible :artist_id, :pic, :rovi_id, :title, :year, :is_hidden, :tracks
|
||||
VA = "Various Artists"
|
||||
|
||||
def pic_safe
|
||||
@@ -23,6 +23,10 @@ class Album < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def pic_thumb
|
||||
pic_safe
|
||||
end
|
||||
|
||||
def load_pic
|
||||
info = begin
|
||||
response = LastFM::Album.get_info(artist: (artist.nil? ? VA : artist.name), album: title)
|
||||
@@ -52,14 +56,14 @@ class Album < ActiveRecord::Base
|
||||
update_attributes(
|
||||
title: robbie_album.title,
|
||||
year: robbie_album.year,
|
||||
tracks: robbie_album.tracks.each { |robbie_track|
|
||||
tracks: robbie_album.tracks.map{ |robbie_track|
|
||||
track = Track.find_or_create_by_rovi_id(robbie_track.id)
|
||||
track.update_attributes(
|
||||
disc_id: robbie_track.disc_id,
|
||||
position: robbie_track.position,
|
||||
title: robbie_track.title,
|
||||
duration: robbie_track.duration,
|
||||
artists: robbie_track.artists.map { |robbie_artist|
|
||||
artists: robbie_track.artists.map{ |robbie_artist|
|
||||
track_artist = Artist.find_or_create_by_rovi_id(robbie_artist.id)
|
||||
track_artist.update_attributes(
|
||||
name: robbie_artist.name
|
||||
|
||||
@@ -2,9 +2,10 @@ class Artist < ActiveRecord::Base
|
||||
has_many :albums
|
||||
has_many :performers
|
||||
has_many :tracks, through: :performers
|
||||
has_many :artist_genres
|
||||
has_many :genres, through: :artist_genres
|
||||
|
||||
attr_accessible :bio, :is_group, :name, :pic, :rovi_id
|
||||
attr_accessible :bio, :is_group, :name, :pic, :rovi_id, :albums, :genres
|
||||
|
||||
scope :discography, lambda {
|
||||
includes(:albums).includes(:tracks)
|
||||
@@ -15,7 +16,7 @@ class Artist < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def url
|
||||
"/artist/#{name.gsub(/\s/, "+")}"
|
||||
"/artist/#{name.gsub(/\s/, "+")}" rescue ""
|
||||
end
|
||||
|
||||
def import
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
class ArtistGenre < ActiveRecord::Base
|
||||
belongs_to :artist
|
||||
belongs_to :genre
|
||||
|
||||
attr_accessible :artist_id, :genre_id
|
||||
end
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ class Track < ActiveRecord::Base
|
||||
has_many :performers
|
||||
has_many :artists, through: :performers
|
||||
|
||||
attr_accessible :album_id, :disc_id, :duration, :position, :rovi_id, :title
|
||||
attr_accessible :album_id, :disc_id, :duration, :position, :rovi_id, :title, :artists
|
||||
scope :with_artists, lambda{
|
||||
includes(:artists)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user