fix playlist routes, add version debug log

This commit is contained in:
jb-alvarado 2024-06-25 17:11:33 +02:00
parent 14f1a18b5b
commit e34562d31e
4 changed files with 20 additions and 14 deletions

4
Cargo.lock generated
View File

@ -1061,7 +1061,7 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
[[package]] [[package]]
name = "ffplayout" name = "ffplayout"
version = "0.24.0-beta1" version = "0.24.0-alpha1"
dependencies = [ dependencies = [
"actix-files", "actix-files",
"actix-multipart", "actix-multipart",
@ -3336,7 +3336,7 @@ dependencies = [
[[package]] [[package]]
name = "tests" name = "tests"
version = "0.24.0-beta1" version = "0.24.0-alpha1"
dependencies = [ dependencies = [
"chrono", "chrono",
"crossbeam-channel", "crossbeam-channel",

View File

@ -4,7 +4,7 @@ default-members = ["ffplayout", "tests"]
resolver = "2" resolver = "2"
[workspace.package] [workspace.package]
version = "0.24.0-beta1" version = "0.24.0-alpha1"
license = "GPL-3.0" license = "GPL-3.0"
repository = "https://github.com/ffplayout/ffplayout" repository = "https://github.com/ffplayout/ffplayout"
authors = ["Jonathan Baecker <jonbae77@gmail.com>"] authors = ["Jonathan Baecker <jonbae77@gmail.com>"]

View File

@ -1016,18 +1016,17 @@ pub async fn save_playlist(
#[protect( #[protect(
any("Role::GlobalAdmin", "Role::ChannelAdmin", "Role::User"), any("Role::GlobalAdmin", "Role::ChannelAdmin", "Role::User"),
ty = "Role", ty = "Role",
expr = "user.channels.contains(&*id) || role.has_authority(&Role::GlobalAdmin)" expr = "user.channels.contains(&params.0) || role.has_authority(&Role::GlobalAdmin)"
)] )]
pub async fn gen_playlist( pub async fn gen_playlist(
id: web::Path<i32>, params: web::Path<(i32, String)>,
date: web::Path<String>,
data: Option<web::Json<PathsObj>>, data: Option<web::Json<PathsObj>>,
controllers: web::Data<Mutex<ChannelController>>, controllers: web::Data<Mutex<ChannelController>>,
role: AuthDetails<Role>, role: AuthDetails<Role>,
user: web::ReqData<UserMeta>, user: web::ReqData<UserMeta>,
) -> Result<impl Responder, ServiceError> { ) -> Result<impl Responder, ServiceError> {
let manager = controllers.lock().unwrap().get(*id).unwrap(); let manager = controllers.lock().unwrap().get(params.0).unwrap();
manager.config.lock().unwrap().general.generate = Some(vec![date.clone()]); manager.config.lock().unwrap().general.generate = Some(vec![params.1.clone()]);
let storage_path = manager.config.lock().unwrap().global.storage_path.clone(); let storage_path = manager.config.lock().unwrap().global.storage_path.clone();
if let Some(obj) = data { if let Some(obj) = data {
@ -1068,19 +1067,18 @@ pub async fn gen_playlist(
#[protect( #[protect(
any("Role::GlobalAdmin", "Role::ChannelAdmin", "Role::User"), any("Role::GlobalAdmin", "Role::ChannelAdmin", "Role::User"),
ty = "Role", ty = "Role",
expr = "user.channels.contains(&*id) || role.has_authority(&Role::GlobalAdmin)" expr = "user.channels.contains(&params.0) || role.has_authority(&Role::GlobalAdmin)"
)] )]
pub async fn del_playlist( pub async fn del_playlist(
id: web::Path<i32>, params: web::Path<(i32, String)>,
date: web::Path<String>,
controllers: web::Data<Mutex<ChannelController>>, controllers: web::Data<Mutex<ChannelController>>,
role: AuthDetails<Role>, role: AuthDetails<Role>,
user: web::ReqData<UserMeta>, user: web::ReqData<UserMeta>,
) -> Result<impl Responder, ServiceError> { ) -> Result<impl Responder, ServiceError> {
let manager = controllers.lock().unwrap().get(*id).unwrap(); let manager = controllers.lock().unwrap().get(params.0).unwrap();
let config = manager.config.lock().unwrap().clone(); let config = manager.config.lock().unwrap().clone();
match delete_playlist(&config, &date).await { match delete_playlist(&config, &params.1).await {
Ok(m) => Ok(web::Json(m)), Ok(m) => Ok(web::Json(m)),
Err(e) => Err(e), Err(e) => Err(e),
} }

View File

@ -15,7 +15,6 @@ use log::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sqlx::{Pool, Sqlite}; use sqlx::{Pool, Sqlite};
use crate::db::{handles, models::Channel};
use crate::player::{ use crate::player::{
output::{player, write_hls}, output::{player, write_hls},
utils::{folder::fill_filler_list, Media}, utils::{folder::fill_filler_list, Media},
@ -25,6 +24,12 @@ use crate::utils::{
errors::ProcessError, errors::ProcessError,
}; };
use crate::ARGS; use crate::ARGS;
use crate::{
db::{handles, models::Channel},
utils::logging::Target,
};
const VERSION: &str = env!("CARGO_PKG_VERSION");
/// Defined process units. /// Defined process units.
#[derive(Clone, Debug, Default, Copy, Eq, Serialize, Deserialize, PartialEq)] #[derive(Clone, Debug, Default, Copy, Eq, Serialize, Deserialize, PartialEq)]
@ -323,6 +328,9 @@ pub fn start_channel(manager: ChannelManager) -> Result<(), ProcessError> {
let config = manager.config.lock()?.clone(); let config = manager.config.lock()?.clone();
let mode = config.output.mode.clone(); let mode = config.output.mode.clone();
let filler_list = manager.filler_list.clone(); let filler_list = manager.filler_list.clone();
let channel_id = config.general.channel_id;
debug!(target: Target::all(), channel = channel_id; "Start ffplayout v{VERSION}, channel: <yellow>{channel_id}</>");
// Fill filler list, can also be a single file. // Fill filler list, can also be a single file.
thread::spawn(move || { thread::spawn(move || {