feat(qt): say "not yet available" on pre-release tracks

/album/get sends streamable_at and release_date_stream per track: a future
value marks a pre-release, null a pulled track. Track carries both fields
and Track::is_upcoming applies the one rule (future streamable_at wins,
then a future release date); the album, playlist, search and label rows
publish qobuzUpcoming and the unavailable glyph reads "This track is not
yet available" instead of "no longer". Artist page rows carry no dates and
keep the generic copy. New msgid in the seven translated catalogs.

cc
This commit is contained in:
vicrodh committed 2026-09-02 20:34:58 -06:00
1 parent feb2c9de12
commit 35ff1818f6
15 files changed
+160 -9

No files matched your search

@@ -3664,6 +3664,9 @@ msgstr "Dies meldet Sie von Plex ab und löscht die lokal zwischengespeicherten
msgid "This track is no longer available"
msgstr "Dieser Titel ist nicht mehr verfügbar"
msgid "This track is not yet available"
msgstr "Dieser Titel ist noch nicht verfügbar"
msgid "Track count differs from the result; titles applied by position"
msgstr "Die Titelanzahl weicht vom Ergebnis ab; Titel wurden nach Position zugewiesen"
@@ -3670,6 +3670,9 @@ msgstr "Esto cierra la sesión de Plex y borra las bibliotecas y pistas almacena
msgid "This track is no longer available"
msgstr "Esta pista ya no está disponible"
msgid "This track is not yet available"
msgstr "Esta pista todavía no está disponible"
msgid "Track count differs from the result; titles applied by position"
msgstr "El número de pistas difiere del resultado; los títulos se aplicaron por posición"
@@ -3664,6 +3664,9 @@ msgstr "Cette opération vous déconnecte de Plex et efface les bibliothèques e
msgid "This track is no longer available"
msgstr "Ce titre n'est plus disponible"
msgid "This track is not yet available"
msgstr "Ce titre n'est pas encore disponible"
msgid "Track count differs from the result; titles applied by position"
msgstr "Le nombre de titres diffère du résultat ; les titres ont été appliqués par position"
@@ -3508,6 +3508,9 @@ msgstr "これはキャッシュされたPlexのライブラリとトラック
msgid "This track is no longer available"
msgstr "このトラックは利用できなくなりました"
msgid "This track is not yet available"
msgstr "このトラックはまだ利用できません"
msgid "Track count differs from the result; titles applied by position"
msgstr "トラック数が結果と異なります。タイトルは位置順に適用されました"
@@ -3656,6 +3656,9 @@ msgstr "Dit logt uit bij Plex en wist de lokaal gecachte bibliotheken en nummers
msgid "This track is no longer available"
msgstr "Dit nummer is niet meer beschikbaar"
msgid "This track is not yet available"
msgstr "Dit nummer is nog niet beschikbaar"
msgid "Track count differs from the result; titles applied by position"
msgstr "Aantal nummers wijkt af van het resultaat; titels toegepast op positie"
@@ -3664,6 +3664,9 @@ msgstr "Isto termina a sessão no Plex e limpa as bibliotecas e faixas em cache
msgid "This track is no longer available"
msgstr "Esta faixa já não está disponível"
msgid "This track is not yet available"
msgstr "Esta faixa ainda não está disponível"
msgid "Track count differs from the result; titles applied by position"
msgstr "O número de faixas difere do resultado; os títulos foram aplicados por posição"
@@ -3529,6 +3529,9 @@ msgstr "Это удалит кэшированные библиотеки и т
msgid "This track is no longer available"
msgstr "Этот трек больше недоступен"
msgid "This track is not yet available"
msgstr "Этот трек пока недоступен"
msgid "Track count differs from the result; titles applied by position"
msgstr "Количество треков отличается от результата; названия применены по позиции"
+90
View File
@@ -571,6 +571,17 @@ pub struct Track {
/// for the same reasons; the two shapes are now consistent.
#[serde(default)]
pub streamable: Option<bool>,
/// Unix seconds at which streaming rights START for this track
/// (`/album/get` sends it on every item: a PAST value on live tracks,
/// `null` on a pulled one, a FUTURE value on a pre-release). Read through
/// [`Track::is_upcoming`], which is what tells "not yet" from "no longer".
#[serde(default)]
pub streamable_at: Option<i64>,
/// Per-track streaming release date (ISO `YYYY-MM-DD`), the same shape as
/// [`Album::release_date_stream`]. Fallback for [`Track::is_upcoming`]
/// when `streamable_at` is absent.
#[serde(default)]
pub release_date_stream: Option<String>,
#[serde(default)]
pub parental_warning: bool,
/// Playlist-specific: ID within the playlist (for removal)
@@ -608,6 +619,44 @@ impl Track {
pub fn is_streamable(&self) -> bool {
self.streamable.unwrap_or(true)
}
/// Whether this track is a PRE-RELEASE: not streamable today because its
/// streaming rights have not started yet, as opposed to a track Qobuz
/// pulled. Only meaningful alongside `!is_streamable()`; a streamable
/// track is never "upcoming". See [`upcoming_from`] for the rule.
pub fn is_upcoming(&self) -> bool {
!self.is_streamable()
&& upcoming_from(
self.streamable_at,
self.release_date_stream.as_deref(),
chrono::Utc::now(),
)
}
}
/// The ONE rule that tells "not yet available" from "no longer available":
/// a FUTURE `streamable_at` (Unix seconds) wins; without it, a FUTURE
/// `release_date_stream` (`YYYY-MM-DD`, compared by calendar day in UTC).
/// Anything absent, malformed, or in the past reads as NOT upcoming, so a
/// terse endpoint keeps the existing "no longer available" wording rather
/// than promising a release that never comes.
pub fn upcoming_now(streamable_at: Option<i64>, release_date_stream: Option<&str>) -> bool {
upcoming_from(streamable_at, release_date_stream, chrono::Utc::now())
}
/// [`upcoming_now`] against an explicit clock (tests).
pub fn upcoming_from(
streamable_at: Option<i64>,
release_date_stream: Option<&str>,
now: chrono::DateTime<chrono::Utc>,
) -> bool {
if let Some(at) = streamable_at {
return at > now.timestamp();
}
release_date_stream
.and_then(|s| chrono::NaiveDate::parse_from_str(s.trim(), "%Y-%m-%d").ok())
.map(|date| date > now.date_naive())
.unwrap_or(false)
}
/// Album summary (embedded in track responses)
@@ -2253,3 +2302,44 @@ mod purchase_deserializer_tests {
assert_eq!(goodies[0].display_name(), "Booklet");
}
}
#[cfg(test)]
mod upcoming_tests {
use super::{upcoming_from, Track};
use chrono::{TimeZone, Utc};
#[test]
fn future_streamable_at_wins_over_the_date() {
let now = Utc.with_ymd_and_hms(2026, 9, 2, 12, 0, 0).unwrap();
assert!(upcoming_from(Some(now.timestamp() + 60), None, now));
assert!(upcoming_from(Some(now.timestamp() + 60), Some("2000-01-01"), now));
assert!(!upcoming_from(Some(now.timestamp() - 60), Some("2099-01-01"), now));
// The captured dead track: `streamable_at: null`, past release date.
assert!(!upcoming_from(None, Some("2013-06-21"), now));
}
#[test]
fn release_date_is_the_fallback_and_absence_is_not_upcoming() {
let now = Utc.with_ymd_and_hms(2026, 9, 2, 12, 0, 0).unwrap();
assert!(upcoming_from(None, Some("2026-10-16"), now));
assert!(!upcoming_from(None, Some("2026-09-02"), now), "today is not upcoming");
assert!(!upcoming_from(None, Some("not a date"), now));
assert!(!upcoming_from(None, None, now));
}
#[test]
fn a_streamable_track_is_never_upcoming() {
let track = Track {
streamable: Some(true),
release_date_stream: Some("2099-01-01".into()),
..Default::default()
};
assert!(!track.is_upcoming());
let track = Track {
streamable: Some(false),
release_date_stream: Some("2099-01-01".into()),
..Default::default()
};
assert!(track.is_upcoming());
}
}
+7 -5
View File
@@ -777,11 +777,13 @@ Rectangle {
// the same on its unavailable rows.
ToolTip.visible: containsMouse
ToolTip.delay: 300
// REUSED msgid — already translated in all 7
// translated locales (es:3658); it is the same
// sentence the reactive skip path toasts.
ToolTip.text: QbzSession.tr(
"This track is no longer available", QbzSession.trRev)
// A pre-release (`qobuzUpcoming`: streaming rights
// start in the future) is "not yet"; anything else
// unavailable keeps the REUSED msgid the reactive
// skip path toasts.
ToolTip.text: root.item.qobuzUpcoming === true
? QbzSession.tr("This track is not yet available", QbzSession.trRev)
: QbzSession.tr("This track is no longer available", QbzSession.trRev)
}
}
}
+6 -4
View File
@@ -1158,10 +1158,12 @@ Rectangle {
hoverEnabled: true
ToolTip.visible: containsMouse
ToolTip.delay: 300
// REUSED msgid (es:3658) — the same sentence the
// reactive skip path toasts.
ToolTip.text: QbzSession.tr(
"This track is no longer available", QbzSession.trRev)
// Same split as rows/TrackRow.qml: a pre-release
// says "not yet", a pulled track keeps the REUSED
// msgid the reactive skip path toasts.
ToolTip.text: row.qobuzUpcoming === true
? QbzSession.tr("This track is not yet available", QbzSession.trRev)
: QbzSession.tr("This track is no longer available", QbzSession.trRev)
}
}
}
+7
View File
@@ -111,6 +111,12 @@ pub struct TrackRow {
/// neighbours `isFavorite` and `cacheStatus`.
#[serde(rename = "qobuzUnavailable")]
pub not_streamable: bool,
/// Refines `qobuzUnavailable`: the track is not streamable because its
/// release is still ahead (`streamable_at` / `release_date_stream` in the
/// future — `qbz_models::upcoming_from`), so the glyph says "not yet"
/// instead of "no longer". Never true on a streamable row.
#[serde(rename = "qobuzUpcoming")]
pub upcoming: bool,
}
/// `Deserialize` rides along with `Serialize` so a card can be read BACK out of
@@ -554,6 +560,7 @@ fn map_track(track: &Track) -> TrackRow {
// THIS endpoint the answer is real rather than inferred — which is what
// makes the owner's known-bad album a usable smoke.
not_streamable: !track.is_streamable(),
upcoming: track.is_upcoming(),
}
}
+4
View File
@@ -590,6 +590,10 @@ fn map_track(index: usize, track: PageArtistTrack) -> TrackRow {
work_composer_id: String::new(),
artwork_url,
not_streamable,
// /artist/page track items carry neither `streamable_at` nor a
// release date (only the nested `rights`), so an unavailable row here
// keeps the generic "no longer available" wording.
upcoming: false,
}
}
+7
View File
@@ -1286,6 +1286,12 @@ fn parse_top_track(index: usize, raw: &Value) -> TrackRow {
.and_then(|v| v.as_bool())
})
.unwrap_or(true);
// Same rule as `qbz_models::Track::is_upcoming`, read off the raw keys.
let upcoming = not_streamable
&& qbz_models::types::upcoming_now(
raw.get("streamable_at").and_then(|v| v.as_i64()),
raw.get("release_date_stream").and_then(|v| v.as_str()),
);
TrackRow {
is_favorite: id
.parse::<u64>()
@@ -1321,6 +1327,7 @@ fn parse_top_track(index: usize, raw: &Value) -> TrackRow {
work_composer_id: String::new(),
artwork_url,
not_streamable,
upcoming,
}
}
+9
View File
@@ -144,6 +144,14 @@ pub struct PlaylistTrackRow {
skip_serializing_if = "std::ops::Not::not"
)]
pub not_streamable: bool,
/// Refines `qobuzUnavailable`: a pre-release (release still ahead) rather
/// than a pulled track — `qbz_models::Track::is_upcoming`.
#[serde(
default,
rename = "qobuzUpcoming",
skip_serializing_if = "std::ops::Not::not"
)]
pub upcoming: bool,
/// The recording identifier, carried so the replacement search's ISRC
/// short-circuit can fire (`qbz-playlist-import/src/match_qobuz.rs:156-159`
/// scores an ISRC hit 1.0). That is the owner's "a veces cambia el ID del
@@ -794,6 +802,7 @@ pub(crate) fn map_track(track: &Track) -> PlaylistTrackRow {
// owner says pulled tracks show up on MOST, which is why this row model
// is the first one plumbed.
not_streamable: !track.is_streamable(),
upcoming: track.is_upcoming(),
// Carried for §6's ISRC short-circuit; see the field's doc comment.
isrc: track.isrc.clone().unwrap_or_default(),
// F5: a pulled track we already downloaded is NOT dead. The same O(1)
+9
View File
@@ -223,6 +223,14 @@ pub struct TrackRow {
skip_serializing_if = "std::ops::Not::not"
)]
pub not_streamable: bool,
/// Refines `qobuzUnavailable`: a pre-release rather than a pulled track
/// (`qbz_models::Track::is_upcoming`).
#[serde(
default,
rename = "qobuzUpcoming",
skip_serializing_if = "std::ops::Not::not"
)]
pub upcoming: bool,
}
#[derive(Clone, Default, Serialize)]
@@ -417,6 +425,7 @@ fn map_track(track: &Track) -> TrackRow {
art_url: artwork_url,
// §5.1 via §3.1's single interpreter of absence.
not_streamable: !track.is_streamable(),
upcoming: track.is_upcoming(),
..Default::default()
}
}