mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-10 12:01:36 +00:00
live portrait metadata in media files batch get endpoint
This commit is contained in:
1 parent
98b999121a
commit
393ef4ff27
2 files changed
+23
No files matched your search
@@ -25,6 +25,7 @@ use tokens::tokens::prompts::PromptToken;
|
||||
use tokens::tokens::users::UserToken;
|
||||
use tokens::traits::mysql_token_from_row::MySqlTokenFromRow;
|
||||
|
||||
use crate::payloads::media_file_extra_info::media_file_extra_info::MediaFileExtraInfo;
|
||||
use crate::payloads::prompt_args::prompt_inner_payload::PromptInnerPayload;
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
@@ -81,6 +82,10 @@ pub struct MediaFile {
|
||||
pub maybe_model_weight_creator_display_name: Option<String>,
|
||||
pub maybe_model_weight_creator_gravatar_hash: Option<String>,
|
||||
|
||||
/// Not all files have extra info.
|
||||
/// This is a polymorphic JSON blob that gets hydrated into structs.
|
||||
pub extra_media_file_info: Option<MediaFileExtraInfo>,
|
||||
|
||||
pub public_bucket_directory_hash: String,
|
||||
pub maybe_public_bucket_prefix: Option<String>,
|
||||
pub maybe_public_bucket_extension: Option<String>,
|
||||
@@ -158,6 +163,8 @@ pub struct MediaFileRaw {
|
||||
pub maybe_model_weight_creator_display_name: Option<String>,
|
||||
pub maybe_model_weight_creator_gravatar_hash: Option<String>,
|
||||
|
||||
pub extra_file_modification_info: Option<String>,
|
||||
|
||||
pub public_bucket_directory_hash: String,
|
||||
pub maybe_public_bucket_prefix: Option<String>,
|
||||
pub maybe_public_bucket_extension: Option<String>,
|
||||
@@ -253,6 +260,9 @@ pub async fn batch_get_media_files(
|
||||
maybe_model_weight_creator_username: record.maybe_model_weight_creator_username,
|
||||
maybe_model_weight_creator_display_name: record.maybe_model_weight_creator_display_name,
|
||||
maybe_model_weight_creator_gravatar_hash: record.maybe_model_weight_creator_gravatar_hash,
|
||||
extra_media_file_info: record.extra_file_modification_info
|
||||
.map(|info| MediaFileExtraInfo::from_json_str(&info).ok())
|
||||
.flatten(), // NB: Fail open. Do not fail the query if we can't hydrate the JSON.
|
||||
public_bucket_directory_hash: record.public_bucket_directory_hash,
|
||||
maybe_public_bucket_prefix: record.maybe_public_bucket_prefix,
|
||||
maybe_public_bucket_extension: record.maybe_public_bucket_extension,
|
||||
@@ -314,6 +324,8 @@ SELECT
|
||||
model_weight_creator.display_name as maybe_model_weight_creator_display_name,
|
||||
model_weight_creator.email_gravatar_hash as maybe_model_weight_creator_gravatar_hash,
|
||||
|
||||
m.extra_file_modification_info,
|
||||
|
||||
m.public_bucket_directory_hash,
|
||||
m.maybe_public_bucket_prefix,
|
||||
m.maybe_public_bucket_extension,
|
||||
@@ -401,6 +413,8 @@ impl FromRow<'_, MySqlRow> for MediaFileRaw {
|
||||
maybe_model_weight_creator_display_name: row.try_get("maybe_model_weight_creator_display_name")?,
|
||||
maybe_model_weight_creator_gravatar_hash: row.try_get("maybe_model_weight_creator_gravatar_hash")?,
|
||||
|
||||
extra_file_modification_info: row.try_get("extra_file_modification_info")?,
|
||||
|
||||
public_bucket_directory_hash: row.try_get("public_bucket_directory_hash")?,
|
||||
maybe_public_bucket_prefix: row.try_get("maybe_public_bucket_prefix")?,
|
||||
maybe_public_bucket_extension: row.try_get("maybe_public_bucket_extension")?,
|
||||
|
||||
+9
@@ -33,6 +33,7 @@ use tokens::tokens::prompts::PromptToken;
|
||||
use crate::http_server::common_responses::media_file_cover_image_details::{MediaFileCoverImageDetails, MediaFileDefaultCover};
|
||||
use crate::http_server::common_responses::simple_entity_stats::SimpleEntityStats;
|
||||
use crate::http_server::common_responses::user_details_lite::UserDetailsLight;
|
||||
use crate::http_server::endpoints::media_files::common_responses::live_portrait::MediaFileLivePortraitDetails;
|
||||
use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
use crate::state::server_state::ServerState;
|
||||
|
||||
@@ -122,6 +123,10 @@ pub struct BatchMediaFileInfo {
|
||||
/// Text transcripts for TTS, etc.
|
||||
pub maybe_text_transcript: Option<String>,
|
||||
|
||||
/// OPTIONAL. Details on live portrait generated media files,
|
||||
/// if this is a live portrait generated file.
|
||||
pub maybe_live_portrait_details: Option<MediaFileLivePortraitDetails>,
|
||||
|
||||
/// For Comfy / Video Style Transfer jobs, this might include
|
||||
/// the name of the selected style.
|
||||
pub maybe_style_name: Option<StyleTransferName>,
|
||||
@@ -320,6 +325,10 @@ pub async fn batch_get_media_files_handler(
|
||||
),
|
||||
maybe_title: result.maybe_title,
|
||||
maybe_text_transcript: result.maybe_text_transcript,
|
||||
maybe_live_portrait_details: result.extra_media_file_info
|
||||
.as_ref()
|
||||
.map(|info| MediaFileLivePortraitDetails::maybe_from_extra_info(&info))
|
||||
.flatten(),
|
||||
maybe_style_name: result.maybe_prompt_args
|
||||
.as_ref()
|
||||
.and_then(|args| args.style_name.as_ref())
|
||||
|
||||
Reference in new issue
Block a user