From 42568332b5433c97813e8c291db0fc0d15867b76 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 24 Oct 2023 19:32:26 +0200 Subject: import -> jellytool --- import/src/infojson.rs | 143 ------------------------------------------------- 1 file changed, 143 deletions(-) delete mode 100644 import/src/infojson.rs (limited to 'import/src/infojson.rs') diff --git a/import/src/infojson.rs b/import/src/infojson.rs deleted file mode 100644 index dd2151b..0000000 --- a/import/src/infojson.rs +++ /dev/null @@ -1,143 +0,0 @@ -/* - 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 -*/ - -use anyhow::Context; -use jellycommon::chrono::{format::Parsed, DateTime, Utc}; -use serde::{Deserialize, Serialize}; -use std::collections::HashMap; - -#[derive(Debug, Serialize, Deserialize)] -pub struct YVideo { - pub id: String, - pub title: String, - pub formats: Vec, - pub thumbnails: Vec, - pub thumbnail: String, - pub description: String, - pub channel_id: String, - pub duration: Option, - pub view_count: usize, - pub average_rating: Option, - pub age_limit: usize, - pub webpage_url: String, - pub categories: Vec, - pub tags: Vec, - pub playable_in_embed: bool, - pub automatic_captions: HashMap>, - pub comment_count: Option, - pub chapters: Option>, - pub heatmap: Option>, - pub like_count: Option, - pub channel: Option, - pub channel_follower_count: usize, - pub channel_is_verified: Option, - pub uploader: String, - pub uploader_id: String, - pub uploader_url: String, - pub upload_date: String, - pub availability: String, // "public" | "private" | "unlisted", - pub original_url: Option, - 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 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: Option, - pub ext: String, //"vtt" | "json3" | "srv1" | "srv2" | "srv3" | "ttml", - pub protocol: Option, - pub name: Option, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct YFormat { - pub format_id: String, - pub format_note: Option, - pub ext: String, - pub protocol: String, - pub acodec: Option, - pub vcodec: Option, - pub url: Option, - pub width: Option, - pub height: Option, - pub fps: Option, - pub columns: Option, - pub fragments: Option>, - pub resolution: String, - pub dynamic_range: Option, - pub aspect_ratio: Option, - pub http_headers: HashMap, - pub audio_ext: String, - pub video_ext: String, - pub vbr: Option, - pub abr: Option, - pub format: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct YFragment { - pub url: Option, - pub duration: Option, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct YThumbnail { - pub url: String, - pub preference: i32, - pub id: String, - pub height: Option, - pub width: Option, - pub resolution: Option, -} - -#[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: f64, - pub value: f64, -} - -pub fn parse_upload_date(d: &str) -> anyhow::Result> { - let (year, month, day) = (&d[0..4], &d[4..6], &d[6..8]); - let (year, month, day) = ( - year.parse().context("parsing year")?, - month.parse().context("parsing month")?, - day.parse().context("parsing day")?, - ); - - let mut p = Parsed::new(); - p.year = Some(year); - p.month = Some(month); - p.day = Some(day); - p.hour_div_12 = Some(0); - p.hour_mod_12 = Some(0); - p.minute = Some(0); - p.second = Some(0); - Ok(p.to_datetime_with_timezone(&Utc)?) -} -- cgit v1.2.3-70-g09d2