add item types enum

This commit is contained in:
ThetaDev 2023-07-04 12:46:19 +02:00
parent 8ea69d5453
commit b18698604b
3 changed files with 22 additions and 4 deletions

View file

@ -11,7 +11,9 @@ tokio = { version = "1.20.0", features = ["macros", "rt-multi-thread"] }
futures = "0.3.21"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.82"
serde_with = { version = "3.0.0", default-features = false, features = ["macros"] }
serde_with = { version = "3.0.0", default-features = false, features = [
"macros",
] }
anyhow = "1.0"
log = "0.4.17"
env_logger = "0.10.0"
@ -24,3 +26,4 @@ num_enum = "0.6.1"
path_macro = "1.0.0"
intl_pluralrules = "7.0.2"
unic-langid = "0.9.1"
ordered_hash_map = { version = "0.2.0", features = ["serde"] }

View file

@ -6,6 +6,7 @@ use std::{
};
use futures::{stream, StreamExt};
use ordered_hash_map::OrderedHashMap;
use path_macro::path;
use rustypipe::{
client::RustyPipe,
@ -170,7 +171,7 @@ pub fn write_samples_to_dict() {
dict_entry.months = BTreeMap::new();
if collect_nd_tokens {
dict_entry.timeago_nd_tokens = BTreeMap::new();
dict_entry.timeago_nd_tokens = OrderedHashMap::new();
}
for datestr_table in &datestr_tables {

View file

@ -1,5 +1,6 @@
use std::collections::BTreeMap;
use ordered_hash_map::OrderedHashMap;
use rustypipe::{client::YTContext, model::AlbumType, param::Language};
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DefaultOnError, VecSkipError};
@ -18,7 +19,7 @@ pub struct DictEntry {
///
/// Identifiers: `Y`(ear), `M`(month), `W`(eek), `D`(ay),
/// `h`(our), `m`(inute), `s`(econd)
pub timeago_tokens: BTreeMap<String, String>,
pub timeago_tokens: OrderedHashMap<String, String>,
/// Order in which to parse numeric date components. Formatted as
/// a string of date identifiers (Y, M, D).
///
@ -34,7 +35,7 @@ pub struct DictEntry {
/// Tokens for parsing date strings with no digits (e.g. Today, Tomorrow)
///
/// Format: Parsed token -> \[Quantity\] Identifier
pub timeago_nd_tokens: BTreeMap<String, String>,
pub timeago_nd_tokens: OrderedHashMap<String, String>,
/// Are commas (instead of points) used as decimal separators?
pub comma_decimal: bool,
/// Tokens for parsing decimal prefixes (K, M, B, ...)
@ -49,6 +50,10 @@ pub struct DictEntry {
///
/// Format: Parsed text -> Album type
pub album_types: BTreeMap<String, AlbumType>,
/// Names of item types (Song, Video, Artist, Playlist)
///
/// Format: Parsed text -> Item type
pub item_types: BTreeMap<String, ExtItemType>,
}
/// Parsed TimeAgo string, contains amount and time unit.
@ -99,6 +104,15 @@ impl TimeUnit {
}
}
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ExtItemType {
Track,
Video,
Episode,
Playlist,
Artist,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct QBrowse<'a> {