-
Notifications
You must be signed in to change notification settings - Fork 205
Expand file tree
/
Copy pathconstants.rs
More file actions
149 lines (138 loc) · 5.81 KB
/
Copy pathconstants.rs
File metadata and controls
149 lines (138 loc) · 5.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
use std::collections::HashMap;
use once_cell::sync::Lazy;
use percent_encoding::{AsciiSet, NON_ALPHANUMERIC};
use tracing::trace;
use url::Url;
use crate::types::addon::{Descriptor, ExtraProp, OptionsLimit};
pub const SCHEMA_VERSION_STORAGE_KEY: &str = "schema_version";
pub const PROFILE_STORAGE_KEY: &str = "profile";
pub const LIBRARY_STORAGE_KEY: &str = "library";
pub const LIBRARY_RECENT_STORAGE_KEY: &str = "library_recent";
pub const STREAMS_STORAGE_KEY: &str = "streams";
pub const SEARCH_HISTORY_STORAGE_KEY: &str = "search_history";
pub const STREAMING_SERVER_URLS_STORAGE_KEY: &str = "streaming_server_urls";
pub const NOTIFICATIONS_STORAGE_KEY: &str = "notifications";
pub const CALENDAR_STORAGE_KEY: &str = "calendar";
pub const DISMISSED_EVENTS_STORAGE_KEY: &str = "dismissed_events";
pub const LIBRARY_COLLECTION_NAME: &str = "libraryItem";
pub const SEARCH_EXTRA_NAME: &str = "search";
/// `https://{ADDON_UR}/meta/...` resource
pub const META_RESOURCE_NAME: &str = "meta";
pub const STREAM_RESOURCE_NAME: &str = "stream";
/// `https://{ADDON_URL}/catalog/...` resource
pub const CATALOG_RESOURCE_NAME: &str = "catalog";
pub const SUBTITLES_RESOURCE_NAME: &str = "subtitles";
pub const ADDON_MANIFEST_PATH: &str = "/manifest.json";
pub const ADDON_LEGACY_PATH: &str = "/stremio/v1";
pub const CATALOG_PAGE_SIZE: usize = 100;
pub const CATALOG_PREVIEW_SIZE: usize = 100;
pub const LIBRARY_RECENT_COUNT: usize = 200;
pub const NOTIFICATION_ITEMS_COUNT: usize = 100;
/// Maximum calendar items to fetch from `calendarIds` resource
pub const CALENDAR_ITEMS_COUNT: usize = 100;
/// Account age in days to be considered a new user
pub const NEW_USER_DAYS: chrono::Duration = chrono::Duration::days(30);
/// A `LibraryItem` is considered watched once we've watched more than the `duration * threshold`:
///
/// `LibraryItem.state.time_watched` > `LibraryItem.state.duration` * [`WATCHED_THRESHOLD_COEF`]
pub const WATCHED_THRESHOLD_COEF: f64 = 0.7;
pub const CREDITS_THRESHOLD_COEF: f64 = 0.9;
/// The latest migration scheme version
pub const SCHEMA_VERSION: u32 = 23;
pub const IMDB_LINK_CATEGORY: &str = "imdb";
pub const GENRES_LINK_CATEGORY: &str = "Genres";
pub const CINEMETA_TOP_CATALOG_ID: &str = "top";
/// Only found in Cinemeta catalogs, i.e. [`CINEMETA_CATALOGS_URL`]
pub const CINEMETA_FEED_CATALOG_ID: &str = "feed.json";
pub const IMDB_TITLE_PATH: &str = "title";
pub const YOUTUBE_ADDON_ID_PREFIX: &str = "yt_id:";
pub const URI_COMPONENT_ENCODE_SET: &AsciiSet = &NON_ALPHANUMERIC
.remove(b'-')
.remove(b'_')
.remove(b'.')
.remove(b'!')
.remove(b'~')
.remove(b'*')
.remove(b'\'')
.remove(b'(')
.remove(b')');
pub const USER_LIKES_SUPPORTED_ID_PREFIXES: &[&str] = &["tt", "tmdb", "kitsu"];
pub const USER_LIKES_SUPPORTED_TYPES: &[&str] = &["movie", "series"];
/// In milliseconds
pub const PLAYER_IGNORE_SEEK_AFTER: u64 = 600_000;
pub static BASE64: base64::engine::general_purpose::GeneralPurpose =
base64::engine::general_purpose::STANDARD;
pub static CINEMETA_CATALOGS_URL: Lazy<Url> = Lazy::new(|| {
Url::parse("https://cinemeta-catalogs.strem.io").expect("CINEMETA_URL parse failed")
});
/// Manifest URL for Cinemeta V3
pub static CINEMETA_URL: Lazy<Url> = Lazy::new(|| {
Url::parse("https://v3-cinemeta.strem.io/manifest.json").expect("CINEMETA_URL parse failed")
});
pub static USER_LIKES_API_URL: Lazy<Url> =
Lazy::new(|| Url::parse("https://likes.stremio.com").expect("API_URL parse failed"));
pub static API_URL: Lazy<Url> =
Lazy::new(|| Url::parse("https://api.strem.io").expect("API_URL parse failed"));
pub static LINK_API_URL: Lazy<Url> =
Lazy::new(|| Url::parse("https://link.stremio.com").expect("LINK_API_URL parse failed"));
pub static STREAMING_SERVER_URL: Lazy<Url> =
Lazy::new(|| Url::parse("http://127.0.0.1:11470").expect("STREAMING_SERVER_URL parse failed"));
pub static IMDB_URL: Lazy<Url> =
Lazy::new(|| Url::parse("https://imdb.com").expect("IMDB_URL parse failed"));
pub static OFFICIAL_ADDONS: Lazy<Vec<Descriptor>> = Lazy::new(|| {
if std::env::var("EMPTY_OFFICIAL_ADDONS").unwrap_or("0".to_string()) == "1" {
trace!("Official addons are disabled");
return serde_json::from_str("[]").expect("OFFICIAL_ADDONS parse failed");
} else {
let addons_str = stremio_official_addons::get_addons_string();
return serde_json::from_slice(&addons_str).expect("OFFICIAL_ADDONS parse failed");
}
});
pub static SKIP_EXTRA_PROP: Lazy<ExtraProp> = Lazy::new(|| ExtraProp {
name: "skip".to_owned(),
is_required: false,
options: vec![],
options_limit: OptionsLimit::default(),
});
pub static VIDEO_HASH_EXTRA_PROP: Lazy<ExtraProp> = Lazy::new(|| ExtraProp {
name: "videoHash".to_owned(),
is_required: false,
options: vec![],
options_limit: OptionsLimit::default(),
});
pub static VIDEO_SIZE_EXTRA_PROP: Lazy<ExtraProp> = Lazy::new(|| ExtraProp {
name: "videoSize".to_owned(),
is_required: false,
options: vec![],
options_limit: OptionsLimit::default(),
});
pub static VIDEO_FILENAME_EXTRA_PROP: Lazy<ExtraProp> = Lazy::new(|| ExtraProp {
name: "filename".to_owned(),
is_required: false,
options: vec![],
options_limit: OptionsLimit::default(),
});
pub static LAST_VIDEOS_IDS_EXTRA_PROP: Lazy<ExtraProp> = Lazy::new(|| ExtraProp {
name: "lastVideosIds".to_owned(),
is_required: false,
options: vec![],
options_limit: OptionsLimit(1),
});
pub static CALENDAR_IDS_EXTRA_PROP: Lazy<ExtraProp> = Lazy::new(|| ExtraProp {
name: "calendarVideosIds".to_owned(),
is_required: false,
options: vec![],
options_limit: OptionsLimit(1),
});
pub static TYPE_PRIORITIES: Lazy<HashMap<&'static str, i32>> = Lazy::new(|| {
vec![
("all", 5),
("movie", 4),
("series", 3),
("channel", 2),
("tv", 1),
("other", i32::MIN),
]
.into_iter()
.collect()
});