Fall back to just matching song title if album can't be matched

Fixes most cases where a song couldn't be found on the media server
This commit is contained in:
jude 2024-05-25 14:27:48 +01:00
parent b0f9764fcf
commit eb30bc11d9
4 changed files with 25 additions and 8 deletions

View File

@ -14,7 +14,8 @@
<component name="ChangeListManager">
<list default="true" id="52900e09-9584-4b6c-95ff-fbd4ed5d8b2c" name="Changes" comment="Add interface package. Start adding auth stuff for refreshing tokens.">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.toml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/daemon/update_playlists.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/daemon/update_playlists.rs" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -160,7 +161,11 @@
<workItem from="1713465993328" duration="1750000" />
<workItem from="1713469457285" duration="6588000" />
<workItem from="1713609379678" duration="7216000" />
<workItem from="1713639881551" duration="450000" />
<workItem from="1713639881551" duration="577000" />
<workItem from="1716043707662" duration="542000" />
<workItem from="1716046070333" duration="1484000" />
<workItem from="1716640392358" duration="367000" />
<workItem from="1716642009543" duration="1073000" />
</task>
<task id="LOCAL-00001" summary="Structure">
<created>1692008860369</created>

2
Cargo.lock generated
View File

@ -1456,7 +1456,7 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
[[package]]
name = "playlistd"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"chrono",
"config",

View File

@ -1,6 +1,6 @@
[package]
name = "playlistd"
version = "0.2.2"
version = "0.2.3"
edition = "2021"
authors = ["Jude Southworth (judesouthworth@pm.me)"]
license = "AGPL-3.0 only"

View File

@ -95,10 +95,22 @@ async fn update_playlist(
tracks.push(track.id);
}
None => {
error!(
"Couldn't find matching track for {} - {}",
recording.track_name, recording.artist_name
)
let filtered = search_results
.iter()
.find(|s| alpha_compare(&s.title, &recording.track_name))
.cloned();
match filtered {
Some(track) => {
tracks.push(track.id);
}
None => {
error!(
"Couldn't find matching track for {} - {}",
recording.track_name, recording.artist_name
)
}
}
}
}
}