fix: support localized Spotify URLs (#1456)

* fix: support localized Spotify URLs

* Update changelog and format using cargo fmt
This commit is contained in:
Bettehem
2024-05-17 22:01:06 +03:00
committed by GitHub
parent 9b54ace100
commit 1ffa03daaf
2 changed files with 14 additions and 1 deletions

View File

@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Fixed
- Handling localized Spotify URLs
## [1.1.1] - 2024-05-10
### Added

View File

@@ -47,8 +47,11 @@ impl SpotifyUrl {
let mut path_segments = url.path_segments()?;
let entity = path_segments.next()?;
let mut entity = path_segments.next()?;
if entity.to_lowercase().as_str().starts_with("intl-") {
entity = path_segments.next()?
}
let uri_type = match entity.to_lowercase().as_str() {
"album" => Some(UriType::Album),
"artist" => Some(UriType::Artist),
@@ -93,6 +96,10 @@ mod tests {
"https://open.spotify.com/track/6fRJg3R90w0juYoCJXxj2d",
SpotifyUrl::new("6fRJg3R90w0juYoCJXxj2d", UriType::Track),
);
test_cases.insert(
"https://open.spotify.com/intl-pt/track/3Kj2M9gRU1Lwf5eiNjBtBp",
SpotifyUrl::new("3Kj2M9gRU1Lwf5eiNjBtBp", UriType::Track),
);
test_cases.insert(
"https://open.spotify.com/user/~villainy~/playlist/0OgoSs65CLDPn6AF6tsZVg",
SpotifyUrl::new("0OgoSs65CLDPn6AF6tsZVg", UriType::Playlist),