aboutsummaryrefslogtreecommitdiff
path: root/server/src/library.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/library.rs')
-rw-r--r--server/src/library.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/server/src/library.rs b/server/src/library.rs
index 330f382..ffd8b4a 100644
--- a/server/src/library.rs
+++ b/server/src/library.rs
@@ -14,6 +14,8 @@ use std::{
sync::Arc,
};
+use crate::{routes::ui::node::AssetRole, CONF};
+
pub struct Library {
pub root: Arc<Node>,
pub root_path: PathBuf,
@@ -183,6 +185,22 @@ impl Node {
bail!("did somebody really put a fifo or socket in the library?!")
}
}
+
+ pub fn get_asset(&self, library: &Library, role: AssetRole) -> PathBuf {
+ let path = match role {
+ AssetRole::Backdrop => self
+ .common()
+ .backdrop
+ .clone()
+ .or_else(|| self.common().poster.clone()),
+ AssetRole::Poster => self.common().poster.clone(),
+ };
+ if let Some(p) = path {
+ library.root_path.join(p)
+ } else {
+ CONF.asset_path.join("fallback.jpeg")
+ }
+ }
}
impl Item {