aboutsummaryrefslogtreecommitdiff
path: root/tool/src/import/infojson.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-12-21 23:57:42 +0100
committermetamuffin <metamuffin@disroot.org>2023-12-21 23:57:42 +0100
commit3a29113e965a94bdef06655f1583cc6e86edd606 (patch)
treea0910fa9687a9935ba1ca85a9cb5def1a0bc9069 /tool/src/import/infojson.rs
parenta8b2480e898e269e7e0d41dbd46d9a18c7d1e4ba (diff)
downloadjellything-3a29113e965a94bdef06655f1583cc6e86edd606.tar
jellything-3a29113e965a94bdef06655f1583cc6e86edd606.tar.bz2
jellything-3a29113e965a94bdef06655f1583cc6e86edd606.tar.zst
rework import system pt. 1
Diffstat (limited to 'tool/src/import/infojson.rs')
-rw-r--r--tool/src/import/infojson.rs143
1 files changed, 0 insertions, 143 deletions
diff --git a/tool/src/import/infojson.rs b/tool/src/import/infojson.rs
deleted file mode 100644
index 3f0edc9..0000000
--- a/tool/src/import/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 <metamuffin.org>
-*/
-
-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<YFormat>,
- pub thumbnails: Vec<YThumbnail>,
- pub thumbnail: String,
- pub description: String,
- pub channel_id: String,
- pub duration: Option<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: Option<usize>,
- pub chapters: Option<Vec<YChapter>>,
- pub heatmap: Option<Vec<YHeatmapSample>>,
- pub like_count: Option<usize>,
- pub channel: Option<String>,
- pub channel_follower_count: usize,
- pub channel_is_verified: Option<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: Option<String>,
- pub webpage_url_basename: String,
- pub webpage_url_domain: String,
- pub extractor: String,
- pub extractor_key: String,
- pub playlist_count: Option<usize>,
- pub playlist: Option<String>,
- pub playlist_id: Option<String>,
- pub playlist_title: Option<String>,
- pub playlist_uploader: Option<String>,
- pub playlist_uploader_id: Option<String>,
- pub n_entries: Option<usize>,
- pub playlist_index: Option<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<String>,
- pub ext: String, //"vtt" | "json3" | "srv1" | "srv2" | "srv3" | "ttml",
- pub protocol: Option<String>,
- pub name: Option<String>,
-}
-
-#[derive(Debug, Serialize, Deserialize)]
-pub struct YFormat {
- pub format_id: String,
- pub format_note: Option<String>,
- pub ext: String,
- pub protocol: String,
- pub acodec: Option<String>,
- pub vcodec: Option<String>,
- pub url: Option<String>,
- pub width: Option<u32>,
- pub height: Option<u32>,
- pub fps: Option<f64>,
- pub columns: Option<u32>,
- pub fragments: Option<Vec<YFragment>>,
- pub resolution: String,
- pub dynamic_range: Option<String>,
- pub aspect_ratio: Option<f64>,
- pub http_headers: HashMap<String, String>,
- pub audio_ext: String,
- pub video_ext: String,
- pub vbr: Option<f64>,
- pub abr: Option<f64>,
- pub format: String,
-}
-
-#[derive(Debug, Serialize, Deserialize)]
-pub struct YFragment {
- pub url: Option<String>,
- pub duration: Option<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: f64,
- pub value: f64,
-}
-
-pub fn parse_upload_date(d: &str) -> anyhow::Result<DateTime<Utc>> {
- 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)?)
-}