mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Update metadata.rs
Properly check forbidden and allowed lists, skip tracks where allowed list is set but is empty.
This commit is contained in:
parent
4a17a15a82
commit
8bd9174370
1 changed files with 15 additions and 4 deletions
|
@ -17,18 +17,29 @@ fn parse_restrictions<'s, I>(restrictions: I, country: &str, catalogue: &str) ->
|
||||||
where I: IntoIterator<Item = &'s protocol::metadata::Restriction>
|
where I: IntoIterator<Item = &'s protocol::metadata::Restriction>
|
||||||
{
|
{
|
||||||
let mut forbidden = "".to_string();
|
let mut forbidden = "".to_string();
|
||||||
|
let mut has_forbidden = false;
|
||||||
|
|
||||||
let mut allowed = "".to_string();
|
let mut allowed = "".to_string();
|
||||||
|
let mut has_allowed = false;
|
||||||
|
|
||||||
let rs = restrictions.into_iter().filter(|r|
|
let rs = restrictions.into_iter().filter(|r|
|
||||||
r.get_catalogue_str().contains(&catalogue.to_owned())
|
r.get_catalogue_str().contains(&catalogue.to_owned())
|
||||||
);
|
);
|
||||||
|
|
||||||
for r in rs {
|
for r in rs {
|
||||||
forbidden.push_str(r.get_countries_forbidden());
|
if r.has_countries_forbidden() {
|
||||||
allowed.push_str(r.get_countries_allowed());
|
forbidden.push_str(r.get_countries_forbidden());
|
||||||
|
has_forbidden = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.has_countries_allowed() {
|
||||||
|
allowed.push_str(r.get_countries_allowed());
|
||||||
|
has_allowed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(forbidden == "" || !countrylist_contains(forbidden.as_str(), country)) &&
|
(!has_forbidden || !countrylist_contains(forbidden.as_str(), country)) &&
|
||||||
(allowed == "" || countrylist_contains(allowed.as_str(), country))
|
(!has_allowed || countrylist_contains(allowed.as_str(), country))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait MetadataTrait : Send + 'static {
|
pub trait MetadataTrait : Send + 'static {
|
||||||
|
|
Loading…
Reference in a new issue