Artist key cleanup
This commit is contained in:
parent
e06f79c500
commit
ef6951faba
4 changed files with 21 additions and 28 deletions
|
@ -173,7 +173,7 @@ impl Manager {
|
||||||
.strings
|
.strings
|
||||||
.get(name)
|
.get(name)
|
||||||
.ok_or_else(|| Error::ArtistNotFound)?;
|
.ok_or_else(|| Error::ArtistNotFound)?;
|
||||||
let artist_key = ArtistKey { name };
|
let artist_key = ArtistKey(name);
|
||||||
index
|
index
|
||||||
.collection
|
.collection
|
||||||
.get_artist(&index.strings, artist_key)
|
.get_artist(&index.strings, artist_key)
|
||||||
|
@ -197,7 +197,7 @@ impl Manager {
|
||||||
artists: artists
|
artists: artists
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|a| index.strings.get(a))
|
.filter_map(|a| index.strings.get(a))
|
||||||
.map(|k| ArtistKey { name: k })
|
.map(|k| ArtistKey(k))
|
||||||
.collect(),
|
.collect(),
|
||||||
name,
|
name,
|
||||||
};
|
};
|
||||||
|
|
|
@ -232,7 +232,7 @@ fn make_album_header(album: &storage::Album, strings: &RodeoReader) -> AlbumHead
|
||||||
artists: album
|
artists: album
|
||||||
.artists
|
.artists
|
||||||
.iter()
|
.iter()
|
||||||
.map(|a| strings.resolve(&a.name).to_string())
|
.map(|a| strings.resolve(&a.0).to_string())
|
||||||
.collect(),
|
.collect(),
|
||||||
year: album.year,
|
year: album.year,
|
||||||
date_added: album.date_added,
|
date_added: album.date_added,
|
||||||
|
@ -364,7 +364,7 @@ impl Builder {
|
||||||
self.artists
|
self.artists
|
||||||
.entry(artist_key)
|
.entry(artist_key)
|
||||||
.or_insert_with(|| storage::Artist {
|
.or_insert_with(|| storage::Artist {
|
||||||
name: artist_key.name,
|
name: artist_key.0,
|
||||||
all_albums: HashSet::new(),
|
all_albums: HashSet::new(),
|
||||||
albums_as_performer: HashSet::new(),
|
albums_as_performer: HashSet::new(),
|
||||||
albums_as_additional_performer: HashSet::new(),
|
albums_as_additional_performer: HashSet::new(),
|
||||||
|
@ -777,12 +777,8 @@ mod test {
|
||||||
},
|
},
|
||||||
]));
|
]));
|
||||||
|
|
||||||
let artist = collection.get_artist(
|
let artist =
|
||||||
&strings,
|
collection.get_artist(&strings, ArtistKey(strings.get("Stratovarius").unwrap()));
|
||||||
ArtistKey {
|
|
||||||
name: strings.get("Stratovarius").unwrap(),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
let names = artist
|
let names = artist
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -843,12 +839,11 @@ mod test {
|
||||||
},
|
},
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
let artist = ArtistKey(strings.get("FSOL").unwrap());
|
||||||
let album = collection.get_album(
|
let album = collection.get_album(
|
||||||
&strings,
|
&strings,
|
||||||
AlbumKey {
|
AlbumKey {
|
||||||
artists: tiny_vec![ArtistKey {
|
artists: tiny_vec!([ArtistKey; 4] => artist),
|
||||||
name: strings.get("FSOL").unwrap()
|
|
||||||
}],
|
|
||||||
name: strings.get("Lifeforms").unwrap(),
|
name: strings.get("Lifeforms").unwrap(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -287,11 +287,11 @@ impl Builder {
|
||||||
.iter()
|
.iter()
|
||||||
.zip(storage_song.album_artists.iter())
|
.zip(storage_song.album_artists.iter())
|
||||||
{
|
{
|
||||||
self.text_fields[TextField::AlbumArtist].insert(str, artist_key.name, song_key);
|
self.text_fields[TextField::AlbumArtist].insert(str, artist_key.0, song_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (str, artist_key) in scanner_song.artists.iter().zip(storage_song.artists.iter()) {
|
for (str, artist_key) in scanner_song.artists.iter().zip(storage_song.artists.iter()) {
|
||||||
self.text_fields[TextField::Artist].insert(str, artist_key.name, song_key);
|
self.text_fields[TextField::Artist].insert(str, artist_key.0, song_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (str, artist_key) in scanner_song
|
for (str, artist_key) in scanner_song
|
||||||
|
@ -299,7 +299,7 @@ impl Builder {
|
||||||
.iter()
|
.iter()
|
||||||
.zip(storage_song.composers.iter())
|
.zip(storage_song.composers.iter())
|
||||||
{
|
{
|
||||||
self.text_fields[TextField::Composer].insert(str, artist_key.name, song_key);
|
self.text_fields[TextField::Composer].insert(str, artist_key.0, song_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(disc_number) = &scanner_song.disc_number {
|
if let Some(disc_number) = &scanner_song.disc_number {
|
||||||
|
@ -319,7 +319,7 @@ impl Builder {
|
||||||
.iter()
|
.iter()
|
||||||
.zip(storage_song.lyricists.iter())
|
.zip(storage_song.lyricists.iter())
|
||||||
{
|
{
|
||||||
self.text_fields[TextField::Lyricist].insert(str, artist_key.name, song_key);
|
self.text_fields[TextField::Lyricist].insert(str, artist_key.0, song_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.text_fields[TextField::Path].insert(
|
self.text_fields[TextField::Path].insert(
|
||||||
|
|
|
@ -75,9 +75,7 @@ pub struct GenreKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct ArtistKey {
|
pub struct ArtistKey(pub Spur);
|
||||||
pub name: Spur,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct AlbumKey {
|
pub struct AlbumKey {
|
||||||
|
@ -166,13 +164,13 @@ pub fn store_song(
|
||||||
.artists
|
.artists
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(&mut canonicalize)
|
.filter_map(&mut canonicalize)
|
||||||
.map(|k| ArtistKey { name: k })
|
.map(|k| ArtistKey(k))
|
||||||
.collect(),
|
.collect(),
|
||||||
album_artists: song
|
album_artists: song
|
||||||
.album_artists
|
.album_artists
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(&mut canonicalize)
|
.filter_map(&mut canonicalize)
|
||||||
.map(|k| ArtistKey { name: k })
|
.map(|k| ArtistKey(k))
|
||||||
.collect(),
|
.collect(),
|
||||||
year: song.year,
|
year: song.year,
|
||||||
album: song.album.as_ref().and_then(&mut canonicalize),
|
album: song.album.as_ref().and_then(&mut canonicalize),
|
||||||
|
@ -182,13 +180,13 @@ pub fn store_song(
|
||||||
.lyricists
|
.lyricists
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(&mut canonicalize)
|
.filter_map(&mut canonicalize)
|
||||||
.map(|k| ArtistKey { name: k })
|
.map(|k| ArtistKey(k))
|
||||||
.collect(),
|
.collect(),
|
||||||
composers: song
|
composers: song
|
||||||
.composers
|
.composers
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(&mut canonicalize)
|
.filter_map(&mut canonicalize)
|
||||||
.map(|k| ArtistKey { name: k })
|
.map(|k| ArtistKey(k))
|
||||||
.collect(),
|
.collect(),
|
||||||
genres: song.genres.iter().filter_map(&mut canonicalize).collect(),
|
genres: song.genres.iter().filter_map(&mut canonicalize).collect(),
|
||||||
labels: song.labels.iter().filter_map(&mut canonicalize).collect(),
|
labels: song.labels.iter().filter_map(&mut canonicalize).collect(),
|
||||||
|
@ -206,12 +204,12 @@ pub fn fetch_song(strings: &RodeoReader, song: &Song) -> super::Song {
|
||||||
artists: song
|
artists: song
|
||||||
.artists
|
.artists
|
||||||
.iter()
|
.iter()
|
||||||
.map(|k| strings.resolve(&k.name).to_string())
|
.map(|k| strings.resolve(&k.0).to_string())
|
||||||
.collect(),
|
.collect(),
|
||||||
album_artists: song
|
album_artists: song
|
||||||
.album_artists
|
.album_artists
|
||||||
.iter()
|
.iter()
|
||||||
.map(|k| strings.resolve(&k.name).to_string())
|
.map(|k| strings.resolve(&k.0).to_string())
|
||||||
.collect(),
|
.collect(),
|
||||||
year: song.year,
|
year: song.year,
|
||||||
album: song.album.map(|s| strings.resolve(&s).to_string()),
|
album: song.album.map(|s| strings.resolve(&s).to_string()),
|
||||||
|
@ -220,12 +218,12 @@ pub fn fetch_song(strings: &RodeoReader, song: &Song) -> super::Song {
|
||||||
lyricists: song
|
lyricists: song
|
||||||
.lyricists
|
.lyricists
|
||||||
.iter()
|
.iter()
|
||||||
.map(|k| strings.resolve(&k.name).to_string())
|
.map(|k| strings.resolve(&k.0).to_string())
|
||||||
.collect(),
|
.collect(),
|
||||||
composers: song
|
composers: song
|
||||||
.composers
|
.composers
|
||||||
.iter()
|
.iter()
|
||||||
.map(|k| strings.resolve(&k.name).to_string())
|
.map(|k| strings.resolve(&k.0).to_string())
|
||||||
.collect(),
|
.collect(),
|
||||||
genres: song
|
genres: song
|
||||||
.genres
|
.genres
|
||||||
|
|
Loading…
Add table
Reference in a new issue