scene: stagedirection: switch to a generic playlist name based interface to mixxx, instead of PWM episode numbers
This commit is contained in:
+5
-11
@@ -16,7 +16,7 @@ const SYSTEM_PROMPT: &str = include_str!("system-prompt.txt");
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum PredictionAction {
|
pub enum PredictionAction {
|
||||||
ConversationAppend(ConversationEntry),
|
ConversationAppend(ConversationEntry),
|
||||||
SetEpisodeNumber(u32),
|
SetPlaylist(String),
|
||||||
GeneratePredictions,
|
GeneratePredictions,
|
||||||
SetNarrative(String),
|
SetNarrative(String),
|
||||||
SetShowEndTime(DateTime<Utc>)
|
SetShowEndTime(DateTime<Utc>)
|
||||||
@@ -417,19 +417,13 @@ pub async fn start_prediction(saved_session: SaveData, mut messages: tokio::sync
|
|||||||
|
|
||||||
do_regen
|
do_regen
|
||||||
},
|
},
|
||||||
PredictionAction::SetEpisodeNumber(num) => {
|
PredictionAction::SetPlaylist(playlist_name) => {
|
||||||
session.direction.episode_number = num;
|
match MixxxDB::load(&playlist_name) {
|
||||||
match MixxxDB::load(num) {
|
|
||||||
Err(err) => log::info!("Failed to load mixxx playlist: {:?}.", err),
|
Err(err) => log::info!("Failed to load mixxx playlist: {:?}.", err),
|
||||||
Ok(playlist) => {
|
Ok(playlist) => {
|
||||||
for track in &playlist {
|
session.scenery.artifacts.merge(playlist.clone());
|
||||||
if let Some(merge_target) = session.scenery.artifacts.iter_mut().find(|a| { *a == track }) {
|
|
||||||
merge_target.merge(track.clone());
|
|
||||||
} else {
|
|
||||||
session.scenery.artifacts.push(track.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
session.scenery.current_playlist = playlist;
|
session.scenery.current_playlist = playlist;
|
||||||
|
session.direction.playlist = playlist_name;
|
||||||
log::info!("Mixxx playlist reloaded.");
|
log::info!("Mixxx playlist reloaded.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ pub mod conversation;
|
|||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct StageDirection {
|
pub struct StageDirection {
|
||||||
pub episode_number: u32,
|
pub playlist: String,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
#[serde(default="StageDirection::default_end_time")]
|
#[serde(default="StageDirection::default_end_time")]
|
||||||
pub end_time: DateTime<Utc>,
|
pub end_time: DateTime<Utc>,
|
||||||
@@ -27,7 +27,7 @@ impl StageDirection {
|
|||||||
impl Default for StageDirection {
|
impl Default for StageDirection {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
episode_number: 0,
|
playlist: Default::default(),
|
||||||
end_time: Self::default_end_time(),
|
end_time: Self::default_end_time(),
|
||||||
narrative: Default::default(),
|
narrative: Default::default(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,13 +145,17 @@ impl Ui {
|
|||||||
match command {
|
match command {
|
||||||
// FIXME: Need some new kind of /bandcamp command to force loading of specific urls
|
// FIXME: Need some new kind of /bandcamp command to force loading of specific urls
|
||||||
"/episode" => {
|
"/episode" => {
|
||||||
if let Ok(episode_number) = arg.trim().parse() {
|
if let Ok(episode_number) = arg.trim().parse::<u32>() {
|
||||||
self.predictions.insert(PredictionAction::SetEpisodeNumber(episode_number)).await;
|
let playlist_name = format!("BFF.fm - Episode {}", episode_number);
|
||||||
|
self.predictions.insert(PredictionAction::SetPlaylist(playlist_name)).await;
|
||||||
} else {
|
} else {
|
||||||
log::error!("Invalid episode number format. Use /episode [number]");
|
log::error!("Invalid episode number format. Use /episode [number]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/playlist" => {
|
||||||
|
self.predictions.insert(PredictionAction::SetPlaylist(arg.trim().to_string())).await;
|
||||||
|
}
|
||||||
"/timer" => {
|
"/timer" => {
|
||||||
if let Ok(minutes) = arg.trim().parse::<i64>() {
|
if let Ok(minutes) = arg.trim().parse::<i64>() {
|
||||||
let end_time = Utc::now() + Duration::minutes(minutes);
|
let end_time = Utc::now() + Duration::minutes(minutes);
|
||||||
|
|||||||
+1
-1
@@ -173,7 +173,7 @@ impl Widget for StatusBar<'_> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let status_line = Line::from_iter([
|
let status_line = Line::from_iter([
|
||||||
Span::from(format!("Episode {}", self.0.direction().episode_number)).style(ratatui::style::Color::LightBlue),
|
Span::from(format!("Playlist: {}", self.0.direction().playlist)).style(ratatui::style::Color::LightBlue),
|
||||||
Span::from(" | ").style(ratatui::style::Color::DarkGray),
|
Span::from(" | ").style(ratatui::style::Color::DarkGray),
|
||||||
Span::from(format!("{} tracks", self.0.scenery().current_playlist.len())).style(ratatui::style::Color::LightBlue),
|
Span::from(format!("{} tracks", self.0.scenery().current_playlist.len())).style(ratatui::style::Color::LightBlue),
|
||||||
Span::from(" | ").style(ratatui::style::Color::DarkGray),
|
Span::from(" | ").style(ratatui::style::Color::DarkGray),
|
||||||
|
|||||||
Reference in New Issue
Block a user