fix: support YTM browse urls

This commit is contained in:
ThetaDev 2022-11-09 21:02:21 +01:00
parent ea16a3e74f
commit 9b6c952fd3
3 changed files with 16 additions and 3 deletions

View file

@ -72,6 +72,19 @@ impl RustyPipeQuery {
Ok(UrlTarget::Playlist { id })
}
}
// Album or channel
Some("browse") => match path_split.next() {
Some(id) => {
if util::CHANNEL_ID_REGEX.is_match(id).unwrap_or_default() {
Ok(UrlTarget::Channel { id: id.to_owned() })
} else if util::ALBUM_ID_REGEX.is_match(id).unwrap_or_default() {
Ok(UrlTarget::Album { id: id.to_owned() })
} else {
Err(Error::Other("invalid url: no browse id".into()))
}
}
None => Err(Error::Other("invalid url: invalid browse id".into())),
},
// Channel vanity URL or youtu.be shortlink
Some(mut id) => {
if id == "c" || id == "user" {

View file

@ -68,9 +68,7 @@ impl UrlTarget {
format!("{}/playlist?list={}", yt_host, id)
}
UrlTarget::Album { id } => {
// The official album URLs use the playlist ID
// This looks weird, but it works
format!("{}/channel/{}", yt_host, id)
format!("https://music.youtube.com/browse/{}", id)
}
}
}