diff options
author | metamuffin <metamuffin@disroot.org> | 2023-08-04 12:37:07 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-08-04 12:37:07 +0200 |
commit | 9bef55396cc9a9a4d83970a26bf56f07d5f0377d (patch) | |
tree | 8709da46cd02df8c97338a84fafd3183837b3fb3 | |
parent | 016b8fec6ed9908e11e72ec7b9930e5908d58a02 (diff) | |
download | jellything-9bef55396cc9a9a4d83970a26bf56f07d5f0377d.tar jellything-9bef55396cc9a9a4d83970a26bf56f07d5f0377d.tar.bz2 jellything-9bef55396cc9a9a4d83970a26bf56f07d5f0377d.tar.zst |
infojson schema
-rw-r--r-- | import/src/infojson.rs | 123 | ||||
-rw-r--r-- | import/src/main.rs | 15 |
2 files changed, 136 insertions, 2 deletions
diff --git a/import/src/infojson.rs b/import/src/infojson.rs new file mode 100644 index 0000000..6f98eaa --- /dev/null +++ b/import/src/infojson.rs @@ -0,0 +1,123 @@ +/* + This file is part of jellything (https://codeberg.org/metamuffin/jellything) + which is licensed under the GNU Affero General Public License (version 3); see /COPYING. + Copyright (C) 2023 metamuffin <metamuffin.org> +*/ + +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +#[derive(Debug, Serialize, Deserialize)] +pub struct YVideo { + pub id: String, + pub title: String, + pub formats: Vec<YFormat>, + pub thumbnails: Vec<YThumbnail>, + pub thumbnail: String, + pub description: String, + pub channel_id: String, + pub duration: f64, + pub view_count: usize, + pub average_rating: Option<String>, + pub age_limit: usize, + pub webpage_url: String, + pub categories: Vec<String>, + pub tags: Vec<String>, + pub playable_in_embed: bool, + pub automatic_captions: HashMap<String, Vec<YCaption>>, + pub comment_count: usize, + pub chapters: Vec<YChapter>, + pub heatmap: Vec<YHeatmapSample>, + pub like_count: usize, + pub channel: String, + pub channel_follower_count: usize, + pub channel_is_verified: bool, + pub uploader: String, + pub uploader_id: String, + pub uploader_url: String, + pub upload_date: String, + pub availability: String, // "public" | "private" | "unlisted", + pub original_url: String, + pub webpage_url_basename: String, + pub webpage_url_domain: String, + pub extractor: String, + pub extractor_key: String, + pub playlist_count: usize, + pub playlist: String, + pub playlist_id: String, + pub playlist_title: String, + pub playlist_uploader: String, + pub playlist_uploader_id: String, + pub n_entries: usize, + pub playlist_index: usize, + pub playlist_autonumber: usize, + pub display_id: String, + pub fulltitle: String, + pub duration_string: String, + pub is_live: bool, + pub was_live: bool, + pub epoch: usize, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct YCaption { + pub url: String, + pub ext: String, //"vtt" | "json3" | "srv1" | "srv2" | "srv3" | "ttml", + pub protocol: Option<String>, + pub name: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct YFormat { + pub format_id: String, + pub format_note: String, + pub ext: String, + pub protocol: String, + pub acodec: String, + pub vcodec: String, + pub url: String, + pub width: u32, + pub height: u32, + pub fps: f64, + pub columns: u32, + pub fragments: Vec<YFragment>, + pub resolution: Vec<String>, + pub dynamic_range: Option<String>, + pub aspect_ratio: f64, + pub http_headers: HashMap<String, String>, + pub audio_ext: String, + pub video_ext: String, + pub vbr: usize, + pub abr: usize, + pub format: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct YFragment { + pub url: String, + pub duration: f64, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct YThumbnail { + pub url: String, + pub preference: i32, + pub id: String, + pub height: Option<u32>, + pub width: Option<u32>, + pub resolution: Option<String>, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct YChapter { + pub start_time: f64, + pub end_time: f64, + pub title: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct YHeatmapSample { + pub start_time: f64, + pub end_time: String, + pub value: f64, +} diff --git a/import/src/main.rs b/import/src/main.rs index d40916a..bf5c49c 100644 --- a/import/src/main.rs +++ b/import/src/main.rs @@ -4,10 +4,13 @@ Copyright (C) 2023 metamuffin <metamuffin.org> */ pub mod tmdb; +pub mod infojson; use anyhow::Context; use clap::{Parser, Subcommand}; -use jellycommon::{AssetLocation, MediaInfo, MediaSource, Node, NodeKind, NodePrivate, NodePublic}; +use jellycommon::{ + AssetLocation, LocalTrack, MediaInfo, MediaSource, Node, NodeKind, NodePrivate, NodePublic, +}; use jellymatroska::read::EbmlReader; use jellyremuxer::import::{import_metadata, seek_index}; use log::{info, warn}; @@ -214,7 +217,15 @@ fn main() -> anyhow::Result<()> { backdrop: backdrop.clone().map(AssetLocation::Library), poster: poster.clone().map(AssetLocation::Library), source: file_meta.as_ref().map(|m| MediaSource::Local { - tracks: m.track_sources.clone(), + tracks: m + .track_sources + .clone() + .into_iter() + .map(|t| LocalTrack { + path: source_path_e.clone().unwrap(), + ..t + }) + .collect(), }), }, public: NodePublic { |