PLAYER: Added generated playlists feature
Build and Publish / Build and Publish Docker Image (push) Successful in 3m5s
Build and Publish / Build and Publish Docker Image (push) Successful in 3m5s
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "furumusic"
|
name = "furumusic"
|
||||||
version = "0.2.9"
|
version = "0.2.10"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
description = "Reusable web-app boilerplate: auth, OIDC/SSO, admin panel, user management, i18n, PostgreSQL"
|
description = "Reusable web-app boilerplate: auth, OIDC/SSO, admin panel, user management, i18n, PostgreSQL"
|
||||||
|
|
||||||
|
|||||||
@@ -282,6 +282,32 @@ impl App for AdminApp {
|
|||||||
},
|
},
|
||||||
"admin_v2_jobs",
|
"admin_v2_jobs",
|
||||||
),
|
),
|
||||||
|
Route::with_handler_and_name(
|
||||||
|
"/v2/api/jobs/metadata_backfill/run-options",
|
||||||
|
cot::router::method::post({
|
||||||
|
let pool = Arc::clone(&pool);
|
||||||
|
let pool_config = Arc::clone(&pool_config);
|
||||||
|
move |session: Session,
|
||||||
|
db: Database,
|
||||||
|
json: Json<v2::MetadataBackfillRunRequest>| {
|
||||||
|
let pool = Arc::clone(&pool);
|
||||||
|
let pool_config = Arc::clone(&pool_config);
|
||||||
|
async move {
|
||||||
|
let pg_pool = pool
|
||||||
|
.get_or_init(|| async {
|
||||||
|
sqlx::postgres::PgPoolOptions::new()
|
||||||
|
.max_connections(5)
|
||||||
|
.connect(&pool_config.database_url)
|
||||||
|
.await
|
||||||
|
.expect("admin pool")
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
v2::run_metadata_backfill(session, db, pg_pool, json).await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
"admin_v2_metadata_backfill_run_options",
|
||||||
|
),
|
||||||
Route::with_handler_and_name(
|
Route::with_handler_and_name(
|
||||||
"/v2/api/jobs/{name}/run",
|
"/v2/api/jobs/{name}/run",
|
||||||
cot::router::method::post({
|
cot::router::method::post({
|
||||||
|
|||||||
+186
-1
@@ -17,7 +17,7 @@ use crate::agent;
|
|||||||
use crate::auth::{self, AuthenticatedUser, Role};
|
use crate::auth::{self, AuthenticatedUser, Role};
|
||||||
use crate::config::{AppConfig, ConfigEntry, ConfigSources};
|
use crate::config::{AppConfig, ConfigEntry, ConfigSources};
|
||||||
use crate::i18n::{I18n, Translations};
|
use crate::i18n::{I18n, Translations};
|
||||||
use crate::scheduler::{JobRegistry, ScheduledJob};
|
use crate::scheduler::{self, JobRegistry, JobRun, ScheduledJob};
|
||||||
|
|
||||||
#[derive(Debug, Template)]
|
#[derive(Debug, Template)]
|
||||||
#[template(path = "admin/v2.html")]
|
#[template(path = "admin/v2.html")]
|
||||||
@@ -61,6 +61,24 @@ pub(super) struct BulkLibraryRequest {
|
|||||||
filter: Option<LibraryFilter>,
|
filter: Option<LibraryFilter>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct MetadataBackfillRunRequest {
|
||||||
|
#[serde(default = "default_true")]
|
||||||
|
audio_bitrate: bool,
|
||||||
|
#[serde(default = "default_true")]
|
||||||
|
audio_sample_rate: bool,
|
||||||
|
#[serde(default = "default_true")]
|
||||||
|
audio_bit_depth: bool,
|
||||||
|
#[serde(default = "default_true")]
|
||||||
|
duration_seconds: bool,
|
||||||
|
#[serde(default = "default_true")]
|
||||||
|
local_genres: bool,
|
||||||
|
#[serde(default = "default_true")]
|
||||||
|
lastfm_tags: bool,
|
||||||
|
#[serde(default)]
|
||||||
|
overwrite: bool,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub(super) struct UpdateLibraryItemRequest {
|
pub(super) struct UpdateLibraryItemRequest {
|
||||||
kind: String,
|
kind: String,
|
||||||
@@ -161,6 +179,14 @@ struct TagDto {
|
|||||||
kind: String,
|
kind: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, JsonSchema)]
|
||||||
|
struct MetadataTagDto {
|
||||||
|
name: String,
|
||||||
|
source: String,
|
||||||
|
weight: f64,
|
||||||
|
updated_at: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, JsonSchema)]
|
#[derive(Debug, Serialize, JsonSchema)]
|
||||||
struct ReviewPageDto {
|
struct ReviewPageDto {
|
||||||
items: Vec<ReviewDto>,
|
items: Vec<ReviewDto>,
|
||||||
@@ -399,6 +425,7 @@ struct LibraryItemDetailDto {
|
|||||||
artists: Vec<ArtistOptionDto>,
|
artists: Vec<ArtistOptionDto>,
|
||||||
releases: Vec<ReleaseOptionDto>,
|
releases: Vec<ReleaseOptionDto>,
|
||||||
available_covers: Vec<AvailableCoverDto>,
|
available_covers: Vec<AvailableCoverDto>,
|
||||||
|
metadata_tags: Vec<MetadataTagDto>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, JsonSchema)]
|
#[derive(Debug, Serialize, JsonSchema)]
|
||||||
@@ -889,6 +916,68 @@ pub async fn run_job(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn run_metadata_backfill(
|
||||||
|
session: Session,
|
||||||
|
db: Database,
|
||||||
|
pool: &PgPool,
|
||||||
|
Json(body): Json<MetadataBackfillRunRequest>,
|
||||||
|
) -> cot::Result<cot::response::Response> {
|
||||||
|
if let Err(response) = require_admin_json(&session, &db).await {
|
||||||
|
return Ok(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
let options = crate::jobs::metadata_backfill::MetadataBackfillOptions {
|
||||||
|
audio_bitrate: body.audio_bitrate,
|
||||||
|
audio_sample_rate: body.audio_sample_rate,
|
||||||
|
audio_bit_depth: body.audio_bit_depth,
|
||||||
|
duration_seconds: body.duration_seconds,
|
||||||
|
local_genres: body.local_genres,
|
||||||
|
lastfm_tags: body.lastfm_tags,
|
||||||
|
overwrite: body.overwrite,
|
||||||
|
};
|
||||||
|
if !options.any_field() {
|
||||||
|
return Ok(json_error(
|
||||||
|
StatusCode::BAD_REQUEST,
|
||||||
|
"select at least one metadata field",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut run = JobRun::create_running(&db, "metadata_backfill", "manual")
|
||||||
|
.await
|
||||||
|
.map_err(|e| cot::Error::internal(format!("failed to create job run: {e}")))?;
|
||||||
|
let run_id = run.id_val();
|
||||||
|
let (live_config, _) = AppConfig::load_with_db(&db).await;
|
||||||
|
let db_for_task = db.clone();
|
||||||
|
let pool_for_task = pool.clone();
|
||||||
|
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let start = std::time::Instant::now();
|
||||||
|
let ctx = scheduler::JobContext {
|
||||||
|
config: std::sync::Arc::new(live_config),
|
||||||
|
db: db_for_task.clone(),
|
||||||
|
pool: pool_for_task.clone(),
|
||||||
|
run_id,
|
||||||
|
registry: std::sync::Arc::new(JobRegistry::new()),
|
||||||
|
};
|
||||||
|
let mut log = scheduler::JobLog::with_live_flush(pool_for_task.clone(), run_id);
|
||||||
|
let result =
|
||||||
|
crate::jobs::metadata_backfill::run_with_options(&ctx, &mut log, options).await;
|
||||||
|
let duration_ms = start.elapsed().as_millis() as i64;
|
||||||
|
match result {
|
||||||
|
Ok(()) => {
|
||||||
|
let _ = run.set_completed(&db_for_task, duration_ms, &log.output()).await;
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
let _ = run
|
||||||
|
.set_failed(&db_for_task, duration_ms, &log.output(), &err.to_string())
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Json(JobRunStartedDto { ok: true, run_id }).into_response()
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn toggle_job(
|
pub async fn toggle_job(
|
||||||
session: Session,
|
session: Session,
|
||||||
db: Database,
|
db: Database,
|
||||||
@@ -1974,6 +2063,7 @@ async fn load_library_item_detail(
|
|||||||
artists: Vec::new(),
|
artists: Vec::new(),
|
||||||
releases: Vec::new(),
|
releases: Vec::new(),
|
||||||
available_covers: Vec::new(),
|
available_covers: Vec::new(),
|
||||||
|
metadata_tags: load_metadata_tags(pool, kind, item.id).await?,
|
||||||
item,
|
item,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2044,6 +2134,97 @@ async fn load_library_item_detail(
|
|||||||
Ok(detail)
|
Ok(detail)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn load_metadata_tags(
|
||||||
|
pool: &PgPool,
|
||||||
|
kind: &str,
|
||||||
|
id: i64,
|
||||||
|
) -> anyhow::Result<Vec<MetadataTagDto>> {
|
||||||
|
let entity_kind = match kind {
|
||||||
|
"artists" => "artist",
|
||||||
|
"releases" => "release",
|
||||||
|
"tracks" => "track",
|
||||||
|
_ => return Ok(Vec::new()),
|
||||||
|
};
|
||||||
|
let rows = sqlx::query_as::<_, (String, String, f64, String)>(
|
||||||
|
r#"SELECT name, source, weight, updated_at
|
||||||
|
FROM (
|
||||||
|
SELECT g.name::text AS name,
|
||||||
|
egt.source::text AS source,
|
||||||
|
egt.weight,
|
||||||
|
egt.updated_at::text AS updated_at
|
||||||
|
FROM furumusic__entity_genre_tag egt
|
||||||
|
JOIN furumusic__genre g ON g.id = egt.genre_id
|
||||||
|
WHERE egt.entity_kind = $1 AND egt.entity_id = $2
|
||||||
|
UNION ALL
|
||||||
|
SELECT g.name::text AS name,
|
||||||
|
'track_genre'::text AS source,
|
||||||
|
1.0::double precision AS weight,
|
||||||
|
''::text AS updated_at
|
||||||
|
FROM furumusic__track_genre tg
|
||||||
|
JOIN furumusic__genre g ON g.id = tg.genre_id
|
||||||
|
WHERE $1 = 'track'
|
||||||
|
AND tg.track_id = $2
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM furumusic__entity_genre_tag egt
|
||||||
|
WHERE egt.entity_kind = 'track'
|
||||||
|
AND egt.entity_id = tg.track_id
|
||||||
|
AND egt.genre_id = tg.genre_id
|
||||||
|
)
|
||||||
|
UNION ALL
|
||||||
|
SELECT g.name::text AS name,
|
||||||
|
('release_' || egt.source)::text AS source,
|
||||||
|
egt.weight,
|
||||||
|
egt.updated_at::text AS updated_at
|
||||||
|
FROM furumusic__track t
|
||||||
|
JOIN furumusic__entity_genre_tag egt
|
||||||
|
ON egt.entity_kind = 'release'
|
||||||
|
AND egt.entity_id = t.release_id
|
||||||
|
JOIN furumusic__genre g ON g.id = egt.genre_id
|
||||||
|
WHERE $1 = 'track'
|
||||||
|
AND t.id = $2
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM furumusic__entity_genre_tag direct_egt
|
||||||
|
WHERE direct_egt.entity_kind = 'track'
|
||||||
|
AND direct_egt.entity_id = t.id
|
||||||
|
AND direct_egt.genre_id = egt.genre_id
|
||||||
|
)
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM furumusic__track_genre tg
|
||||||
|
WHERE tg.track_id = t.id
|
||||||
|
AND tg.genre_id = egt.genre_id
|
||||||
|
)
|
||||||
|
) tags
|
||||||
|
ORDER BY CASE source
|
||||||
|
WHEN 'lastfm' THEN 0
|
||||||
|
WHEN 'release_lastfm' THEN 1
|
||||||
|
WHEN 'review' THEN 2
|
||||||
|
WHEN 'release_review' THEN 3
|
||||||
|
WHEN 'file' THEN 4
|
||||||
|
WHEN 'release_file' THEN 5
|
||||||
|
WHEN 'track_genre' THEN 6
|
||||||
|
ELSE 7
|
||||||
|
END,
|
||||||
|
weight DESC,
|
||||||
|
name ASC"#,
|
||||||
|
)
|
||||||
|
.bind(entity_kind)
|
||||||
|
.bind(id)
|
||||||
|
.fetch_all(pool)
|
||||||
|
.await?;
|
||||||
|
Ok(rows
|
||||||
|
.into_iter()
|
||||||
|
.map(|(name, source, weight, updated_at)| MetadataTagDto {
|
||||||
|
name,
|
||||||
|
source,
|
||||||
|
weight,
|
||||||
|
updated_at,
|
||||||
|
})
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
|
|
||||||
async fn load_artist_options(pool: &PgPool) -> anyhow::Result<Vec<ArtistOptionDto>> {
|
async fn load_artist_options(pool: &PgPool) -> anyhow::Result<Vec<ArtistOptionDto>> {
|
||||||
let rows = sqlx::query_as::<_, (i64, String)>(
|
let rows = sqlx::query_as::<_, (i64, String)>(
|
||||||
"SELECT id, name::text FROM furumusic__artist ORDER BY name ASC",
|
"SELECT id, name::text FROM furumusic__artist ORDER BY name ASC",
|
||||||
@@ -2655,6 +2836,10 @@ fn tag(label: impl Into<String>, kind: impl Into<String>) -> TagDto {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_true() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
fn optional_job_time(value: &str) -> Option<String> {
|
fn optional_job_time(value: &str) -> Option<String> {
|
||||||
if value.is_empty() {
|
if value.is_empty() {
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -1402,6 +1402,8 @@ pub struct MetadataBackfillForm {
|
|||||||
audio_sample_rate: Option<String>,
|
audio_sample_rate: Option<String>,
|
||||||
audio_bit_depth: Option<String>,
|
audio_bit_depth: Option<String>,
|
||||||
duration_seconds: Option<String>,
|
duration_seconds: Option<String>,
|
||||||
|
local_genres: Option<String>,
|
||||||
|
lastfm_tags: Option<String>,
|
||||||
mode: Option<String>,
|
mode: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1468,6 +1470,8 @@ pub async fn metadata_backfill_run(
|
|||||||
audio_sample_rate: data.audio_sample_rate.is_some(),
|
audio_sample_rate: data.audio_sample_rate.is_some(),
|
||||||
audio_bit_depth: data.audio_bit_depth.is_some(),
|
audio_bit_depth: data.audio_bit_depth.is_some(),
|
||||||
duration_seconds: data.duration_seconds.is_some(),
|
duration_seconds: data.duration_seconds.is_some(),
|
||||||
|
local_genres: data.local_genres.is_some(),
|
||||||
|
lastfm_tags: data.lastfm_tags.is_some(),
|
||||||
overwrite: data.mode.as_deref() == Some("overwrite"),
|
overwrite: data.mode.as_deref() == Some("overwrite"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -346,6 +346,11 @@ translations! {
|
|||||||
player_lastfm_connect_failed: "Could not open Last.fm connection" , "Не удалось открыть подключение Last.fm";
|
player_lastfm_connect_failed: "Could not open Last.fm connection" , "Не удалось открыть подключение Last.fm";
|
||||||
player_lastfm_disconnect_failed: "Could not disconnect Last.fm" , "Не удалось отвязать Last.fm";
|
player_lastfm_disconnect_failed: "Could not disconnect Last.fm" , "Не удалось отвязать Last.fm";
|
||||||
player_play: "Play" , "Играть";
|
player_play: "Play" , "Играть";
|
||||||
|
player_listen: "Listen" , "Слушать";
|
||||||
|
player_listen_artist: "Listen to artist" , "Слушать артиста";
|
||||||
|
player_start_radio: "Start radio" , "Запустить радио";
|
||||||
|
player_radio_failed: "Could not start radio" , "Не удалось запустить радио";
|
||||||
|
player_played_at: "Played" , "Прослушано";
|
||||||
player_like: "Like" , "Лайк";
|
player_like: "Like" , "Лайк";
|
||||||
player_add_to_queue: "Add to queue" , "Добавить в очередь";
|
player_add_to_queue: "Add to queue" , "Добавить в очередь";
|
||||||
player_add_to_end_queue: "Add to end of queue" , "Добавить в конец очереди";
|
player_add_to_end_queue: "Add to end of queue" , "Добавить в конец очереди";
|
||||||
|
|||||||
@@ -878,6 +878,26 @@ pub async fn finalize_approved(
|
|||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let approved_genre = normalized
|
||||||
|
.genre
|
||||||
|
.as_deref()
|
||||||
|
.or_else(|| context.get("raw_genre").and_then(|v| v.as_str()))
|
||||||
|
.map(str::trim)
|
||||||
|
.filter(|value| !value.is_empty());
|
||||||
|
if let Some(genre) = approved_genre {
|
||||||
|
if let Err(err) =
|
||||||
|
crate::jobs::metadata_backfill::save_approved_track_genres(pool, track.id_val(), genre)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
tracing::warn!(
|
||||||
|
track_id = track.id_val(),
|
||||||
|
genre,
|
||||||
|
error = %err,
|
||||||
|
"failed to save approved track genre metadata"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Cover art: if the release has no cover yet, try to find one
|
// Cover art: if the release has no cover yet, try to find one
|
||||||
if release.cover_file_id.is_none() {
|
if release.cover_file_id.is_none() {
|
||||||
let source_folder = Path::new(input_path_str).parent().unwrap_or(Path::new("."));
|
let source_folder = Path::new(input_path_str).parent().unwrap_or(Path::new("."));
|
||||||
|
|||||||
+836
-112
File diff suppressed because it is too large
Load Diff
@@ -1815,6 +1815,56 @@ pub mod db_migrations {
|
|||||||
&[Operation::custom(create_artwork_lookup_state).build()];
|
&[Operation::custom(create_artwork_lookup_state).build()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- M0035: Weighted metadata tags for tracks, releases, and artists ----
|
||||||
|
|
||||||
|
#[cot::db::migrations::migration_op]
|
||||||
|
async fn create_entity_genre_tags(
|
||||||
|
ctx: migrations::MigrationContext<'_>,
|
||||||
|
) -> cot::db::Result<()> {
|
||||||
|
ctx.db
|
||||||
|
.raw(
|
||||||
|
"CREATE TABLE IF NOT EXISTS furumusic__entity_genre_tag (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
entity_kind VARCHAR(32) NOT NULL,
|
||||||
|
entity_id BIGINT NOT NULL,
|
||||||
|
genre_id BIGINT NOT NULL,
|
||||||
|
source VARCHAR(32) NOT NULL,
|
||||||
|
weight DOUBLE PRECISION NOT NULL DEFAULT 1,
|
||||||
|
updated_at VARCHAR(32) NOT NULL,
|
||||||
|
UNIQUE(entity_kind, entity_id, genre_id, source)
|
||||||
|
)",
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
ctx.db
|
||||||
|
.raw(
|
||||||
|
"CREATE INDEX IF NOT EXISTS idx_entity_genre_tag_entity
|
||||||
|
ON furumusic__entity_genre_tag (entity_kind, entity_id, source)",
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
ctx.db
|
||||||
|
.raw(
|
||||||
|
"CREATE INDEX IF NOT EXISTS idx_entity_genre_tag_genre
|
||||||
|
ON furumusic__entity_genre_tag (genre_id, entity_kind)",
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
pub struct M0035CreateEntityGenreTags;
|
||||||
|
|
||||||
|
impl migrations::Migration for M0035CreateEntityGenreTags {
|
||||||
|
const APP_NAME: &'static str = "furumusic";
|
||||||
|
const MIGRATION_NAME: &'static str = "m_0035_create_entity_genre_tags";
|
||||||
|
const DEPENDENCIES: &'static [migrations::MigrationDependency] =
|
||||||
|
&[migrations::MigrationDependency::migration(
|
||||||
|
"furumusic",
|
||||||
|
"m_0034_create_artwork_lookup_state",
|
||||||
|
)];
|
||||||
|
const OPERATIONS: &'static [Operation] =
|
||||||
|
&[Operation::custom(create_entity_genre_tags).build()];
|
||||||
|
}
|
||||||
|
|
||||||
pub const MIGRATIONS: &[&SyncDynMigration] = &[
|
pub const MIGRATIONS: &[&SyncDynMigration] = &[
|
||||||
&M0006CreateMediaFile,
|
&M0006CreateMediaFile,
|
||||||
&M0007CreateArtist,
|
&M0007CreateArtist,
|
||||||
@@ -1840,5 +1890,6 @@ pub mod db_migrations {
|
|||||||
&M0032CreateLastfmTrackPopularity,
|
&M0032CreateLastfmTrackPopularity,
|
||||||
&M0033CreateLastfmScrobbling,
|
&M0033CreateLastfmScrobbling,
|
||||||
&M0034CreateArtworkLookupState,
|
&M0034CreateArtworkLookupState,
|
||||||
|
&M0035CreateEntityGenreTags,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ pub(super) struct ArtistDetail {
|
|||||||
pub(super) image_url: Option<String>,
|
pub(super) image_url: Option<String>,
|
||||||
pub(super) total_track_count: i64,
|
pub(super) total_track_count: i64,
|
||||||
pub(super) total_play_count: i64,
|
pub(super) total_play_count: i64,
|
||||||
|
pub(super) top_tracks: Vec<TrackItem>,
|
||||||
pub(super) releases: Vec<ReleaseCard>,
|
pub(super) releases: Vec<ReleaseCard>,
|
||||||
pub(super) featured_tracks: Vec<ArtistAppearanceTrack>,
|
pub(super) featured_tracks: Vec<ArtistAppearanceTrack>,
|
||||||
}
|
}
|
||||||
@@ -463,6 +464,7 @@ pub(super) struct PlayHistoryItem {
|
|||||||
pub(super) track_id: i64,
|
pub(super) track_id: i64,
|
||||||
pub(super) track_title: String,
|
pub(super) track_title: String,
|
||||||
pub(super) release_title: Option<String>,
|
pub(super) release_title: Option<String>,
|
||||||
|
pub(super) track: TrackItem,
|
||||||
pub(super) played_at: String,
|
pub(super) played_at: String,
|
||||||
pub(super) duration_listened: Option<i32>,
|
pub(super) duration_listened: Option<i32>,
|
||||||
pub(super) completed: bool,
|
pub(super) completed: bool,
|
||||||
|
|||||||
+683
-199
@@ -56,6 +56,9 @@ const PLAYER_DEVICE_COMMAND_TTL_MS: i64 = 20_000;
|
|||||||
const PLAYER_DEVICE_MAX_COMMANDS: usize = 32;
|
const PLAYER_DEVICE_MAX_COMMANDS: usize = 32;
|
||||||
const PLAYER_JAM_IDLE_TTL_MS: i64 = 4 * 60 * 60 * 1000;
|
const PLAYER_JAM_IDLE_TTL_MS: i64 = 4 * 60 * 60 * 1000;
|
||||||
const PLAYER_JAM_MAX_INVITEES: usize = 25;
|
const PLAYER_JAM_MAX_INVITEES: usize = 25;
|
||||||
|
const PLAYER_RADIO_TRACK_LIMIT: usize = 40;
|
||||||
|
const PLAYER_RADIO_CANDIDATE_LIMIT: i64 = 220;
|
||||||
|
const PLAYER_RADIO_RELEASE_SEED_TRACKS: i64 = 4;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct PlayerDevice {
|
struct PlayerDevice {
|
||||||
@@ -3023,12 +3026,56 @@ async fn artist_detail_handler(
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
let top_tracks = sqlx::query_as::<_, PlaylistTrackRow>(
|
||||||
|
r#"SELECT t.id, t.title::text as title, t.track_number, t.disc_number,
|
||||||
|
t.duration_seconds, t.cover_file_id,
|
||||||
|
r.cover_file_id as release_cover_file_id,
|
||||||
|
r.id as release_id,
|
||||||
|
r.title::text as release_title,
|
||||||
|
r.year as release_year,
|
||||||
|
COALESCE(mf.uploader_name, 'UFO')::text AS uploader_name,
|
||||||
|
mf.audio_format,
|
||||||
|
mf.audio_bitrate,
|
||||||
|
mf.audio_sample_rate,
|
||||||
|
mf.audio_bit_depth,
|
||||||
|
mf.file_size_bytes,
|
||||||
|
t.lastfm_listeners,
|
||||||
|
t.lastfm_playcount,
|
||||||
|
t.lastfm_rating,
|
||||||
|
t.lastfm_updated_at
|
||||||
|
FROM furumusic__track t
|
||||||
|
JOIN furumusic__release r ON r.id = t.release_id
|
||||||
|
LEFT JOIN furumusic__media_file mf ON mf.id = t.audio_file_id
|
||||||
|
WHERE t.is_hidden = false
|
||||||
|
AND r.is_hidden = false
|
||||||
|
AND EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM furumusic__track_artist ta
|
||||||
|
WHERE ta.track_id = t.id
|
||||||
|
AND ta.artist_id = $1
|
||||||
|
AND ta.role <> 'featuring'
|
||||||
|
)
|
||||||
|
ORDER BY COALESCE(t.lastfm_rating, 0) DESC,
|
||||||
|
COALESCE(t.lastfm_playcount, 0) DESC,
|
||||||
|
COALESCE(t.lastfm_listeners, 0) DESC,
|
||||||
|
r.year DESC NULLS LAST,
|
||||||
|
t.track_number NULLS LAST,
|
||||||
|
t.id
|
||||||
|
LIMIT 50"#,
|
||||||
|
)
|
||||||
|
.bind(artist_id)
|
||||||
|
.fetch_all(pool)
|
||||||
|
.await
|
||||||
|
.map_err(|e| cot::Error::internal(e.to_string()))?;
|
||||||
|
let top_tracks = build_track_items(top_tracks, pool).await?;
|
||||||
|
|
||||||
Json(ArtistDetail {
|
Json(ArtistDetail {
|
||||||
id: artist.id,
|
id: artist.id,
|
||||||
name: artist.name,
|
name: artist.name,
|
||||||
image_url: cover_variant_url(image_file_id, "large"),
|
image_url: cover_variant_url(image_file_id, "large"),
|
||||||
total_track_count,
|
total_track_count,
|
||||||
total_play_count,
|
total_play_count,
|
||||||
|
top_tracks,
|
||||||
releases: release_cards,
|
releases: release_cards,
|
||||||
featured_tracks,
|
featured_tracks,
|
||||||
})
|
})
|
||||||
@@ -3077,8 +3124,7 @@ async fn release_detail_handler(
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| cot::Error::internal(e.to_string()))?;
|
.map_err(|e| cot::Error::internal(e.to_string()))?;
|
||||||
|
|
||||||
// Tracks
|
let tracks = sqlx::query_as::<_, PlaylistTrackRow>(
|
||||||
let tracks = sqlx::query_as::<_, TrackRow>(
|
|
||||||
r#"SELECT t.id, t.title::text as title, t.track_number, t.disc_number,
|
r#"SELECT t.id, t.title::text as title, t.track_number, t.disc_number,
|
||||||
t.duration_seconds, t.cover_file_id,
|
t.duration_seconds, t.cover_file_id,
|
||||||
r.cover_file_id as release_cover_file_id,
|
r.cover_file_id as release_cover_file_id,
|
||||||
@@ -3106,83 +3152,7 @@ async fn release_detail_handler(
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| cot::Error::internal(e.to_string()))?;
|
.map_err(|e| cot::Error::internal(e.to_string()))?;
|
||||||
|
|
||||||
let track_ids: Vec<i64> = tracks.iter().map(|t| t.id).collect();
|
let track_items = build_track_items(tracks, pool).await?;
|
||||||
|
|
||||||
// Track artists (batch)
|
|
||||||
let track_artists = if track_ids.is_empty() {
|
|
||||||
Vec::new()
|
|
||||||
} else {
|
|
||||||
sqlx::query_as::<_, TrackArtistRow>(
|
|
||||||
r#"SELECT ta.track_id, ta.artist_id, a.name::text as artist_name, ta.role::text as role
|
|
||||||
FROM furumusic__track_artist ta
|
|
||||||
JOIN furumusic__artist a ON a.id = ta.artist_id
|
|
||||||
WHERE ta.track_id = ANY($1)
|
|
||||||
ORDER BY ta.track_id, ta.position"#,
|
|
||||||
)
|
|
||||||
.bind(&track_ids)
|
|
||||||
.fetch_all(pool)
|
|
||||||
.await
|
|
||||||
.map_err(|e| cot::Error::internal(e.to_string()))?
|
|
||||||
};
|
|
||||||
|
|
||||||
// Group track artists
|
|
||||||
let mut track_main_artists: std::collections::HashMap<i64, Vec<ArtistRef>> =
|
|
||||||
std::collections::HashMap::new();
|
|
||||||
let mut track_feat_artists: std::collections::HashMap<i64, Vec<ArtistRef>> =
|
|
||||||
std::collections::HashMap::new();
|
|
||||||
|
|
||||||
for ta in &track_artists {
|
|
||||||
let artist_ref = ArtistRef {
|
|
||||||
id: ta.artist_id,
|
|
||||||
name: ta.artist_name.clone(),
|
|
||||||
};
|
|
||||||
if ta.role == "featuring" {
|
|
||||||
track_feat_artists
|
|
||||||
.entry(ta.track_id)
|
|
||||||
.or_default()
|
|
||||||
.push(artist_ref);
|
|
||||||
} else {
|
|
||||||
track_main_artists
|
|
||||||
.entry(ta.track_id)
|
|
||||||
.or_default()
|
|
||||||
.push(artist_ref);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let track_items: Vec<TrackItem> = tracks
|
|
||||||
.into_iter()
|
|
||||||
.map(|t| {
|
|
||||||
let tid = t.id;
|
|
||||||
TrackItem {
|
|
||||||
id: t.id,
|
|
||||||
title: t.title,
|
|
||||||
track_number: t.track_number,
|
|
||||||
disc_number: t.disc_number,
|
|
||||||
duration_seconds: t.duration_seconds,
|
|
||||||
artists: track_main_artists.remove(&tid).unwrap_or_default(),
|
|
||||||
featured_artists: track_feat_artists.remove(&tid).unwrap_or_default(),
|
|
||||||
release_id: t.release_id,
|
|
||||||
release_title: t.release_title,
|
|
||||||
release_year: t.release_year,
|
|
||||||
cover_url: track_cover_variant_url(
|
|
||||||
t.cover_file_id,
|
|
||||||
t.release_cover_file_id,
|
|
||||||
"medium",
|
|
||||||
),
|
|
||||||
stream_url: format!("/api/player/stream/{tid}"),
|
|
||||||
uploader_name: t.uploader_name,
|
|
||||||
audio_format: t.audio_format,
|
|
||||||
audio_bitrate: t.audio_bitrate,
|
|
||||||
audio_sample_rate: t.audio_sample_rate,
|
|
||||||
audio_bit_depth: t.audio_bit_depth,
|
|
||||||
file_size_bytes: t.file_size_bytes,
|
|
||||||
lastfm_listeners: t.lastfm_listeners,
|
|
||||||
lastfm_playcount: t.lastfm_playcount,
|
|
||||||
lastfm_rating: t.lastfm_rating,
|
|
||||||
lastfm_updated_at: t.lastfm_updated_at,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
let uploaders = load_release_uploaders(pool, &[release.id])
|
let uploaders = load_release_uploaders(pool, &[release.id])
|
||||||
.await
|
.await
|
||||||
.map_err(|e| cot::Error::internal(e.to_string()))?
|
.map_err(|e| cot::Error::internal(e.to_string()))?
|
||||||
@@ -3451,6 +3421,50 @@ async fn build_track_items(
|
|||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn load_track_items_by_ids(
|
||||||
|
pool: &sqlx::PgPool,
|
||||||
|
ids: &[i64],
|
||||||
|
) -> cot::Result<Vec<TrackItem>> {
|
||||||
|
if ids.is_empty() {
|
||||||
|
return Ok(Vec::new());
|
||||||
|
}
|
||||||
|
|
||||||
|
let tracks = sqlx::query_as::<_, PlaylistTrackRow>(
|
||||||
|
r#"SELECT t.id, t.title::text as title, t.track_number, t.disc_number,
|
||||||
|
t.duration_seconds, t.cover_file_id,
|
||||||
|
r.cover_file_id as release_cover_file_id,
|
||||||
|
r.id as release_id,
|
||||||
|
r.title::text as release_title,
|
||||||
|
r.year as release_year,
|
||||||
|
COALESCE(mf.uploader_name, 'UFO')::text AS uploader_name,
|
||||||
|
mf.audio_format,
|
||||||
|
mf.audio_bitrate,
|
||||||
|
mf.audio_sample_rate,
|
||||||
|
mf.audio_bit_depth,
|
||||||
|
mf.file_size_bytes,
|
||||||
|
t.lastfm_listeners,
|
||||||
|
t.lastfm_playcount,
|
||||||
|
t.lastfm_rating,
|
||||||
|
t.lastfm_updated_at
|
||||||
|
FROM furumusic__track t
|
||||||
|
JOIN furumusic__release r ON r.id = t.release_id
|
||||||
|
LEFT JOIN furumusic__media_file mf ON mf.id = t.audio_file_id
|
||||||
|
WHERE t.id = ANY($1) AND t.is_hidden = false AND r.is_hidden = false"#,
|
||||||
|
)
|
||||||
|
.bind(ids)
|
||||||
|
.fetch_all(pool)
|
||||||
|
.await
|
||||||
|
.map_err(|e| cot::Error::internal(e.to_string()))?;
|
||||||
|
|
||||||
|
let mut track_map: HashMap<i64, TrackItem> = build_track_items(tracks, pool)
|
||||||
|
.await?
|
||||||
|
.into_iter()
|
||||||
|
.map(|track| (track.id, track))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
Ok(ids.iter().filter_map(|id| track_map.remove(id)).collect())
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the virtual "Likes" playlist for a given user.
|
/// Return the virtual "Likes" playlist for a given user.
|
||||||
async fn likes_playlist_handler(
|
async fn likes_playlist_handler(
|
||||||
user_id: i64,
|
user_id: i64,
|
||||||
@@ -4321,17 +4335,35 @@ async fn history_list_handler(
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| cot::Error::internal(e.to_string()))?;
|
.map_err(|e| cot::Error::internal(e.to_string()))?;
|
||||||
|
|
||||||
let rows = sqlx::query_as::<_, PlayHistoryRow>(
|
let rows = sqlx::query_as::<_, PlayHistoryTrackRow>(
|
||||||
r#"SELECT ph.id,
|
r#"SELECT ph.id AS history_id,
|
||||||
ph.track_id,
|
|
||||||
t.title::text AS track_title,
|
|
||||||
r.title::text AS release_title,
|
|
||||||
ph.played_at::text AS played_at,
|
ph.played_at::text AS played_at,
|
||||||
ph.duration_listened,
|
ph.duration_listened,
|
||||||
ph.completed
|
ph.completed,
|
||||||
|
t.id,
|
||||||
|
t.title::text as title,
|
||||||
|
t.track_number,
|
||||||
|
t.disc_number,
|
||||||
|
t.duration_seconds,
|
||||||
|
t.cover_file_id,
|
||||||
|
r.cover_file_id as release_cover_file_id,
|
||||||
|
t.release_id,
|
||||||
|
COALESCE(r.title::text, '') as release_title,
|
||||||
|
r.year as release_year,
|
||||||
|
COALESCE(mf.uploader_name, 'UFO')::text AS uploader_name,
|
||||||
|
mf.audio_format,
|
||||||
|
mf.audio_bitrate,
|
||||||
|
mf.audio_sample_rate,
|
||||||
|
mf.audio_bit_depth,
|
||||||
|
mf.file_size_bytes,
|
||||||
|
t.lastfm_listeners,
|
||||||
|
t.lastfm_playcount,
|
||||||
|
t.lastfm_rating,
|
||||||
|
t.lastfm_updated_at
|
||||||
FROM furumusic__play_history ph
|
FROM furumusic__play_history ph
|
||||||
JOIN furumusic__track t ON t.id = ph.track_id
|
JOIN furumusic__track t ON t.id = ph.track_id
|
||||||
LEFT JOIN furumusic__release r ON r.id = t.release_id
|
LEFT JOIN furumusic__release r ON r.id = t.release_id
|
||||||
|
LEFT JOIN furumusic__media_file mf ON mf.id = t.audio_file_id
|
||||||
WHERE ph.user_id = $1
|
WHERE ph.user_id = $1
|
||||||
ORDER BY ph.played_at DESC, ph.id DESC
|
ORDER BY ph.played_at DESC, ph.id DESC
|
||||||
LIMIT $2 OFFSET $3"#,
|
LIMIT $2 OFFSET $3"#,
|
||||||
@@ -4343,14 +4375,86 @@ async fn history_list_handler(
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| cot::Error::internal(e.to_string()))?;
|
.map_err(|e| cot::Error::internal(e.to_string()))?;
|
||||||
|
|
||||||
|
let track_ids: Vec<i64> = rows.iter().map(|t| t.id).collect();
|
||||||
|
let track_artists = if track_ids.is_empty() {
|
||||||
|
Vec::new()
|
||||||
|
} else {
|
||||||
|
sqlx::query_as::<_, TrackArtistRow>(
|
||||||
|
r#"SELECT ta.track_id, ta.artist_id, a.name::text as artist_name, ta.role::text as role
|
||||||
|
FROM furumusic__track_artist ta
|
||||||
|
JOIN furumusic__artist a ON a.id = ta.artist_id
|
||||||
|
WHERE ta.track_id = ANY($1)
|
||||||
|
ORDER BY ta.track_id, ta.position"#,
|
||||||
|
)
|
||||||
|
.bind(&track_ids)
|
||||||
|
.fetch_all(pool)
|
||||||
|
.await
|
||||||
|
.map_err(|e| cot::Error::internal(e.to_string()))?
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut track_main_artists: HashMap<i64, Vec<ArtistRef>> = HashMap::new();
|
||||||
|
let mut track_feat_artists: HashMap<i64, Vec<ArtistRef>> = HashMap::new();
|
||||||
|
for ta in &track_artists {
|
||||||
|
let artist_ref = ArtistRef {
|
||||||
|
id: ta.artist_id,
|
||||||
|
name: ta.artist_name.clone(),
|
||||||
|
};
|
||||||
|
if ta.role == "featuring" {
|
||||||
|
track_feat_artists
|
||||||
|
.entry(ta.track_id)
|
||||||
|
.or_default()
|
||||||
|
.push(artist_ref);
|
||||||
|
} else {
|
||||||
|
track_main_artists
|
||||||
|
.entry(ta.track_id)
|
||||||
|
.or_default()
|
||||||
|
.push(artist_ref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Json(PlayHistoryPage {
|
Json(PlayHistoryPage {
|
||||||
items: rows
|
items: rows
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|row| PlayHistoryItem {
|
.map(|row| PlayHistoryItem {
|
||||||
id: row.id,
|
id: row.history_id,
|
||||||
track_id: row.track_id,
|
track_id: row.id,
|
||||||
track_title: row.track_title,
|
track_title: row.title.clone(),
|
||||||
release_title: row.release_title,
|
release_title: if row.release_title.trim().is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(row.release_title.clone())
|
||||||
|
},
|
||||||
|
track: {
|
||||||
|
let tid = row.id;
|
||||||
|
TrackItem {
|
||||||
|
id: row.id,
|
||||||
|
title: row.title,
|
||||||
|
track_number: row.track_number,
|
||||||
|
disc_number: row.disc_number,
|
||||||
|
duration_seconds: row.duration_seconds,
|
||||||
|
artists: track_main_artists.remove(&tid).unwrap_or_default(),
|
||||||
|
featured_artists: track_feat_artists.remove(&tid).unwrap_or_default(),
|
||||||
|
release_id: row.release_id,
|
||||||
|
release_title: row.release_title,
|
||||||
|
release_year: row.release_year,
|
||||||
|
cover_url: track_cover_variant_url(
|
||||||
|
row.cover_file_id,
|
||||||
|
row.release_cover_file_id,
|
||||||
|
"medium",
|
||||||
|
),
|
||||||
|
stream_url: format!("/api/player/stream/{tid}"),
|
||||||
|
uploader_name: row.uploader_name,
|
||||||
|
audio_format: row.audio_format,
|
||||||
|
audio_bitrate: row.audio_bitrate,
|
||||||
|
audio_sample_rate: row.audio_sample_rate,
|
||||||
|
audio_bit_depth: row.audio_bit_depth,
|
||||||
|
file_size_bytes: row.file_size_bytes,
|
||||||
|
lastfm_listeners: row.lastfm_listeners,
|
||||||
|
lastfm_playcount: row.lastfm_playcount,
|
||||||
|
lastfm_rating: row.lastfm_rating,
|
||||||
|
lastfm_updated_at: row.lastfm_updated_at,
|
||||||
|
}
|
||||||
|
},
|
||||||
played_at: row.played_at,
|
played_at: row.played_at,
|
||||||
duration_listened: row.duration_listened,
|
duration_listened: row.duration_listened,
|
||||||
completed: row.completed,
|
completed: row.completed,
|
||||||
@@ -5248,6 +5352,471 @@ async fn toggle_follow_artist_handler(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// GET /api/player/radio/{kind}/{id}
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
fn append_unique_track_ids(track_ids: &mut Vec<i64>, candidates: Vec<i64>, limit: usize) {
|
||||||
|
let mut seen: HashSet<i64> = track_ids.iter().copied().collect();
|
||||||
|
for candidate in candidates {
|
||||||
|
if track_ids.len() >= limit {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if seen.insert(candidate) {
|
||||||
|
track_ids.push(candidate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn track_primary_artist_ids(pool: &sqlx::PgPool, track_id: i64) -> cot::Result<Vec<i64>> {
|
||||||
|
sqlx::query_scalar::<_, i64>(
|
||||||
|
r#"SELECT artist_id
|
||||||
|
FROM furumusic__track_artist
|
||||||
|
WHERE track_id = $1 AND role <> 'featuring'
|
||||||
|
ORDER BY position, artist_id"#,
|
||||||
|
)
|
||||||
|
.bind(track_id)
|
||||||
|
.fetch_all(pool)
|
||||||
|
.await
|
||||||
|
.map_err(|e| cot::Error::internal(e.to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn release_primary_artist_ids(pool: &sqlx::PgPool, release_id: i64) -> cot::Result<Vec<i64>> {
|
||||||
|
sqlx::query_scalar::<_, i64>(
|
||||||
|
r#"SELECT artist_id
|
||||||
|
FROM furumusic__release_artist
|
||||||
|
WHERE release_id = $1
|
||||||
|
ORDER BY position, artist_id"#,
|
||||||
|
)
|
||||||
|
.bind(release_id)
|
||||||
|
.fetch_all(pool)
|
||||||
|
.await
|
||||||
|
.map_err(|e| cot::Error::internal(e.to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn fallback_radio_track_ids(
|
||||||
|
pool: &sqlx::PgPool,
|
||||||
|
user_id: i64,
|
||||||
|
artist_ids: &[i64],
|
||||||
|
excluded_ids: &[i64],
|
||||||
|
limit: i64,
|
||||||
|
) -> cot::Result<Vec<i64>> {
|
||||||
|
if limit <= 0 {
|
||||||
|
return Ok(Vec::new());
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlx::query_scalar::<_, i64>(
|
||||||
|
r#"SELECT t.id
|
||||||
|
FROM furumusic__track t
|
||||||
|
JOIN furumusic__release r ON r.id = t.release_id
|
||||||
|
WHERE t.is_hidden = false
|
||||||
|
AND r.is_hidden = false
|
||||||
|
AND NOT (t.id = ANY($3::bigint[]))
|
||||||
|
ORDER BY (
|
||||||
|
CASE WHEN EXISTS (
|
||||||
|
SELECT 1 FROM furumusic__user_liked_track ult
|
||||||
|
WHERE ult.user_id = $1 AND ult.track_id = t.id
|
||||||
|
) THEN 9.0 ELSE 0.0 END
|
||||||
|
+ CASE WHEN EXISTS (
|
||||||
|
SELECT 1 FROM furumusic__track_artist ta
|
||||||
|
WHERE ta.track_id = t.id
|
||||||
|
AND ta.role <> 'featuring'
|
||||||
|
AND ta.artist_id = ANY($2::bigint[])
|
||||||
|
) THEN 5.0 ELSE 0.0 END
|
||||||
|
+ COALESCE(t.lastfm_rating, 0.0) * 0.7
|
||||||
|
+ ln(COALESCE(t.lastfm_playcount, 0)::double precision + 1.0) * 0.04
|
||||||
|
+ ln(COALESCE(t.lastfm_listeners, 0)::double precision + 1.0) * 0.03
|
||||||
|
+ random() * 2.0
|
||||||
|
) DESC, t.id
|
||||||
|
LIMIT $4"#,
|
||||||
|
)
|
||||||
|
.bind(user_id)
|
||||||
|
.bind(artist_ids)
|
||||||
|
.bind(excluded_ids)
|
||||||
|
.bind(limit)
|
||||||
|
.fetch_all(pool)
|
||||||
|
.await
|
||||||
|
.map_err(|e| cot::Error::internal(e.to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn track_radio_candidate_ids(
|
||||||
|
pool: &sqlx::PgPool,
|
||||||
|
user_id: i64,
|
||||||
|
track_id: i64,
|
||||||
|
limit: i64,
|
||||||
|
) -> cot::Result<Vec<i64>> {
|
||||||
|
sqlx::query_scalar::<_, i64>(
|
||||||
|
r#"WITH seed_track AS (
|
||||||
|
SELECT t.id, t.release_id
|
||||||
|
FROM furumusic__track t
|
||||||
|
JOIN furumusic__release r ON r.id = t.release_id
|
||||||
|
WHERE t.id = $1 AND t.is_hidden = false AND r.is_hidden = false
|
||||||
|
),
|
||||||
|
seed_artists AS (
|
||||||
|
SELECT ta.artist_id
|
||||||
|
FROM furumusic__track_artist ta
|
||||||
|
JOIN seed_track st ON st.id = ta.track_id
|
||||||
|
WHERE ta.role <> 'featuring'
|
||||||
|
),
|
||||||
|
seed_tag_sources AS (
|
||||||
|
SELECT egt.genre_id,
|
||||||
|
ln(greatest(COALESCE(egt.weight, 1.0), 1.0) + 1.0) AS weight
|
||||||
|
FROM furumusic__entity_genre_tag egt
|
||||||
|
JOIN seed_track st ON egt.entity_kind = 'track' AND egt.entity_id = st.id
|
||||||
|
UNION ALL
|
||||||
|
SELECT tg.genre_id, 1.0 AS weight
|
||||||
|
FROM furumusic__track_genre tg
|
||||||
|
JOIN seed_track st ON st.id = tg.track_id
|
||||||
|
UNION ALL
|
||||||
|
SELECT egt.genre_id,
|
||||||
|
ln(greatest(COALESCE(egt.weight, 1.0), 1.0) + 1.0) AS weight
|
||||||
|
FROM furumusic__entity_genre_tag egt
|
||||||
|
JOIN seed_track st ON egt.entity_kind = 'release' AND egt.entity_id = st.release_id
|
||||||
|
),
|
||||||
|
seed_tags AS (
|
||||||
|
SELECT genre_id, max(weight) AS seed_weight
|
||||||
|
FROM seed_tag_sources
|
||||||
|
GROUP BY genre_id
|
||||||
|
),
|
||||||
|
candidate_tag_sources AS (
|
||||||
|
SELECT egt.entity_id AS track_id,
|
||||||
|
egt.genre_id,
|
||||||
|
ln(greatest(COALESCE(egt.weight, 1.0), 1.0) + 1.0) AS weight
|
||||||
|
FROM furumusic__entity_genre_tag egt
|
||||||
|
WHERE egt.entity_kind = 'track'
|
||||||
|
UNION ALL
|
||||||
|
SELECT tg.track_id, tg.genre_id, 1.0 AS weight
|
||||||
|
FROM furumusic__track_genre tg
|
||||||
|
UNION ALL
|
||||||
|
SELECT t.id AS track_id,
|
||||||
|
egt.genre_id,
|
||||||
|
ln(greatest(COALESCE(egt.weight, 1.0), 1.0) + 1.0) AS weight
|
||||||
|
FROM furumusic__track t
|
||||||
|
JOIN furumusic__entity_genre_tag egt
|
||||||
|
ON egt.entity_kind = 'release' AND egt.entity_id = t.release_id
|
||||||
|
),
|
||||||
|
candidate_tags AS (
|
||||||
|
SELECT track_id, genre_id, max(weight) AS weight
|
||||||
|
FROM candidate_tag_sources
|
||||||
|
GROUP BY track_id, genre_id
|
||||||
|
),
|
||||||
|
tag_scores AS (
|
||||||
|
SELECT ct.track_id, sum(st.seed_weight * ct.weight) AS tag_score
|
||||||
|
FROM candidate_tags ct
|
||||||
|
JOIN seed_tags st ON st.genre_id = ct.genre_id
|
||||||
|
GROUP BY ct.track_id
|
||||||
|
)
|
||||||
|
SELECT t.id
|
||||||
|
FROM furumusic__track t
|
||||||
|
JOIN furumusic__release r ON r.id = t.release_id
|
||||||
|
LEFT JOIN tag_scores score ON score.track_id = t.id
|
||||||
|
WHERE t.is_hidden = false
|
||||||
|
AND r.is_hidden = false
|
||||||
|
AND t.id <> $1
|
||||||
|
AND (
|
||||||
|
COALESCE(score.tag_score, 0.0) > 0.0
|
||||||
|
OR EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM furumusic__track_artist ta
|
||||||
|
JOIN seed_artists sa ON sa.artist_id = ta.artist_id
|
||||||
|
WHERE ta.track_id = t.id AND ta.role <> 'featuring'
|
||||||
|
)
|
||||||
|
OR EXISTS (
|
||||||
|
SELECT 1 FROM furumusic__user_liked_track ult
|
||||||
|
WHERE ult.user_id = $2 AND ult.track_id = t.id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
ORDER BY (
|
||||||
|
COALESCE(score.tag_score, 0.0) * 12.0
|
||||||
|
+ CASE
|
||||||
|
WHEN EXISTS (
|
||||||
|
SELECT 1 FROM furumusic__user_liked_track ult
|
||||||
|
WHERE ult.user_id = $2 AND ult.track_id = t.id
|
||||||
|
) AND COALESCE(score.tag_score, 0.0) > 0.0 THEN 12.0
|
||||||
|
WHEN EXISTS (
|
||||||
|
SELECT 1 FROM furumusic__user_liked_track ult
|
||||||
|
WHERE ult.user_id = $2 AND ult.track_id = t.id
|
||||||
|
) THEN 3.0
|
||||||
|
ELSE 0.0
|
||||||
|
END
|
||||||
|
+ CASE WHEN EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM furumusic__track_artist ta
|
||||||
|
JOIN seed_artists sa ON sa.artist_id = ta.artist_id
|
||||||
|
WHERE ta.track_id = t.id AND ta.role <> 'featuring'
|
||||||
|
) THEN 4.0 ELSE 0.0 END
|
||||||
|
+ COALESCE(t.lastfm_rating, 0.0) * 0.65
|
||||||
|
+ ln(COALESCE(t.lastfm_playcount, 0)::double precision + 1.0) * 0.04
|
||||||
|
+ ln(COALESCE(t.lastfm_listeners, 0)::double precision + 1.0) * 0.03
|
||||||
|
+ random() * 1.6
|
||||||
|
) DESC, t.id
|
||||||
|
LIMIT $3"#,
|
||||||
|
)
|
||||||
|
.bind(track_id)
|
||||||
|
.bind(user_id)
|
||||||
|
.bind(limit)
|
||||||
|
.fetch_all(pool)
|
||||||
|
.await
|
||||||
|
.map_err(|e| cot::Error::internal(e.to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn release_radio_candidate_ids(
|
||||||
|
pool: &sqlx::PgPool,
|
||||||
|
user_id: i64,
|
||||||
|
release_id: i64,
|
||||||
|
excluded_ids: &[i64],
|
||||||
|
limit: i64,
|
||||||
|
) -> cot::Result<Vec<i64>> {
|
||||||
|
sqlx::query_scalar::<_, i64>(
|
||||||
|
r#"WITH seed_release AS (
|
||||||
|
SELECT id
|
||||||
|
FROM furumusic__release
|
||||||
|
WHERE id = $1 AND is_hidden = false
|
||||||
|
),
|
||||||
|
seed_artists AS (
|
||||||
|
SELECT ra.artist_id
|
||||||
|
FROM furumusic__release_artist ra
|
||||||
|
JOIN seed_release sr ON sr.id = ra.release_id
|
||||||
|
),
|
||||||
|
seed_tag_sources AS (
|
||||||
|
SELECT egt.genre_id,
|
||||||
|
ln(greatest(COALESCE(egt.weight, 1.0), 1.0) + 1.0) AS weight
|
||||||
|
FROM furumusic__entity_genre_tag egt
|
||||||
|
JOIN seed_release sr ON egt.entity_kind = 'release' AND egt.entity_id = sr.id
|
||||||
|
UNION ALL
|
||||||
|
SELECT egt.genre_id,
|
||||||
|
ln(greatest(COALESCE(egt.weight, 1.0), 1.0) + 1.0) AS weight
|
||||||
|
FROM furumusic__track t
|
||||||
|
JOIN seed_release sr ON sr.id = t.release_id
|
||||||
|
JOIN furumusic__entity_genre_tag egt
|
||||||
|
ON egt.entity_kind = 'track' AND egt.entity_id = t.id
|
||||||
|
UNION ALL
|
||||||
|
SELECT tg.genre_id, 1.0 AS weight
|
||||||
|
FROM furumusic__track t
|
||||||
|
JOIN seed_release sr ON sr.id = t.release_id
|
||||||
|
JOIN furumusic__track_genre tg ON tg.track_id = t.id
|
||||||
|
),
|
||||||
|
seed_tags AS (
|
||||||
|
SELECT genre_id, max(weight) AS seed_weight
|
||||||
|
FROM seed_tag_sources
|
||||||
|
GROUP BY genre_id
|
||||||
|
),
|
||||||
|
candidate_release_tag_sources AS (
|
||||||
|
SELECT egt.entity_id AS release_id,
|
||||||
|
egt.genre_id,
|
||||||
|
ln(greatest(COALESCE(egt.weight, 1.0), 1.0) + 1.0) AS weight
|
||||||
|
FROM furumusic__entity_genre_tag egt
|
||||||
|
WHERE egt.entity_kind = 'release'
|
||||||
|
UNION ALL
|
||||||
|
SELECT t.release_id,
|
||||||
|
egt.genre_id,
|
||||||
|
ln(greatest(COALESCE(egt.weight, 1.0), 1.0) + 1.0) AS weight
|
||||||
|
FROM furumusic__track t
|
||||||
|
JOIN furumusic__entity_genre_tag egt
|
||||||
|
ON egt.entity_kind = 'track' AND egt.entity_id = t.id
|
||||||
|
UNION ALL
|
||||||
|
SELECT t.release_id, tg.genre_id, 1.0 AS weight
|
||||||
|
FROM furumusic__track t
|
||||||
|
JOIN furumusic__track_genre tg ON tg.track_id = t.id
|
||||||
|
),
|
||||||
|
candidate_release_tags AS (
|
||||||
|
SELECT release_id, genre_id, max(weight) AS weight
|
||||||
|
FROM candidate_release_tag_sources
|
||||||
|
GROUP BY release_id, genre_id
|
||||||
|
),
|
||||||
|
release_scores AS (
|
||||||
|
SELECT crt.release_id, sum(st.seed_weight * crt.weight) AS tag_score
|
||||||
|
FROM candidate_release_tags crt
|
||||||
|
JOIN seed_tags st ON st.genre_id = crt.genre_id
|
||||||
|
GROUP BY crt.release_id
|
||||||
|
),
|
||||||
|
candidate_tracks AS (
|
||||||
|
SELECT t.id,
|
||||||
|
t.release_id,
|
||||||
|
COALESCE(score.tag_score, 0.0) AS tag_score,
|
||||||
|
EXISTS (
|
||||||
|
SELECT 1 FROM furumusic__user_liked_track ult
|
||||||
|
WHERE ult.user_id = $2 AND ult.track_id = t.id
|
||||||
|
) AS liked,
|
||||||
|
EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM furumusic__release_artist ra
|
||||||
|
JOIN seed_artists sa ON sa.artist_id = ra.artist_id
|
||||||
|
WHERE ra.release_id = t.release_id
|
||||||
|
) AS same_artist,
|
||||||
|
COALESCE(t.lastfm_rating, 0.0) AS rating,
|
||||||
|
COALESCE(t.lastfm_playcount, 0)::double precision AS playcount,
|
||||||
|
COALESCE(t.lastfm_listeners, 0)::double precision AS listeners
|
||||||
|
FROM furumusic__track t
|
||||||
|
JOIN furumusic__release r ON r.id = t.release_id
|
||||||
|
LEFT JOIN release_scores score ON score.release_id = t.release_id
|
||||||
|
WHERE t.is_hidden = false
|
||||||
|
AND r.is_hidden = false
|
||||||
|
AND t.release_id <> $1
|
||||||
|
AND NOT (t.id = ANY($3::bigint[]))
|
||||||
|
AND (
|
||||||
|
COALESCE(score.tag_score, 0.0) > 0.0
|
||||||
|
OR EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM furumusic__release_artist ra
|
||||||
|
JOIN seed_artists sa ON sa.artist_id = ra.artist_id
|
||||||
|
WHERE ra.release_id = t.release_id
|
||||||
|
)
|
||||||
|
OR EXISTS (
|
||||||
|
SELECT 1 FROM furumusic__user_liked_track ult
|
||||||
|
WHERE ult.user_id = $2 AND ult.track_id = t.id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
ranked_tracks AS (
|
||||||
|
SELECT *,
|
||||||
|
row_number() OVER (
|
||||||
|
PARTITION BY release_id
|
||||||
|
ORDER BY rating DESC, playcount DESC, listeners DESC, random() DESC, id
|
||||||
|
) AS release_rank
|
||||||
|
FROM candidate_tracks
|
||||||
|
)
|
||||||
|
SELECT id
|
||||||
|
FROM ranked_tracks
|
||||||
|
WHERE release_rank <= 4
|
||||||
|
ORDER BY (
|
||||||
|
tag_score * 12.0
|
||||||
|
+ CASE
|
||||||
|
WHEN liked AND tag_score > 0.0 THEN 11.0
|
||||||
|
WHEN liked THEN 3.0
|
||||||
|
ELSE 0.0
|
||||||
|
END
|
||||||
|
+ CASE WHEN same_artist THEN 3.5 ELSE 0.0 END
|
||||||
|
+ rating * 0.65
|
||||||
|
+ ln(playcount + 1.0) * 0.04
|
||||||
|
+ ln(listeners + 1.0) * 0.03
|
||||||
|
+ random() * 1.6
|
||||||
|
) DESC, id
|
||||||
|
LIMIT $4"#,
|
||||||
|
)
|
||||||
|
.bind(release_id)
|
||||||
|
.bind(user_id)
|
||||||
|
.bind(excluded_ids)
|
||||||
|
.bind(limit)
|
||||||
|
.fetch_all(pool)
|
||||||
|
.await
|
||||||
|
.map_err(|e| cot::Error::internal(e.to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn build_track_radio_ids(
|
||||||
|
pool: &sqlx::PgPool,
|
||||||
|
user_id: i64,
|
||||||
|
track_id: i64,
|
||||||
|
) -> cot::Result<Option<Vec<i64>>> {
|
||||||
|
let seed_track = sqlx::query_scalar::<_, i64>(
|
||||||
|
r#"SELECT t.id
|
||||||
|
FROM furumusic__track t
|
||||||
|
JOIN furumusic__release r ON r.id = t.release_id
|
||||||
|
WHERE t.id = $1 AND t.is_hidden = false AND r.is_hidden = false"#,
|
||||||
|
)
|
||||||
|
.bind(track_id)
|
||||||
|
.fetch_optional(pool)
|
||||||
|
.await
|
||||||
|
.map_err(|e| cot::Error::internal(e.to_string()))?;
|
||||||
|
|
||||||
|
if seed_track.is_none() {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut ids = vec![track_id];
|
||||||
|
let candidate_ids =
|
||||||
|
track_radio_candidate_ids(pool, user_id, track_id, PLAYER_RADIO_CANDIDATE_LIMIT).await?;
|
||||||
|
append_unique_track_ids(&mut ids, candidate_ids, PLAYER_RADIO_TRACK_LIMIT);
|
||||||
|
|
||||||
|
let artist_ids = track_primary_artist_ids(pool, track_id).await?;
|
||||||
|
let remaining = PLAYER_RADIO_TRACK_LIMIT.saturating_sub(ids.len()) as i64;
|
||||||
|
let fallback_ids = fallback_radio_track_ids(pool, user_id, &artist_ids, &ids, remaining).await?;
|
||||||
|
append_unique_track_ids(&mut ids, fallback_ids, PLAYER_RADIO_TRACK_LIMIT);
|
||||||
|
|
||||||
|
Ok(Some(ids))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn build_release_radio_ids(
|
||||||
|
pool: &sqlx::PgPool,
|
||||||
|
user_id: i64,
|
||||||
|
release_id: i64,
|
||||||
|
) -> cot::Result<Option<Vec<i64>>> {
|
||||||
|
let seed_release = sqlx::query_scalar::<_, i64>(
|
||||||
|
r#"SELECT id FROM furumusic__release WHERE id = $1 AND is_hidden = false"#,
|
||||||
|
)
|
||||||
|
.bind(release_id)
|
||||||
|
.fetch_optional(pool)
|
||||||
|
.await
|
||||||
|
.map_err(|e| cot::Error::internal(e.to_string()))?;
|
||||||
|
|
||||||
|
if seed_release.is_none() {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut ids = sqlx::query_scalar::<_, i64>(
|
||||||
|
r#"SELECT t.id
|
||||||
|
FROM furumusic__track t
|
||||||
|
JOIN furumusic__release r ON r.id = t.release_id
|
||||||
|
WHERE t.release_id = $1
|
||||||
|
AND t.is_hidden = false
|
||||||
|
AND r.is_hidden = false
|
||||||
|
ORDER BY COALESCE(t.lastfm_rating, 0.0) DESC,
|
||||||
|
COALESCE(t.lastfm_playcount, 0) DESC,
|
||||||
|
COALESCE(t.lastfm_listeners, 0) DESC,
|
||||||
|
t.disc_number NULLS FIRST,
|
||||||
|
t.track_number NULLS LAST,
|
||||||
|
t.id
|
||||||
|
LIMIT $2"#,
|
||||||
|
)
|
||||||
|
.bind(release_id)
|
||||||
|
.bind(PLAYER_RADIO_RELEASE_SEED_TRACKS)
|
||||||
|
.fetch_all(pool)
|
||||||
|
.await
|
||||||
|
.map_err(|e| cot::Error::internal(e.to_string()))?;
|
||||||
|
|
||||||
|
let candidate_ids = release_radio_candidate_ids(
|
||||||
|
pool,
|
||||||
|
user_id,
|
||||||
|
release_id,
|
||||||
|
&ids,
|
||||||
|
PLAYER_RADIO_CANDIDATE_LIMIT,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
append_unique_track_ids(&mut ids, candidate_ids, PLAYER_RADIO_TRACK_LIMIT);
|
||||||
|
|
||||||
|
let artist_ids = release_primary_artist_ids(pool, release_id).await?;
|
||||||
|
let remaining = PLAYER_RADIO_TRACK_LIMIT.saturating_sub(ids.len()) as i64;
|
||||||
|
let fallback_ids = fallback_radio_track_ids(pool, user_id, &artist_ids, &ids, remaining).await?;
|
||||||
|
append_unique_track_ids(&mut ids, fallback_ids, PLAYER_RADIO_TRACK_LIMIT);
|
||||||
|
|
||||||
|
Ok(Some(ids))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn radio_handler(
|
||||||
|
session: Session,
|
||||||
|
db: Database,
|
||||||
|
pool: &sqlx::PgPool,
|
||||||
|
path: Path<PathRadioSeed>,
|
||||||
|
) -> cot::Result<cot::response::Response> {
|
||||||
|
let Some(user) = auth::get_session_user(&session, &db).await else {
|
||||||
|
return Ok(json_error(StatusCode::UNAUTHORIZED, "not authenticated"));
|
||||||
|
};
|
||||||
|
|
||||||
|
let seed = path.0;
|
||||||
|
let ids = match seed.kind.as_str() {
|
||||||
|
"track" => build_track_radio_ids(pool, user.id, seed.id).await?,
|
||||||
|
"release" => build_release_radio_ids(pool, user.id, seed.id).await?,
|
||||||
|
_ => return Ok(json_error(StatusCode::BAD_REQUEST, "unknown radio seed")),
|
||||||
|
};
|
||||||
|
|
||||||
|
let Some(ids) = ids else {
|
||||||
|
return Ok(json_error(StatusCode::NOT_FOUND, "radio seed not found"));
|
||||||
|
};
|
||||||
|
|
||||||
|
let tracks = load_track_items_by_ids(pool, &ids).await?;
|
||||||
|
Json(tracks).into_response()
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// POST /api/player/tracks-by-ids
|
// POST /api/player/tracks-by-ids
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -5266,117 +5835,8 @@ async fn tracks_by_ids_handler(
|
|||||||
return Json(Vec::<TrackItem>::new()).into_response();
|
return Json(Vec::<TrackItem>::new()).into_response();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limit to 500 IDs to prevent abuse
|
|
||||||
let ids: Vec<i64> = body.ids.into_iter().take(500).collect();
|
let ids: Vec<i64> = body.ids.into_iter().take(500).collect();
|
||||||
|
let result = load_track_items_by_ids(pool, &ids).await?;
|
||||||
let tracks = sqlx::query_as::<_, TrackRow>(
|
|
||||||
r#"SELECT t.id, t.title::text as title, t.track_number, t.disc_number,
|
|
||||||
t.duration_seconds, t.cover_file_id,
|
|
||||||
r.cover_file_id as release_cover_file_id,
|
|
||||||
r.id as release_id,
|
|
||||||
r.title::text as release_title,
|
|
||||||
r.year as release_year,
|
|
||||||
COALESCE(mf.uploader_name, 'UFO')::text AS uploader_name,
|
|
||||||
mf.audio_format,
|
|
||||||
mf.audio_bitrate,
|
|
||||||
mf.audio_sample_rate,
|
|
||||||
mf.audio_bit_depth,
|
|
||||||
mf.file_size_bytes,
|
|
||||||
t.lastfm_listeners,
|
|
||||||
t.lastfm_playcount,
|
|
||||||
t.lastfm_rating,
|
|
||||||
t.lastfm_updated_at
|
|
||||||
FROM furumusic__track t
|
|
||||||
JOIN furumusic__release r ON r.id = t.release_id
|
|
||||||
LEFT JOIN furumusic__media_file mf ON mf.id = t.audio_file_id
|
|
||||||
WHERE t.id = ANY($1) AND t.is_hidden = false"#,
|
|
||||||
)
|
|
||||||
.bind(&ids)
|
|
||||||
.fetch_all(pool)
|
|
||||||
.await
|
|
||||||
.map_err(|e| cot::Error::internal(e.to_string()))?;
|
|
||||||
|
|
||||||
let track_ids: Vec<i64> = tracks.iter().map(|t| t.id).collect();
|
|
||||||
|
|
||||||
let track_artists = if track_ids.is_empty() {
|
|
||||||
Vec::new()
|
|
||||||
} else {
|
|
||||||
sqlx::query_as::<_, TrackArtistRow>(
|
|
||||||
r#"SELECT ta.track_id, ta.artist_id, a.name::text as artist_name, ta.role::text as role
|
|
||||||
FROM furumusic__track_artist ta
|
|
||||||
JOIN furumusic__artist a ON a.id = ta.artist_id
|
|
||||||
WHERE ta.track_id = ANY($1)
|
|
||||||
ORDER BY ta.track_id, ta.position"#,
|
|
||||||
)
|
|
||||||
.bind(&track_ids)
|
|
||||||
.fetch_all(pool)
|
|
||||||
.await
|
|
||||||
.map_err(|e| cot::Error::internal(e.to_string()))?
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut track_main_artists: std::collections::HashMap<i64, Vec<ArtistRef>> =
|
|
||||||
std::collections::HashMap::new();
|
|
||||||
let mut track_feat_artists: std::collections::HashMap<i64, Vec<ArtistRef>> =
|
|
||||||
std::collections::HashMap::new();
|
|
||||||
|
|
||||||
for ta in &track_artists {
|
|
||||||
let artist_ref = ArtistRef {
|
|
||||||
id: ta.artist_id,
|
|
||||||
name: ta.artist_name.clone(),
|
|
||||||
};
|
|
||||||
if ta.role == "featuring" {
|
|
||||||
track_feat_artists
|
|
||||||
.entry(ta.track_id)
|
|
||||||
.or_default()
|
|
||||||
.push(artist_ref);
|
|
||||||
} else {
|
|
||||||
track_main_artists
|
|
||||||
.entry(ta.track_id)
|
|
||||||
.or_default()
|
|
||||||
.push(artist_ref);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build a map from id -> TrackItem
|
|
||||||
let mut track_map: std::collections::HashMap<i64, TrackItem> = std::collections::HashMap::new();
|
|
||||||
for t in tracks {
|
|
||||||
let tid = t.id;
|
|
||||||
track_map.insert(
|
|
||||||
tid,
|
|
||||||
TrackItem {
|
|
||||||
id: t.id,
|
|
||||||
title: t.title,
|
|
||||||
track_number: t.track_number,
|
|
||||||
disc_number: t.disc_number,
|
|
||||||
duration_seconds: t.duration_seconds,
|
|
||||||
artists: track_main_artists.remove(&tid).unwrap_or_default(),
|
|
||||||
featured_artists: track_feat_artists.remove(&tid).unwrap_or_default(),
|
|
||||||
release_id: t.release_id,
|
|
||||||
release_title: t.release_title,
|
|
||||||
release_year: t.release_year,
|
|
||||||
cover_url: track_cover_variant_url(
|
|
||||||
t.cover_file_id,
|
|
||||||
t.release_cover_file_id,
|
|
||||||
"medium",
|
|
||||||
),
|
|
||||||
stream_url: format!("/api/player/stream/{tid}"),
|
|
||||||
uploader_name: t.uploader_name,
|
|
||||||
audio_format: t.audio_format,
|
|
||||||
audio_bitrate: t.audio_bitrate,
|
|
||||||
audio_sample_rate: t.audio_sample_rate,
|
|
||||||
audio_bit_depth: t.audio_bit_depth,
|
|
||||||
file_size_bytes: t.file_size_bytes,
|
|
||||||
lastfm_listeners: t.lastfm_listeners,
|
|
||||||
lastfm_playcount: t.lastfm_playcount,
|
|
||||||
lastfm_rating: t.lastfm_rating,
|
|
||||||
lastfm_updated_at: t.lastfm_updated_at,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reorder results to match input order
|
|
||||||
let result: Vec<TrackItem> = ids.iter().filter_map(|id| track_map.remove(id)).collect();
|
|
||||||
|
|
||||||
Json(result).into_response()
|
Json(result).into_response()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6224,6 +6684,30 @@ impl App for PlayerApp {
|
|||||||
},
|
},
|
||||||
"player_release_detail",
|
"player_release_detail",
|
||||||
),
|
),
|
||||||
|
Route::with_handler_and_name(
|
||||||
|
"/radio/{kind}/{id}",
|
||||||
|
{
|
||||||
|
let pool = Arc::clone(&pool);
|
||||||
|
let pool_config = Arc::clone(&pool_config);
|
||||||
|
get(move |session: Session, db: Database, path: Path<PathRadioSeed>| {
|
||||||
|
let pool = Arc::clone(&pool);
|
||||||
|
let pool_config = Arc::clone(&pool_config);
|
||||||
|
async move {
|
||||||
|
let pg_pool = pool
|
||||||
|
.get_or_init(|| async {
|
||||||
|
sqlx::postgres::PgPoolOptions::new()
|
||||||
|
.max_connections(5)
|
||||||
|
.connect(&pool_config.database_url)
|
||||||
|
.await
|
||||||
|
.expect("player pool")
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
radio_handler(session, db, pg_pool, path).await
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
"player_radio",
|
||||||
|
),
|
||||||
// -- Playlists (list + create) --
|
// -- Playlists (list + create) --
|
||||||
Route::with_handler_and_name(
|
Route::with_handler_and_name(
|
||||||
"/playlists",
|
"/playlists",
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ pub(super) struct PathStringId {
|
|||||||
pub(super) id: String,
|
pub(super) id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub(super) struct PathRadioSeed {
|
||||||
|
pub(super) kind: String,
|
||||||
|
pub(super) id: i64,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub(super) struct SearchQuery {
|
pub(super) struct SearchQuery {
|
||||||
pub(super) q: String,
|
pub(super) q: String,
|
||||||
|
|||||||
+22
-29
@@ -36,30 +36,6 @@ pub(super) struct ArtistBriefRow {
|
|||||||
pub(super) name: String,
|
pub(super) name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(sqlx::FromRow)]
|
|
||||||
pub(super) struct TrackRow {
|
|
||||||
pub(super) id: i64,
|
|
||||||
pub(super) title: String,
|
|
||||||
pub(super) track_number: Option<i32>,
|
|
||||||
pub(super) disc_number: Option<i32>,
|
|
||||||
pub(super) duration_seconds: f64,
|
|
||||||
pub(super) cover_file_id: Option<i64>,
|
|
||||||
pub(super) release_cover_file_id: Option<i64>,
|
|
||||||
pub(super) release_id: i64,
|
|
||||||
pub(super) release_title: String,
|
|
||||||
pub(super) release_year: Option<i32>,
|
|
||||||
pub(super) uploader_name: String,
|
|
||||||
pub(super) audio_format: Option<String>,
|
|
||||||
pub(super) audio_bitrate: Option<i32>,
|
|
||||||
pub(super) audio_sample_rate: Option<i32>,
|
|
||||||
pub(super) audio_bit_depth: Option<i32>,
|
|
||||||
pub(super) file_size_bytes: Option<i64>,
|
|
||||||
pub(super) lastfm_listeners: Option<i64>,
|
|
||||||
pub(super) lastfm_playcount: Option<i64>,
|
|
||||||
pub(super) lastfm_rating: Option<f64>,
|
|
||||||
pub(super) lastfm_updated_at: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(sqlx::FromRow)]
|
#[derive(sqlx::FromRow)]
|
||||||
pub(super) struct TrackArtistRow {
|
pub(super) struct TrackArtistRow {
|
||||||
pub(super) track_id: i64,
|
pub(super) track_id: i64,
|
||||||
@@ -276,14 +252,31 @@ pub(super) struct ReleaseUploaderRow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(sqlx::FromRow)]
|
#[derive(sqlx::FromRow)]
|
||||||
pub(super) struct PlayHistoryRow {
|
pub(super) struct PlayHistoryTrackRow {
|
||||||
pub(super) id: i64,
|
pub(super) history_id: i64,
|
||||||
pub(super) track_id: i64,
|
|
||||||
pub(super) track_title: String,
|
|
||||||
pub(super) release_title: Option<String>,
|
|
||||||
pub(super) played_at: String,
|
pub(super) played_at: String,
|
||||||
pub(super) duration_listened: Option<i32>,
|
pub(super) duration_listened: Option<i32>,
|
||||||
pub(super) completed: bool,
|
pub(super) completed: bool,
|
||||||
|
pub(super) id: i64,
|
||||||
|
pub(super) title: String,
|
||||||
|
pub(super) track_number: Option<i32>,
|
||||||
|
pub(super) disc_number: Option<i32>,
|
||||||
|
pub(super) duration_seconds: f64,
|
||||||
|
pub(super) cover_file_id: Option<i64>,
|
||||||
|
pub(super) release_cover_file_id: Option<i64>,
|
||||||
|
pub(super) release_id: i64,
|
||||||
|
pub(super) release_title: String,
|
||||||
|
pub(super) release_year: Option<i32>,
|
||||||
|
pub(super) uploader_name: String,
|
||||||
|
pub(super) audio_format: Option<String>,
|
||||||
|
pub(super) audio_bitrate: Option<i32>,
|
||||||
|
pub(super) audio_sample_rate: Option<i32>,
|
||||||
|
pub(super) audio_bit_depth: Option<i32>,
|
||||||
|
pub(super) file_size_bytes: Option<i64>,
|
||||||
|
pub(super) lastfm_listeners: Option<i64>,
|
||||||
|
pub(super) lastfm_playcount: Option<i64>,
|
||||||
|
pub(super) lastfm_rating: Option<f64>,
|
||||||
|
pub(super) lastfm_updated_at: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(sqlx::FromRow)]
|
#[derive(sqlx::FromRow)]
|
||||||
|
|||||||
@@ -46,6 +46,12 @@
|
|||||||
<label style="display:inline-flex; gap:.35rem; align-items:center; margin-right:1rem; margin-bottom:.4rem;">
|
<label style="display:inline-flex; gap:.35rem; align-items:center; margin-right:1rem; margin-bottom:.4rem;">
|
||||||
<input type="checkbox" name="duration_seconds" checked> duration_seconds
|
<input type="checkbox" name="duration_seconds" checked> duration_seconds
|
||||||
</label>
|
</label>
|
||||||
|
<label style="display:inline-flex; gap:.35rem; align-items:center; margin-right:1rem; margin-bottom:.4rem;">
|
||||||
|
<input type="checkbox" name="local_genres" checked> local genres from files
|
||||||
|
</label>
|
||||||
|
<label style="display:inline-flex; gap:.35rem; align-items:center; margin-right:1rem; margin-bottom:.4rem;">
|
||||||
|
<input type="checkbox" name="lastfm_tags" checked> Last.fm tags
|
||||||
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div style="display:flex; gap:1rem; align-items:center; margin-bottom:.9rem;">
|
<div style="display:flex; gap:1rem; align-items:center; margin-bottom:.9rem;">
|
||||||
<label style="display:inline-flex; gap:.35rem; align-items:center;">
|
<label style="display:inline-flex; gap:.35rem; align-items:center;">
|
||||||
|
|||||||
+411
-71
@@ -486,6 +486,13 @@ tbody tr:hover {
|
|||||||
.tag.plays,
|
.tag.plays,
|
||||||
.tag.followers { background: rgba(185, 140, 255, 0.18); color: #d8c2ff; }
|
.tag.followers { background: rgba(185, 140, 255, 0.18); color: #d8c2ff; }
|
||||||
.tag.visibility { background: rgba(29, 185, 84, 0.16); color: #8ef0b2; }
|
.tag.visibility { background: rgba(29, 185, 84, 0.16); color: #8ef0b2; }
|
||||||
|
.tag.metadata-lastfm { background: rgba(90, 167, 255, 0.18); color: #c7e0ff; }
|
||||||
|
.tag.metadata-file { background: rgba(29, 185, 84, 0.16); color: #9af0b8; }
|
||||||
|
.tag.metadata-review { background: rgba(241, 184, 75, 0.18); color: #ffe1a6; }
|
||||||
|
.tag.metadata-track-genre { background: rgba(255, 255, 255, 0.1); color: #d2d2d2; }
|
||||||
|
.tag.metadata-release-lastfm { background: rgba(90, 167, 255, 0.12); color: #b7d6ff; border: 1px solid rgba(90, 167, 255, 0.22); }
|
||||||
|
.tag.metadata-release-file { background: rgba(29, 185, 84, 0.1); color: #a7eabd; border: 1px solid rgba(29, 185, 84, 0.2); }
|
||||||
|
.tag.metadata-release-review { background: rgba(241, 184, 75, 0.12); color: #ffe1a6; border: 1px solid rgba(241, 184, 75, 0.22); }
|
||||||
|
|
||||||
.jobs-grid {
|
.jobs-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -494,6 +501,45 @@ tbody tr:hover {
|
|||||||
padding: 12px;
|
padding: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.metadata-backfill-options {
|
||||||
|
display: grid;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--bg-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-backfill-options .option-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-backfill-options label {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 7px;
|
||||||
|
min-height: 26px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-backfill-options input {
|
||||||
|
width: auto;
|
||||||
|
min-height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-backfill-options .mode-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 14px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
padding-top: 4px;
|
||||||
|
border-top: 1px solid rgba(255, 255, 255, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
.jobs-page {
|
.jobs-page {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: minmax(720px, 1fr) 380px;
|
grid-template-columns: minmax(720px, 1fr) 380px;
|
||||||
@@ -524,31 +570,37 @@ tbody tr:hover {
|
|||||||
table-layout: fixed;
|
table-layout: fixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
.jobs-page .jobs-list-panel .panel-head,
|
.jobs-page .jobs-list-panel .panel-head {
|
||||||
.jobs-page .jobs-list-panel .action-strip {
|
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.jobs-page .jobs-list-panel .action-strip {
|
.job-table .job-column { width: 32%; }
|
||||||
border-top: 1px solid var(--border-color);
|
.job-table .state-column { width: 12%; }
|
||||||
border-bottom: 0;
|
.job-table .schedule-column { width: 22%; }
|
||||||
}
|
.job-table .runs-column { width: 24%; }
|
||||||
|
|
||||||
.job-table .job-column { width: 28%; }
|
|
||||||
.job-table .state-column { width: 13%; }
|
|
||||||
.job-table .schedule-column { width: 20%; }
|
|
||||||
.job-table .runs-column { width: 29%; }
|
|
||||||
.job-table .actions-column { width: 10%; }
|
.job-table .actions-column { width: 10%; }
|
||||||
|
|
||||||
|
.job-table .toolbar {
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
.inline-runs {
|
.inline-runs {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: nowrap;
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
|
max-width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.run-chip {
|
.run-chip {
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
max-width: 128px;
|
max-width: 70px;
|
||||||
|
height: 20px;
|
||||||
|
padding: 0 7px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-form {
|
.task-form {
|
||||||
@@ -557,6 +609,76 @@ tbody tr:hover {
|
|||||||
grid-column: 2;
|
grid-column: 2;
|
||||||
grid-row: 1 / span 2;
|
grid-row: 1 / span 2;
|
||||||
align-self: start;
|
align-self: start;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
max-height: calc(100vh - 100px);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.task-form-body {
|
||||||
|
min-height: 0;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.job-detail-description {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.45;
|
||||||
|
}
|
||||||
|
|
||||||
|
.job-facts {
|
||||||
|
display: grid;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.job-fact {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 58px minmax(0, 1fr);
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 28px;
|
||||||
|
padding: 6px 8px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 7px;
|
||||||
|
background: var(--bg-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.job-fact span:first-child {
|
||||||
|
color: var(--text-subdued);
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 850;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.job-fact span:last-child {
|
||||||
|
min-width: 0;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.job-param-note {
|
||||||
|
margin: -2px 0 10px;
|
||||||
|
color: var(--text-subdued);
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.job-run-pager {
|
||||||
|
min-height: 34px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 8px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.job-run-pager .toolbar {
|
||||||
|
flex-wrap: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.run-log-panel {
|
.run-log-panel {
|
||||||
@@ -941,6 +1063,44 @@ tbody tr:hover {
|
|||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.run-log-output.is-following {
|
||||||
|
border-color: rgba(29, 185, 84, 0.36);
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-tags {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
max-height: 112px;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--bg-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-tags .tag {
|
||||||
|
height: auto;
|
||||||
|
min-height: 24px;
|
||||||
|
gap: 5px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-tags small {
|
||||||
|
font-size: 9px;
|
||||||
|
font-weight: 800;
|
||||||
|
opacity: 0.72;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-empty {
|
||||||
|
min-height: 34px;
|
||||||
|
padding: 8px 10px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--bg-primary);
|
||||||
|
}
|
||||||
|
|
||||||
.artist-picker {
|
.artist-picker {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
@@ -1335,7 +1495,7 @@ tbody tr:hover {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<template x-for="job in pagedJobs()" :key="job.name">
|
<template x-for="job in jobs" :key="job.name">
|
||||||
<tr :class="{active: activeJob && activeJob.name === job.name}" @click="selectJob(job.name)">
|
<tr :class="{active: activeJob && activeJob.name === job.name}" @click="selectJob(job.name)">
|
||||||
<td>
|
<td>
|
||||||
<div class="primary-line" x-text="job.name"></div>
|
<div class="primary-line" x-text="job.name"></div>
|
||||||
@@ -1348,7 +1508,7 @@ tbody tr:hover {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="inline-runs">
|
<div class="inline-runs">
|
||||||
<template x-for="run in (job.recent_runs || []).slice(0, 5)" :key="run.id">
|
<template x-for="run in (job.recent_runs || []).slice(0, 3)" :key="run.id">
|
||||||
<button class="badge run-chip" :class="run.status" @click.stop="loadRunDetail(run)" :title="runTitle(run)">
|
<button class="badge run-chip" :class="run.status" @click.stop="loadRunDetail(run)" :title="runTitle(run)">
|
||||||
<span x-text="runChipLabel(run)"></span>
|
<span x-text="runChipLabel(run)"></span>
|
||||||
</button>
|
</button>
|
||||||
@@ -1357,10 +1517,10 @@ tbody tr:hover {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="toolbar">
|
<div class="toolbar">
|
||||||
<button class="icon-btn" @click.stop="runJob(job)" :disabled="job.launching" title="Run now">
|
<button class="icon-btn" type="button" @click.stop="runJob(job)" :disabled="Boolean(job.launching)" title="Run now">
|
||||||
<i data-lucide="play"></i>
|
<i data-lucide="play"></i>
|
||||||
</button>
|
</button>
|
||||||
<button class="icon-btn" @click.stop="toggleJob(job)" :title="job.enabled ? 'Disable' : 'Enable'">
|
<button class="icon-btn" type="button" @click.stop="toggleJob(job)" :title="job.enabled ? 'Disable' : 'Enable'">
|
||||||
<i :data-lucide="job.enabled ? 'pause' : 'power'"></i>
|
<i :data-lucide="job.enabled ? 'pause' : 'power'"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -1370,18 +1530,6 @@ tbody tr:hover {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="action-strip">
|
|
||||||
<span class="selection-summary" x-text="jobsRangeText()"></span>
|
|
||||||
<div class="toolbar">
|
|
||||||
<select class="search" style="width:92px" x-model.number="jobsPerPage" @change="jobsPage = 0">
|
|
||||||
<option value="8">8</option>
|
|
||||||
<option value="12">12</option>
|
|
||||||
<option value="20">20</option>
|
|
||||||
</select>
|
|
||||||
<button class="btn" @click="pageJobs(-1)" :disabled="jobsPage === 0">Previous</button>
|
|
||||||
<button class="btn" @click="pageJobs(1)" :disabled="(jobsPage + 1) * jobsPerPage >= jobs.length">Next</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="panel task-form">
|
<section class="panel task-form">
|
||||||
@@ -1391,25 +1539,45 @@ tbody tr:hover {
|
|||||||
<span x-text="activeJob ? activeJob.health : 'Select a task'"></span>
|
<span x-text="activeJob ? activeJob.health : 'Select a task'"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="padding:14px" x-show="activeJob">
|
<div class="task-form-body" x-show="activeJob">
|
||||||
<div class="field">
|
<div class="job-detail-description" x-text="activeJob?.description || ''"></div>
|
||||||
<label>Description</label>
|
<div class="job-facts">
|
||||||
<textarea readonly x-text="activeJob?.description || ''"></textarea>
|
<div class="job-fact">
|
||||||
|
<span>Cron</span>
|
||||||
|
<span :title="activeJob?.cron_expression || ''" x-text="cronLabel(activeJob)"></span>
|
||||||
|
</div>
|
||||||
|
<div class="job-fact">
|
||||||
|
<span>Next</span>
|
||||||
|
<span x-text="relativeDate(activeJob?.next_run_at)"></span>
|
||||||
|
</div>
|
||||||
|
<div class="job-fact">
|
||||||
|
<span>Last</span>
|
||||||
|
<span x-text="relativeDate(activeJob?.last_run_at)"></span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="metadata-backfill-options" x-show="isMetadataBackfillJob(activeJob)">
|
||||||
<label>Cron</label>
|
<div class="option-grid">
|
||||||
<input readonly :value="activeJob?.cron_expression || ''" />
|
<label><input type="checkbox" x-model="metadataBackfillOptions.audio_bitrate" /> audio_bitrate</label>
|
||||||
|
<label><input type="checkbox" x-model="metadataBackfillOptions.audio_sample_rate" /> audio_sample_rate</label>
|
||||||
|
<label><input type="checkbox" x-model="metadataBackfillOptions.audio_bit_depth" /> audio_bit_depth</label>
|
||||||
|
<label><input type="checkbox" x-model="metadataBackfillOptions.duration_seconds" /> duration_seconds</label>
|
||||||
|
<label><input type="checkbox" x-model="metadataBackfillOptions.local_genres" /> local genres from files</label>
|
||||||
|
<label><input type="checkbox" x-model="metadataBackfillOptions.lastfm_tags" /> Last.fm tags</label>
|
||||||
|
</div>
|
||||||
|
<div class="mode-row">
|
||||||
|
<label><input type="radio" value="fill_missing" x-model="metadataBackfillOptions.mode" /> Fill missing only</label>
|
||||||
|
<label><input type="radio" value="overwrite" x-model="metadataBackfillOptions.mode" /> Overwrite existing values</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="job-param-note" x-show="activeJob && !jobHasParameterForm(activeJob)">
|
||||||
<label>Next / Last</label>
|
This task has no manual parameters.
|
||||||
<input readonly :value="relativeDate(activeJob?.next_run_at) + ' / ' + relativeDate(activeJob?.last_run_at)" />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="toolbar" style="margin-bottom:12px">
|
<div class="toolbar" style="margin-bottom:12px">
|
||||||
<button class="btn primary" @click="runJob(activeJob)">
|
<button class="btn primary" type="button" @click="runJob(activeJob)">
|
||||||
<i data-lucide="play"></i>
|
<i data-lucide="play"></i>
|
||||||
Run now
|
<span x-text="isMetadataBackfillJob(activeJob) ? 'Run with options' : 'Run now'"></span>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn" @click="toggleJob(activeJob)">
|
<button class="btn" type="button" @click="toggleJob(activeJob)">
|
||||||
<i data-lucide="power"></i>
|
<i data-lucide="power"></i>
|
||||||
Toggle
|
Toggle
|
||||||
</button>
|
</button>
|
||||||
@@ -1417,7 +1585,7 @@ tbody tr:hover {
|
|||||||
<div class="field">
|
<div class="field">
|
||||||
<label>Recent Runs</label>
|
<label>Recent Runs</label>
|
||||||
<div class="runs">
|
<div class="runs">
|
||||||
<template x-for="run in visibleRuns()" :key="run.id">
|
<template x-for="run in pagedVisibleRuns()" :key="run.id">
|
||||||
<div class="run-row" @click="loadRunDetail(run)">
|
<div class="run-row" @click="loadRunDetail(run)">
|
||||||
<span class="badge" :class="run.status" x-text="run.status"></span>
|
<span class="badge" :class="run.status" x-text="run.status"></span>
|
||||||
<span x-text="'#' + run.id"></span>
|
<span x-text="'#' + run.id"></span>
|
||||||
@@ -1425,6 +1593,14 @@ tbody tr:hover {
|
|||||||
<span x-text="duration(run.duration_ms)"></span>
|
<span x-text="duration(run.duration_ms)"></span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<div class="empty" x-show="visibleRuns().length === 0">No runs for this task yet</div>
|
||||||
|
</div>
|
||||||
|
<div class="job-run-pager" x-show="visibleRuns().length > recentRunsPerPage">
|
||||||
|
<span class="selection-summary" x-text="recentRunsRangeText()"></span>
|
||||||
|
<div class="toolbar">
|
||||||
|
<button class="btn" type="button" @click="pageRecentRuns(-1)" :disabled="recentRunsPage === 0">Previous</button>
|
||||||
|
<button class="btn" type="button" @click="pageRecentRuns(1)" :disabled="(recentRunsPage + 1) * recentRunsPerPage >= visibleRuns().length">Next</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1440,10 +1616,14 @@ tbody tr:hover {
|
|||||||
<div class="toolbar" x-show="activeRunDetail">
|
<div class="toolbar" x-show="activeRunDetail">
|
||||||
<span class="badge" :class="activeRunDetail?.run?.status" x-text="activeRunDetail?.run?.status"></span>
|
<span class="badge" :class="activeRunDetail?.run?.status" x-text="activeRunDetail?.run?.status"></span>
|
||||||
<span class="selection-summary" x-text="duration(activeRunDetail?.run?.duration_ms)"></span>
|
<span class="selection-summary" x-text="duration(activeRunDetail?.run?.duration_ms)"></span>
|
||||||
|
<button class="btn" type="button" x-show="!runLogAutoScroll" @click="enableRunLogFollow()">
|
||||||
|
<i data-lucide="chevrons-down"></i>
|
||||||
|
Follow
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="run-log-body">
|
<div class="run-log-body">
|
||||||
<pre class="run-log-output" x-show="activeRunDetail" x-text="activeRunDetail?.log_output || activeRunDetail?.run?.log_excerpt || 'No log output captured for this run.'"></pre>
|
<pre class="run-log-output" :class="{'is-following': runLogAutoScroll}" x-ref="runLogOutput" x-show="activeRunDetail" @scroll.passive="handleRunLogScroll()" x-text="activeRunDetail?.log_output || activeRunDetail?.run?.log_excerpt || 'No log output captured for this run.'"></pre>
|
||||||
<div class="empty" x-show="!activeRunDetail">No run selected</div>
|
<div class="empty" x-show="!activeRunDetail">No run selected</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -2015,6 +2195,22 @@ tbody tr:hover {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="field" x-show="canShowMetadataTags()">
|
||||||
|
<label>Metadata genres and tags</label>
|
||||||
|
<div class="metadata-tags" x-show="metadataTags().length">
|
||||||
|
<template x-for="tag in metadataTags()" :key="`${tag.source}:${tag.name}`">
|
||||||
|
<span class="tag" :class="metadataTagClass(tag)" :title="metadataTagTitle(tag)">
|
||||||
|
<span x-text="tag.name"></span>
|
||||||
|
<small x-text="metadataTagSourceLabel(tag)"></small>
|
||||||
|
<small x-show="metadataTagScore(tag)" x-text="metadataTagScore(tag)"></small>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div class="metadata-empty muted" x-show="!metadataTags().length">
|
||||||
|
No metadata genres or tags saved yet
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>Visibility</label>
|
<label>Visibility</label>
|
||||||
<select class="search" style="width:100%" x-model="editorDraft.hidden">
|
<select class="search" style="width:100%" x-model="editorDraft.hidden">
|
||||||
@@ -2131,8 +2327,19 @@ function adminV2() {
|
|||||||
recentRuns: [],
|
recentRuns: [],
|
||||||
activeJobName: null,
|
activeJobName: null,
|
||||||
activeRunDetail: null,
|
activeRunDetail: null,
|
||||||
jobsPage: 0,
|
recentRunsPage: 0,
|
||||||
jobsPerPage: 12,
|
recentRunsPerPage: 8,
|
||||||
|
runLogAutoScroll: true,
|
||||||
|
runLogRefreshing: false,
|
||||||
|
metadataBackfillOptions: {
|
||||||
|
audio_bitrate: true,
|
||||||
|
audio_sample_rate: true,
|
||||||
|
audio_bit_depth: true,
|
||||||
|
duration_seconds: true,
|
||||||
|
local_genres: true,
|
||||||
|
lastfm_tags: true,
|
||||||
|
mode: 'fill_missing'
|
||||||
|
},
|
||||||
libraryKind: 'artists',
|
libraryKind: 'artists',
|
||||||
librarySearch: '',
|
librarySearch: '',
|
||||||
library: { items: [], total: 0, limit: 40, offset: 0 },
|
library: { items: [], total: 0, limit: 40, offset: 0 },
|
||||||
@@ -2186,7 +2393,7 @@ function adminV2() {
|
|||||||
this.applyRouteFromHash();
|
this.applyRouteFromHash();
|
||||||
this.activateCurrentView(false);
|
this.activateCurrentView(false);
|
||||||
});
|
});
|
||||||
this.poller = setInterval(() => this.poll(), 6000);
|
this.poller = setInterval(() => this.poll(), 4000);
|
||||||
this.icons();
|
this.icons();
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -2227,7 +2434,15 @@ function adminV2() {
|
|||||||
|
|
||||||
async poll() {
|
async poll() {
|
||||||
if (this.loading) return;
|
if (this.loading) return;
|
||||||
await Promise.allSettled([this.loadJobs(false), this.loadReviews(false)]);
|
if (this.activeView === 'jobs') {
|
||||||
|
await Promise.allSettled([
|
||||||
|
this.loadJobs(false),
|
||||||
|
this.activeJobName ? this.loadRunsForJob(this.activeJobName, false) : Promise.resolve(),
|
||||||
|
this.refreshActiveRunDetail()
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
await Promise.allSettled([this.loadJobs(false), this.loadReviews(false)]);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
applyRouteFromHash() {
|
applyRouteFromHash() {
|
||||||
@@ -2336,7 +2551,6 @@ function adminV2() {
|
|||||||
try {
|
try {
|
||||||
this.jobs = await this.request(`${this.apiBase}/jobs`);
|
this.jobs = await this.request(`${this.apiBase}/jobs`);
|
||||||
if (!this.activeJobName && this.jobs.length) this.activeJobName = this.jobs[0].name;
|
if (!this.activeJobName && this.jobs.length) this.activeJobName = this.jobs[0].name;
|
||||||
if (this.jobsPage * this.jobsPerPage >= this.jobs.length) this.jobsPage = 0;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (showErrors) this.showToast(error.message);
|
if (showErrors) this.showToast(error.message);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -2578,13 +2792,22 @@ function adminV2() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async runJob(job) {
|
async runJob(job) {
|
||||||
|
if (!job) return;
|
||||||
|
if (job.launching) return;
|
||||||
job.launching = true;
|
job.launching = true;
|
||||||
try {
|
try {
|
||||||
const result = await this.request(`${this.apiBase}/jobs/${encodeURIComponent(job.name)}/run`, { method: 'POST' });
|
const result = this.isMetadataBackfillJob(job)
|
||||||
|
? await this.request(`${this.apiBase}/jobs/metadata_backfill/run-options`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(this.metadataBackfillPayload())
|
||||||
|
})
|
||||||
|
: await this.request(`${this.apiBase}/jobs/${encodeURIComponent(job.name)}/run`, { method: 'POST' });
|
||||||
this.showToast(`Run #${result.run_id} started`);
|
this.showToast(`Run #${result.run_id} started`);
|
||||||
this.activeJobName = job.name;
|
this.activeJobName = job.name;
|
||||||
|
this.recentRunsPage = 0;
|
||||||
await this.loadJobs(false);
|
await this.loadJobs(false);
|
||||||
await this.loadRunsForJob(job.name);
|
await this.loadRunsForJob(job.name);
|
||||||
|
await this.loadRunDetail({ id: result.run_id, job_name: job.name }, { silent: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.showToast(error.message);
|
this.showToast(error.message);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -2593,6 +2816,27 @@ function adminV2() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isMetadataBackfillJob(job) {
|
||||||
|
return job && job.name === 'metadata_backfill';
|
||||||
|
},
|
||||||
|
|
||||||
|
jobHasParameterForm(job) {
|
||||||
|
return this.isMetadataBackfillJob(job);
|
||||||
|
},
|
||||||
|
|
||||||
|
metadataBackfillPayload() {
|
||||||
|
const options = this.metadataBackfillOptions || {};
|
||||||
|
return {
|
||||||
|
audio_bitrate: Boolean(options.audio_bitrate),
|
||||||
|
audio_sample_rate: Boolean(options.audio_sample_rate),
|
||||||
|
audio_bit_depth: Boolean(options.audio_bit_depth),
|
||||||
|
duration_seconds: Boolean(options.duration_seconds),
|
||||||
|
local_genres: Boolean(options.local_genres),
|
||||||
|
lastfm_tags: Boolean(options.lastfm_tags),
|
||||||
|
overwrite: options.mode === 'overwrite'
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
async toggleJob(job) {
|
async toggleJob(job) {
|
||||||
try {
|
try {
|
||||||
const result = await this.request(`${this.apiBase}/jobs/${encodeURIComponent(job.name)}/toggle`, { method: 'POST' });
|
const result = await this.request(`${this.apiBase}/jobs/${encodeURIComponent(job.name)}/toggle`, { method: 'POST' });
|
||||||
@@ -2608,34 +2852,101 @@ function adminV2() {
|
|||||||
this.setRoute(`#jobs/${encodeURIComponent(name)}`);
|
this.setRoute(`#jobs/${encodeURIComponent(name)}`);
|
||||||
this.activeReview = null;
|
this.activeReview = null;
|
||||||
this.activeRunDetail = null;
|
this.activeRunDetail = null;
|
||||||
|
this.recentRunsPage = 0;
|
||||||
|
this.runLogAutoScroll = true;
|
||||||
await this.loadRunsForJob(name);
|
await this.loadRunsForJob(name);
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadRunsForJob(name) {
|
async loadRunsForJob(name, showErrors = true) {
|
||||||
try {
|
try {
|
||||||
const data = await this.request(`${this.apiBase}/jobs/${encodeURIComponent(name)}/runs`);
|
const data = await this.request(`${this.apiBase}/jobs/${encodeURIComponent(name)}/runs`);
|
||||||
const job = this.jobs.find(item => item.name === name);
|
const job = this.jobs.find(item => item.name === name);
|
||||||
if (job) job.recent_runs = data.runs;
|
if (job) job.recent_runs = data.runs;
|
||||||
|
const maxPage = Math.max(0, Math.ceil(((data.runs || []).length) / this.recentRunsPerPage) - 1);
|
||||||
|
this.recentRunsPage = Math.min(this.recentRunsPage, maxPage);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.showToast(error.message);
|
if (showErrors) this.showToast(error.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadRunDetail(run) {
|
async loadRunDetail(run, options = {}) {
|
||||||
|
if (!run) return;
|
||||||
this.activeReview = null;
|
this.activeReview = null;
|
||||||
|
const previousJobName = this.activeJobName;
|
||||||
|
const preserveScroll = Boolean(options.preserveScroll);
|
||||||
|
const sameRun = this.activeRunDetail && Number(this.activeRunDetail.run.id) === Number(run.id);
|
||||||
|
const shouldFollow = !preserveScroll || !sameRun || this.runLogAutoScroll || this.isRunLogAtBottom();
|
||||||
try {
|
try {
|
||||||
this.activeRunDetail = await this.request(`${this.apiBase}/jobs/${encodeURIComponent(run.job_name)}/runs/${run.id}`);
|
this.activeRunDetail = await this.request(`${this.apiBase}/jobs/${encodeURIComponent(run.job_name)}/runs/${run.id}`);
|
||||||
this.activeJobName = run.job_name;
|
this.activeJobName = run.job_name;
|
||||||
|
if (previousJobName !== run.job_name) this.recentRunsPage = 0;
|
||||||
|
if (!preserveScroll || !sameRun) this.runLogAutoScroll = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if (shouldFollow) this.scrollRunLogToBottom(true);
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.showToast(error.message);
|
if (!options.silent) this.showToast(error.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async refreshActiveRunDetail() {
|
||||||
|
if (this.runLogRefreshing || !this.activeRunDetail || this.activeView !== 'jobs') return;
|
||||||
|
this.runLogRefreshing = true;
|
||||||
|
try {
|
||||||
|
await this.loadRunDetail(this.activeRunDetail.run, { preserveScroll: true, silent: true });
|
||||||
|
} finally {
|
||||||
|
this.runLogRefreshing = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleRunLogScroll() {
|
||||||
|
this.runLogAutoScroll = this.isRunLogAtBottom();
|
||||||
|
},
|
||||||
|
|
||||||
|
isRunLogAtBottom() {
|
||||||
|
const el = this.$refs.runLogOutput;
|
||||||
|
if (!el) return true;
|
||||||
|
return el.scrollHeight - el.scrollTop - el.clientHeight < 28;
|
||||||
|
},
|
||||||
|
|
||||||
|
scrollRunLogToBottom(force = false) {
|
||||||
|
const el = this.$refs.runLogOutput;
|
||||||
|
if (!el) return;
|
||||||
|
if (force || this.runLogAutoScroll) {
|
||||||
|
el.scrollTop = el.scrollHeight;
|
||||||
|
this.runLogAutoScroll = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
enableRunLogFollow() {
|
||||||
|
this.runLogAutoScroll = true;
|
||||||
|
this.$nextTick(() => this.scrollRunLogToBottom(true));
|
||||||
|
},
|
||||||
|
|
||||||
visibleRuns() {
|
visibleRuns() {
|
||||||
const job = this.activeJob;
|
const job = this.activeJob;
|
||||||
return job ? (job.recent_runs || []) : this.recentRuns;
|
return job ? (job.recent_runs || []) : this.recentRuns;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
pagedVisibleRuns() {
|
||||||
|
const runs = this.visibleRuns();
|
||||||
|
const start = this.recentRunsPage * this.recentRunsPerPage;
|
||||||
|
return runs.slice(start, start + this.recentRunsPerPage);
|
||||||
|
},
|
||||||
|
|
||||||
|
pageRecentRuns(delta) {
|
||||||
|
const maxPage = Math.max(0, Math.ceil(this.visibleRuns().length / this.recentRunsPerPage) - 1);
|
||||||
|
this.recentRunsPage = Math.min(maxPage, Math.max(0, this.recentRunsPage + delta));
|
||||||
|
},
|
||||||
|
|
||||||
|
recentRunsRangeText() {
|
||||||
|
const total = this.visibleRuns().length;
|
||||||
|
if (!total) return '0 runs';
|
||||||
|
const start = this.recentRunsPage * this.recentRunsPerPage + 1;
|
||||||
|
const end = Math.min((this.recentRunsPage + 1) * this.recentRunsPerPage, total);
|
||||||
|
return `${start}-${end} of ${total}`;
|
||||||
|
},
|
||||||
|
|
||||||
get activeJob() {
|
get activeJob() {
|
||||||
return this.jobs.find(job => job.name === this.activeJobName) || null;
|
return this.jobs.find(job => job.name === this.activeJobName) || null;
|
||||||
},
|
},
|
||||||
@@ -2725,6 +3036,48 @@ function adminV2() {
|
|||||||
return this.isArtistEditor() || this.isReleaseEditor();
|
return this.isArtistEditor() || this.isReleaseEditor();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
canShowMetadataTags() {
|
||||||
|
return this.isArtistEditor() || this.isReleaseEditor() || this.isTrackEditor();
|
||||||
|
},
|
||||||
|
|
||||||
|
metadataTags() {
|
||||||
|
return this.editorDetail && Array.isArray(this.editorDetail.metadata_tags)
|
||||||
|
? this.editorDetail.metadata_tags
|
||||||
|
: [];
|
||||||
|
},
|
||||||
|
|
||||||
|
metadataTagClass(tag) {
|
||||||
|
const source = String((tag && tag.source) || 'unknown').toLowerCase().replace(/_/g, '-');
|
||||||
|
return `metadata-${source}`;
|
||||||
|
},
|
||||||
|
|
||||||
|
metadataTagSourceLabel(tag) {
|
||||||
|
const source = String((tag && tag.source) || '').toLowerCase();
|
||||||
|
if (source === 'lastfm') return 'Last.fm';
|
||||||
|
if (source === 'file') return 'File';
|
||||||
|
if (source === 'review') return 'Review';
|
||||||
|
if (source === 'track_genre') return 'Track genre';
|
||||||
|
if (source === 'release_lastfm') return 'Release Last.fm';
|
||||||
|
if (source === 'release_file') return 'Release file';
|
||||||
|
if (source === 'release_review') return 'Release review';
|
||||||
|
return source || 'Source';
|
||||||
|
},
|
||||||
|
|
||||||
|
metadataTagScore(tag) {
|
||||||
|
const source = String((tag && tag.source) || '').toLowerCase();
|
||||||
|
const weight = Number((tag && tag.weight) || 0);
|
||||||
|
return (source === 'lastfm' || source === 'release_lastfm') && weight > 1 ? String(Math.round(weight)) : '';
|
||||||
|
},
|
||||||
|
|
||||||
|
metadataTagTitle(tag) {
|
||||||
|
if (!tag) return '';
|
||||||
|
const parts = [this.metadataTagSourceLabel(tag)];
|
||||||
|
const weight = Number(tag.weight || 0);
|
||||||
|
if (weight > 0) parts.push(`weight ${Math.round(weight)}`);
|
||||||
|
if (tag.updated_at) parts.push(tag.updated_at);
|
||||||
|
return parts.join(' / ');
|
||||||
|
},
|
||||||
|
|
||||||
editorCanSave() {
|
editorCanSave() {
|
||||||
if (!this.activeLibraryItem || !this.editorDetail || this.editorLoading || this.editorSaving) return false;
|
if (!this.activeLibraryItem || !this.editorDetail || this.editorLoading || this.editorSaving) return false;
|
||||||
if (this.isTrackEditor() && !this.editorDraft.release_id) return false;
|
if (this.isTrackEditor() && !this.editorDraft.release_id) return false;
|
||||||
@@ -3086,21 +3439,9 @@ function adminV2() {
|
|||||||
return `${start}-${end} of ${this.fmt(this.library.total)}`;
|
return `${start}-${end} of ${this.fmt(this.library.total)}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
pagedJobs() {
|
cronLabel(job) {
|
||||||
const start = this.jobsPage * this.jobsPerPage;
|
const value = job && job.cron_expression ? String(job.cron_expression).trim() : '';
|
||||||
return this.jobs.slice(start, start + this.jobsPerPage);
|
return value || 'manual only';
|
||||||
},
|
|
||||||
|
|
||||||
pageJobs(delta) {
|
|
||||||
const maxPage = Math.max(0, Math.ceil(this.jobs.length / this.jobsPerPage) - 1);
|
|
||||||
this.jobsPage = Math.min(maxPage, Math.max(0, this.jobsPage + delta));
|
|
||||||
},
|
|
||||||
|
|
||||||
jobsRangeText() {
|
|
||||||
if (!this.jobs.length) return '0 tasks';
|
|
||||||
const start = this.jobsPage * this.jobsPerPage + 1;
|
|
||||||
const end = Math.min((this.jobsPage + 1) * this.jobsPerPage, this.jobs.length);
|
|
||||||
return `${start}-${end} of ${this.jobs.length}`;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
statusCount(status) {
|
statusCount(status) {
|
||||||
@@ -3118,8 +3459,7 @@ function adminV2() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
runChipLabel(run) {
|
runChipLabel(run) {
|
||||||
const duration = run.duration_ms || run.duration_ms === 0 ? this.duration(run.duration_ms) : this.relativeDate(run.started_at);
|
return `#${run.id}`;
|
||||||
return `#${run.id} · ${duration}`;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
runTitle(run) {
|
runTitle(run) {
|
||||||
|
|||||||
@@ -11,6 +11,13 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="info-actions" x-show="$store.info.modal.actions && $store.info.modal.actions.length">
|
||||||
|
<template x-for="(action, idx) in $store.info.modal.actions" :key="action.label + '-' + idx">
|
||||||
|
<button class="info-action-btn" type="button" @click.stop.prevent="$store.info.runAction(idx)" :disabled="action.busy === true">
|
||||||
|
<span x-text="action.busy ? '{{ t.player_resolving }}' : action.label"></span>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
<div class="info-modal-body">
|
<div class="info-modal-body">
|
||||||
<template x-if="$store.info.modal.rows && $store.info.modal.rows.length">
|
<template x-if="$store.info.modal.rows && $store.info.modal.rows.length">
|
||||||
<table class="info-table">
|
<table class="info-table">
|
||||||
@@ -606,25 +613,93 @@
|
|||||||
<template x-if="$store.history.modal">
|
<template x-if="$store.history.modal">
|
||||||
<div class="modal-overlay" @click.self="$store.history.close()">
|
<div class="modal-overlay" @click.self="$store.history.close()">
|
||||||
<div class="modal-box history-modal">
|
<div class="modal-box history-modal">
|
||||||
<h3>{{ t.player_play_history }}</h3>
|
<div class="history-head">
|
||||||
<p class="torrent-message" :class="{ error: $store.history.error }"
|
<div>
|
||||||
x-text="$store.history.message"></p>
|
<h3>{{ t.player_play_history }}</h3>
|
||||||
|
<p class="torrent-message" :class="{ error: $store.history.error }"
|
||||||
|
x-text="$store.history.message"></p>
|
||||||
|
</div>
|
||||||
|
<button class="mobile-list-action" @click="$store.history.close()" title="{{ t.player_close }}">
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||||
|
<line x1="18" y1="6" x2="6" y2="18"/>
|
||||||
|
<line x1="6" y1="6" x2="18" y2="18"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<div class="history-list">
|
<div class="history-list">
|
||||||
<template x-if="!$store.history.loading && $store.history.items.length === 0">
|
<template x-if="!$store.history.loading && $store.history.items.length === 0">
|
||||||
<div class="empty-state" style="padding:32px 16px">
|
<div class="empty-state" style="padding:32px 16px">
|
||||||
<p>{{ t.player_no_plays_yet }}</p>
|
<p>{{ t.player_no_plays_yet }}</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template x-for="item in $store.history.items" :key="item.id">
|
<template x-if="$store.history.items.length > 0">
|
||||||
<div class="history-row">
|
<div class="history-table-head">
|
||||||
<div style="min-width:0">
|
<span></span>
|
||||||
<div class="history-title" x-text="item.track_title"></div>
|
<span>{{ t.player_title }}</span>
|
||||||
<div class="history-release" x-text="item.release_title || '{{ t.player_unknown_release }}'"></div>
|
<span>{{ t.player_played_at }}</span>
|
||||||
|
<span></span>
|
||||||
|
<span style="text-align:right">{{ t.player_listened }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template x-for="(item, idx) in $store.history.items" :key="item.id">
|
||||||
|
<div class="history-row track-row"
|
||||||
|
:class="{ playing: $store.player.currentTrack && item.track && $store.player.currentTrack.id === item.track.id }"
|
||||||
|
@dblclick="$store.history.playFrom(idx)">
|
||||||
|
<button class="history-cover"
|
||||||
|
@click.stop="$store.history.playFrom(idx)"
|
||||||
|
:title="item.track?.title || item.track_title">
|
||||||
|
<template x-if="item.track && item.track.cover_url">
|
||||||
|
<img :src="item.track.cover_url" :alt="item.track.title" loading="lazy">
|
||||||
|
</template>
|
||||||
|
<template x-if="!item.track || !item.track.cover_url">
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="12" cy="12" r="4"/></svg>
|
||||||
|
</template>
|
||||||
|
</button>
|
||||||
|
<div class="track-info">
|
||||||
|
<div class="track-title" x-text="item.track?.title || item.track_title"></div>
|
||||||
|
<div class="track-artists-inline">
|
||||||
|
<template x-for="(artist, artistIdx) in $store.library.trackArtistLinks(item.track)" :key="artist.label + '-' + artist.id + '-' + artistIdx">
|
||||||
|
<span>
|
||||||
|
<template x-if="artistIdx > 0"><span>, </span></template>
|
||||||
|
<a class="artist-link" @click.stop="$store.history.close(); $store.library.openArtist(artist.id)" x-text="artist.label"></a>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template x-if="!item.track || !$store.library.trackArtistLinks(item.track).length">
|
||||||
|
<span x-text="item.release_title || '{{ t.player_unknown_release }}'"></span>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div class="history-release-line">
|
||||||
|
<a class="artist-link"
|
||||||
|
x-show="item.track && item.track.release_id"
|
||||||
|
@click.stop="$store.history.close(); $store.library.openRelease(item.track.release_id)"
|
||||||
|
x-text="item.track?.release_title || item.release_title || '{{ t.player_unknown_release }}'"></a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="history-date" x-text="$store.history.date(item.played_at)"></div>
|
||||||
<div class="history-date" x-text="$store.history.date(item.played_at)"></div>
|
<div class="track-actions">
|
||||||
<div class="history-duration" x-text="$store.history.duration(item.duration_listened)"></div>
|
<button class="track-action-btn info-btn popularity-info-btn"
|
||||||
|
:class="{ 'has-popularity': $store.library.hasPopularity(item.track), 'no-popularity': !$store.library.hasPopularity(item.track) }"
|
||||||
|
:style="$store.library.popularityStyle(item.track)"
|
||||||
|
@click.stop="$store.library.openTrackInfo(item.track)"
|
||||||
|
:title="$store.library.trackInfoTitle(item.track)"
|
||||||
|
aria-label="{{ t.player_track_info }}">
|
||||||
|
<span x-show="$store.library.hasPopularity(item.track)" x-text="$store.library.popularityLabel(item.track)"></span>
|
||||||
|
<span x-show="!$store.library.hasPopularity(item.track)" class="info-letter">i</span>
|
||||||
|
</button>
|
||||||
|
<button class="like-btn" :class="{ liked: $store.likes.has(item.track_id) }" @click.stop="$store.likes.toggle(item.track_id)" title="{{ t.player_like }}">
|
||||||
|
<svg viewBox="0 0 24 24" :fill="$store.likes.has(item.track_id) ? 'currentColor' : 'none'" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78L12 21.23l8.84-8.84a5.5 5.5 0 000-7.78z"/></svg>
|
||||||
|
</button>
|
||||||
|
<button class="track-action-btn queue-insert-btn queue-next-btn" @click.stop="$store.queue.addNextInQueue([item.track])" title="{{ t.player_play_next }}">
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 6h10M5 12h7M5 18h10"/><path d="M17 9l4 3-4 3" fill="currentColor" stroke="none"/></svg>
|
||||||
|
</button>
|
||||||
|
<button class="track-action-btn queue-insert-btn queue-end-btn" @click.stop="$store.queue.addToEnd([item.track])" title="{{ t.player_add_to_queue }}">
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 6h14M5 12h14M5 18h7"/><path d="M17 15l4 3-4 3" fill="currentColor" stroke="none"/></svg>
|
||||||
|
</button>
|
||||||
|
<button class="track-action-btn playlist-add-btn" @click.stop="$store.playlists.showPicker([item.track_id])" title="{{ t.player_add_to_playlist }}">
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"/></svg>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<span class="history-duration" x-text="$store.history.duration(item.duration_listened)"></span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ const T = {
|
|||||||
lastfmDisconnectConfirm: "{{ t.player_lastfm_disconnect_confirm }}",
|
lastfmDisconnectConfirm: "{{ t.player_lastfm_disconnect_confirm }}",
|
||||||
lastfmConnectFailed: "{{ t.player_lastfm_connect_failed }}",
|
lastfmConnectFailed: "{{ t.player_lastfm_connect_failed }}",
|
||||||
lastfmDisconnectFailed: "{{ t.player_lastfm_disconnect_failed }}",
|
lastfmDisconnectFailed: "{{ t.player_lastfm_disconnect_failed }}",
|
||||||
|
startRadio: "{{ t.player_start_radio }}",
|
||||||
|
radioFailed: "{{ t.player_radio_failed }}",
|
||||||
connectionLost: "{{ t.player_connection_lost }}",
|
connectionLost: "{{ t.player_connection_lost }}",
|
||||||
connectionLostDetail: "{{ t.player_connection_lost_detail }}",
|
connectionLostDetail: "{{ t.player_connection_lost_detail }}",
|
||||||
trackWord: "{{ t.player_tracks_count }}",
|
trackWord: "{{ t.player_tracks_count }}",
|
||||||
@@ -304,27 +306,46 @@ document.addEventListener('alpine:init', () => {
|
|||||||
|
|
||||||
Alpine.store('info', {
|
Alpine.store('info', {
|
||||||
modal: null,
|
modal: null,
|
||||||
open(title, body) {
|
open(title, body, actions = []) {
|
||||||
if (Array.isArray(body)) {
|
if (Array.isArray(body)) {
|
||||||
this.openRows(title, body);
|
this.openRows(title, body, actions);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.modal = {
|
this.modal = {
|
||||||
title: title || T.info,
|
title: title || T.info,
|
||||||
body: body || T.noDetails,
|
body: body || T.noDetails,
|
||||||
rows: null,
|
rows: null,
|
||||||
|
actions: actions || [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
openRows(title, rows) {
|
openRows(title, rows, actions = []) {
|
||||||
this.modal = {
|
this.modal = {
|
||||||
title: title || T.info,
|
title: title || T.info,
|
||||||
body: '',
|
body: '',
|
||||||
rows: (rows || []).filter(row => row && ((row.value !== undefined && row.value !== null && row.value !== '') || (row.links && row.links.length))),
|
rows: (rows || []).filter(row => row && ((row.value !== undefined && row.value !== null && row.value !== '') || (row.links && row.links.length))),
|
||||||
|
actions: actions || [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
close() {
|
close() {
|
||||||
this.modal = null;
|
this.modal = null;
|
||||||
},
|
},
|
||||||
|
async runAction(actionOrIndex) {
|
||||||
|
const index = Number.isInteger(actionOrIndex) ? actionOrIndex : this.modal?.actions?.indexOf(actionOrIndex);
|
||||||
|
const action = index >= 0 ? this.modal?.actions?.[index] : actionOrIndex;
|
||||||
|
if (!action || action.busy === true || typeof action.run !== 'function') return;
|
||||||
|
if (index >= 0 && this.modal?.actions) {
|
||||||
|
this.modal.actions[index] = { ...action, busy: true };
|
||||||
|
this.modal.actions = [...this.modal.actions];
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await action.run();
|
||||||
|
} finally {
|
||||||
|
if (index >= 0 && this.modal?.actions?.[index]) {
|
||||||
|
this.modal.actions[index] = { ...this.modal.actions[index], busy: false };
|
||||||
|
this.modal.actions = [...this.modal.actions];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
navigate(link) {
|
navigate(link) {
|
||||||
if (!link || !link.id) return;
|
if (!link || !link.id) return;
|
||||||
this.close();
|
this.close();
|
||||||
@@ -488,6 +509,16 @@ document.addEventListener('alpine:init', () => {
|
|||||||
return Math.max(1, Math.ceil(this.total / this.perPage));
|
return Math.max(1, Math.ceil(this.total / this.perPage));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
tracks() {
|
||||||
|
return (this.items || []).map(item => item.track).filter(Boolean);
|
||||||
|
},
|
||||||
|
|
||||||
|
playFrom(index) {
|
||||||
|
const tracks = this.tracks();
|
||||||
|
if (!tracks.length || index < 0 || index >= tracks.length) return;
|
||||||
|
Alpine.store('queue').playRelease(tracks, index);
|
||||||
|
},
|
||||||
|
|
||||||
async load(page) {
|
async load(page) {
|
||||||
page = Math.max(1, page || 1);
|
page = Math.max(1, page || 1);
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@@ -2117,8 +2148,25 @@ document.addEventListener('alpine:init', () => {
|
|||||||
return `${T.lastfmRating}: ${Math.round(value)}\n${this.trackInfo(track)}`;
|
return `${T.lastfmRating}: ${Math.round(value)}\n${this.trackInfo(track)}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async startRadio(kind, id) {
|
||||||
|
if (!kind || !id) return;
|
||||||
|
try {
|
||||||
|
const res = await fetch(`/api/player/radio/${encodeURIComponent(kind)}/${encodeURIComponent(id)}`);
|
||||||
|
if (!res.ok) throw new Error('radio failed');
|
||||||
|
const tracks = await res.json();
|
||||||
|
if (!Array.isArray(tracks) || tracks.length === 0) throw new Error('radio empty');
|
||||||
|
Alpine.store('queue').playRelease(tracks, 0);
|
||||||
|
Alpine.store('info').close();
|
||||||
|
} catch (err) {
|
||||||
|
console.warn(err);
|
||||||
|
window.alert(T.radioFailed);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
openTrackInfo(track) {
|
openTrackInfo(track) {
|
||||||
Alpine.store('info').openRows(T.trackInfoTitle, this.trackInfoRows(track));
|
Alpine.store('info').openRows(T.trackInfoTitle, this.trackInfoRows(track), [
|
||||||
|
{ label: T.startRadio, run: () => this.startRadio('track', track?.id) },
|
||||||
|
]);
|
||||||
},
|
},
|
||||||
|
|
||||||
uploadersInfo(uploaders) {
|
uploadersInfo(uploaders) {
|
||||||
@@ -2142,7 +2190,9 @@ document.addEventListener('alpine:init', () => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
openReleaseInfo(release) {
|
openReleaseInfo(release) {
|
||||||
Alpine.store('info').openRows(T.releaseInfoTitle, this.releaseInfoRows(release));
|
Alpine.store('info').openRows(T.releaseInfoTitle, this.releaseInfoRows(release), [
|
||||||
|
{ label: T.startRadio, run: () => this.startRadio('release', release?.id) },
|
||||||
|
]);
|
||||||
},
|
},
|
||||||
|
|
||||||
infoLinks(items, type) {
|
infoLinks(items, type) {
|
||||||
@@ -2230,6 +2280,12 @@ document.addEventListener('alpine:init', () => {
|
|||||||
return rows;
|
return rows;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
playArtistTopTracks() {
|
||||||
|
const tracks = this.currentArtist?.top_tracks || [];
|
||||||
|
if (!tracks.length) return;
|
||||||
|
Alpine.store('queue').playRelease(tracks, 0);
|
||||||
|
},
|
||||||
|
|
||||||
async openRelease(id, options = {}) {
|
async openRelease(id, options = {}) {
|
||||||
this._beginNavigation('#release/' + id, options);
|
this._beginNavigation('#release/' + id, options);
|
||||||
this.searchQuery = '';
|
this.searchQuery = '';
|
||||||
|
|||||||
@@ -570,8 +570,17 @@
|
|||||||
<span>•</span>
|
<span>•</span>
|
||||||
<span x-text="$store.library.currentArtist.total_play_count + ' {{ t.player_plays_count }}'"></span>
|
<span x-text="$store.library.currentArtist.total_play_count + ' {{ t.player_plays_count }}'"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="release-actions">
|
<div class="release-actions artist-actions">
|
||||||
<button class="release-action-btn secondary"
|
<button class="release-action-btn primary artist-listen-action"
|
||||||
|
:disabled="!($store.library.currentArtist.top_tracks && $store.library.currentArtist.top_tracks.length)"
|
||||||
|
@click="$store.library.playArtistTopTracks()"
|
||||||
|
title="{{ t.player_listen_artist }}">
|
||||||
|
<svg viewBox="0 0 24 24" fill="currentColor" stroke="none">
|
||||||
|
<path d="M8 5v14l11-7z"/>
|
||||||
|
</svg>
|
||||||
|
<span>{{ t.player_listen }}</span>
|
||||||
|
</button>
|
||||||
|
<button class="release-action-btn secondary artist-follow-action"
|
||||||
:class="{ followed: $store.follows.has($store.library.currentArtist.id) }"
|
:class="{ followed: $store.follows.has($store.library.currentArtist.id) }"
|
||||||
@click="$store.follows.toggle($store.library.currentArtist.id)"
|
@click="$store.follows.toggle($store.library.currentArtist.id)"
|
||||||
:title="$store.follows.has($store.library.currentArtist.id) ? '{{ t.player_unfollow_artist }}' : '{{ t.player_follow_artist }}'">
|
:title="$store.follows.has($store.library.currentArtist.id) ? '{{ t.player_unfollow_artist }}' : '{{ t.player_follow_artist }}'">
|
||||||
|
|||||||
+211
-15
@@ -911,6 +911,12 @@ button.user-stat:hover {
|
|||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.release-action-btn:disabled {
|
||||||
|
opacity: 0.45;
|
||||||
|
cursor: default;
|
||||||
|
filter: grayscale(0.4);
|
||||||
|
}
|
||||||
|
|
||||||
.release-action-btn.secondary {
|
.release-action-btn.secondary {
|
||||||
background: var(--bg-active);
|
background: var(--bg-active);
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
@@ -921,6 +927,29 @@ button.user-stat:hover {
|
|||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.artist-actions {
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.artist-listen-action {
|
||||||
|
min-width: 112px;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.artist-follow-action,
|
||||||
|
.artist-follow-action.followed {
|
||||||
|
background: var(--bg-active);
|
||||||
|
color: var(--text-secondary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.artist-follow-action:hover,
|
||||||
|
.artist-follow-action.followed:hover {
|
||||||
|
color: var(--text-primary);
|
||||||
|
border-color: var(--text-subdued);
|
||||||
|
}
|
||||||
|
|
||||||
.artist-follow-card-btn {
|
.artist-follow-card-btn {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 8px;
|
bottom: 8px;
|
||||||
@@ -2212,6 +2241,46 @@ button.user-stat:hover {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.info-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin: -4px 0 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-action-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 38px;
|
||||||
|
padding: 9px 15px;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--accent);
|
||||||
|
color: #061307;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 800;
|
||||||
|
cursor: pointer;
|
||||||
|
box-shadow: 0 8px 22px rgba(29, 185, 84, 0.2);
|
||||||
|
transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-action-btn:hover {
|
||||||
|
background: var(--accent-hover);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 10px 26px rgba(29, 185, 84, 0.28);
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-action-btn:disabled {
|
||||||
|
opacity: 0.7;
|
||||||
|
cursor: default;
|
||||||
|
transform: none;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
.info-modal-body {
|
.info-modal-body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 14px;
|
padding: 14px;
|
||||||
@@ -2714,36 +2783,87 @@ button.user-stat:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.history-modal {
|
.history-modal {
|
||||||
width: min(620px, calc(100vw - 32px));
|
width: min(980px, calc(100vw - 32px));
|
||||||
max-width: 620px;
|
max-width: 980px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.history-list {
|
.history-list {
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
max-height: min(54vh, 460px);
|
max-height: min(54vh, 460px);
|
||||||
border: 1px solid var(--border-color);
|
border-top: 1px solid var(--border-color);
|
||||||
border-radius: 8px;
|
border-bottom: 1px solid var(--border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.history-row {
|
.history-table-head,
|
||||||
|
.history-row.track-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: minmax(0, 1fr) auto;
|
grid-template-columns: 48px minmax(0, 1fr) 144px 154px 72px;
|
||||||
gap: 8px 12px;
|
align-items: center;
|
||||||
padding: 10px 12px;
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-table-head {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 3;
|
||||||
|
padding: 8px 12px;
|
||||||
|
background: var(--bg-elevated);
|
||||||
|
color: var(--text-subdued);
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 800;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-row.track-row {
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 0;
|
||||||
border-bottom: 1px solid var(--border-color);
|
border-bottom: 1px solid var(--border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.history-row:last-child { border-bottom: 0; }
|
.history-row:last-child { border-bottom: 0; }
|
||||||
|
|
||||||
.history-title {
|
.history-cover {
|
||||||
min-width: 0;
|
width: 40px;
|
||||||
color: var(--text-primary);
|
height: 40px;
|
||||||
font-size: 13px;
|
padding: 0;
|
||||||
font-weight: 700;
|
border: 0;
|
||||||
|
border-radius: 5px;
|
||||||
|
background: var(--bg-active);
|
||||||
|
color: var(--text-subdued);
|
||||||
|
overflow: hidden;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-cover img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-cover svg {
|
||||||
|
width: 21px;
|
||||||
|
height: 21px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-release-line {
|
||||||
|
margin-top: 2px;
|
||||||
|
color: var(--text-subdued);
|
||||||
|
font-size: 12px;
|
||||||
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.history-release,
|
.history-release,
|
||||||
@@ -2751,14 +2871,16 @@ button.user-stat:hover {
|
|||||||
.history-duration {
|
.history-duration {
|
||||||
color: var(--text-subdued);
|
color: var(--text-subdued);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
line-height: 1.35;
|
||||||
}
|
}
|
||||||
|
|
||||||
.history-date,
|
.history-date,
|
||||||
.history-duration {
|
.history-duration {
|
||||||
text-align: right;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.history-duration { text-align: right; }
|
||||||
|
|
||||||
.history-pager {
|
.history-pager {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -3678,6 +3800,44 @@ button.user-stat:hover {
|
|||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.history-table-head,
|
||||||
|
.history-row.track-row {
|
||||||
|
grid-template-columns: 44px minmax(0, 1fr) auto;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-table-head {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-row.track-row {
|
||||||
|
padding: 9px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-row .history-cover {
|
||||||
|
grid-row: 1 / span 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-row .track-info {
|
||||||
|
grid-column: 2;
|
||||||
|
grid-row: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-row .history-date {
|
||||||
|
grid-column: 2;
|
||||||
|
grid-row: 2;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-row .track-actions {
|
||||||
|
grid-column: 3;
|
||||||
|
grid-row: 1 / span 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-duration {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.queue-panel {
|
.queue-panel {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
left: 12px;
|
left: 12px;
|
||||||
@@ -4478,6 +4638,42 @@ button.user-stat:hover {
|
|||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.history-list {
|
||||||
|
max-height: min(60dvh, 520px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-row.track-row {
|
||||||
|
grid-template-columns: 42px minmax(0, 1fr) auto;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 9px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-cover {
|
||||||
|
width: 38px;
|
||||||
|
height: 38px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-row .track-actions {
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-row .track-actions .track-action-btn,
|
||||||
|
.history-row .track-actions .like-btn {
|
||||||
|
width: 26px;
|
||||||
|
height: 26px;
|
||||||
|
flex-basis: 26px;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-row .track-actions .popularity-info-btn {
|
||||||
|
min-width: 24px;
|
||||||
|
padding: 0 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-release-line {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.info-table th,
|
.info-table th,
|
||||||
.info-table td {
|
.info-table td {
|
||||||
display: block;
|
display: block;
|
||||||
|
|||||||
Reference in New Issue
Block a user