aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-11-29 13:32:52 +0100
committermetamuffin <metamuffin@disroot.org>2025-11-29 13:32:52 +0100
commit5db15c323d76dca9ae71b0204d63dcb09fbbcbc5 (patch)
tree4f69e58c9b6825b7b602712893950673abf9c286 /common
parentbac47e456085ea153ae6ae1b1e28e41868693c9c (diff)
downloadjellything-5db15c323d76dca9ae71b0204d63dcb09fbbcbc5.tar
jellything-5db15c323d76dca9ae71b0204d63dcb09fbbcbc5.tar.bz2
jellything-5db15c323d76dca9ae71b0204d63dcb09fbbcbc5.tar.zst
remove asset token; db json
Diffstat (limited to 'common')
-rw-r--r--common/src/helpers.rs11
-rw-r--r--common/src/impl.rs69
-rw-r--r--common/src/lib.rs35
3 files changed, 22 insertions, 93 deletions
diff --git a/common/src/helpers.rs b/common/src/helpers.rs
index 44e9468..db75ba9 100644
--- a/common/src/helpers.rs
+++ b/common/src/helpers.rs
@@ -97,6 +97,12 @@ impl Display for IdentifierType {
IdentifierType::Tmdb => "tmdb",
IdentifierType::Tvdb => "tvdb",
IdentifierType::Omdb => "omdb",
+ IdentifierType::YoutubeVideo => "youtube_video",
+ IdentifierType::YoutubeChannel => "youtube_channel",
+ IdentifierType::YoutubeChannelHandle => "youtube_channel_handle",
+ IdentifierType::Barcode => "barcode",
+ IdentifierType::AcoustIdTrack => "acoustid_track",
+ IdentifierType::Bandcamp => "bandcamp",
})
}
}
@@ -114,6 +120,11 @@ impl FromStr for IdentifierType {
"tmdb" => IdentifierType::Tmdb,
"tvdb" => IdentifierType::Tvdb,
"omdb" => IdentifierType::Omdb,
+ "youtube_video" => IdentifierType::YoutubeVideo,
+ "youtube_channel" => IdentifierType::YoutubeChannel,
+ "youtube_channel_handle" => IdentifierType::YoutubeChannelHandle,
+ "barcode" => IdentifierType::Barcode,
+ "acoustid_track" => IdentifierType::AcoustIdTrack,
_ => return Err(()),
})
}
diff --git a/common/src/impl.rs b/common/src/impl.rs
index ef1a874..585c778 100644
--- a/common/src/impl.rs
+++ b/common/src/impl.rs
@@ -3,10 +3,7 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
-use crate::{
- IdentifierType, Identifiers, Node, NodeID, NodeIDOrSlug, SourceTrack, SourceTrackKind,
- TmdbKind, TraktKind,
-};
+use crate::{Node, NodeID, NodeIDOrSlug, SourceTrack, SourceTrackKind};
use serde::{Deserialize, Serialize};
use std::{fmt::Display, str::FromStr};
@@ -44,70 +41,6 @@ impl Display for SourceTrack {
}
}
-impl Display for TmdbKind {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- f.write_str(match self {
- TmdbKind::Tv => "tv",
- TmdbKind::Movie => "movie",
- })
- }
-}
-
-impl TraktKind {
- pub fn singular(self) -> &'static str {
- match self {
- TraktKind::Movie => "movie",
- TraktKind::Show => "show",
- TraktKind::Season => "season",
- TraktKind::Episode => "episode",
- TraktKind::Person => "person",
- TraktKind::User => "user",
- }
- }
- pub fn plural(self) -> &'static str {
- match self {
- TraktKind::Movie => "movies",
- TraktKind::Show => "shows",
- TraktKind::Season => "seasons",
- TraktKind::Episode => "episodes",
- TraktKind::Person => "people",
- TraktKind::User => "users", // //! not used in API
- }
- }
-}
-impl Display for TraktKind {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- f.write_str(match self {
- TraktKind::Movie => "Movie",
- TraktKind::Show => "Show",
- TraktKind::Season => "Season",
- TraktKind::Episode => "Episode",
- TraktKind::Person => "Person",
- TraktKind::User => "User",
- })
- }
-}
-impl Display for Identifiers {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- if let Some(id) = self.0.get(&IdentifierType::Trakt) {
- f.write_fmt(format_args!("trakt={}", id))?;
- }
- if let Some(id) = &self.0.get(&IdentifierType::Tmdb) {
- f.write_fmt(format_args!(",tmdb={}", id))?;
- }
- if let Some(_id) = &self.0.get(&IdentifierType::Imdb) {
- f.write_str(",imdb")?;
- }
- if let Some(_id) = &self.0.get(&IdentifierType::Tvdb) {
- f.write_str(",tvdb")?;
- }
- if let Some(_id) = &self.0.get(&IdentifierType::Omdb) {
- f.write_str(",omdb")?;
- }
- Ok(())
- }
-}
-
impl NodeID {
pub fn from_slug(slug: &str) -> Self {
let mut h = blake3::Hasher::new();
diff --git a/common/src/lib.rs b/common/src/lib.rs
index d09153e..f3d8416 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -70,14 +70,11 @@ pub struct Node {
pub ratings: BTreeMap<RatingType, f64>,
pub pictures: BTreeMap<PictureSlot, Asset>,
pub credits: BTreeMap<CreditCategory, Vec<Appearance>>,
- pub identifiers: Identifiers,
+ pub identifiers: BTreeMap<IdentifierType, String>,
pub visibility: Visibility,
pub storage_size: u64,
}
-#[derive(Debug, Clone, Deserialize, Serialize, Default)]
-pub struct Identifiers(pub BTreeMap<IdentifierType, String>);
-
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord)]
#[serde(rename_all = "snake_case")]
pub enum PictureSlot {
@@ -87,14 +84,20 @@ pub enum PictureSlot {
Headshot,
}
-#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord)]
+#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord)]
#[serde(rename_all = "snake_case")]
pub enum IdentifierType {
MusicbrainzRecording,
MusicbrainzArtist,
MusicbrainzRelease,
MusicbrainzReleaseGroup,
+ AcoustIdTrack,
+ YoutubeVideo,
+ YoutubeChannel,
+ YoutubeChannelHandle,
+ Bandcamp,
Isrc,
+ Barcode,
Trakt,
Imdb,
Tmdb,
@@ -103,7 +106,7 @@ pub enum IdentifierType {
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
-pub struct Asset(pub String);
+pub struct Asset(pub PathBuf);
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Appearance {
@@ -165,7 +168,7 @@ pub enum NodeKind {
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum TrackSource {
- Local(Asset),
+ Local(PathBuf, u64),
Remote(usize),
}
@@ -231,21 +234,3 @@ pub enum SourceTrackKind {
},
Subtitle,
}
-
-// TODO move this somewhere else
-#[derive(Debug, Serialize, Deserialize, Clone, Copy, Hash, PartialEq)]
-#[serde(rename_all = "snake_case")]
-pub enum TraktKind {
- Movie,
- Show,
- Season,
- Episode,
- Person,
- User,
-}
-
-#[derive(Debug, Clone, Copy, Hash, Serialize, Deserialize)]
-pub enum TmdbKind {
- Tv,
- Movie,
-}