mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-11 10:22:10 +02:00
some refactoring for constants
This commit is contained in:
@@ -39,6 +39,7 @@ pub fn rewrite_hls(user: &ProxyUserCredentials, props: &RewriteHlsProps) -> Stri
|
||||
let mut result = Vec::new();
|
||||
for line in props.content.lines() {
|
||||
if line.starts_with('#') {
|
||||
|
||||
result.push(line.to_string());
|
||||
} else if let Ok(token) = if line.starts_with("http") {
|
||||
encrypt_text(props.secret, line)
|
||||
|
||||
@@ -12,23 +12,8 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::mem;
|
||||
use std::path::Path;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, LazyLock, Mutex, RwLock};
|
||||
|
||||
static COUNTRY_CODE: LazyLock<HashSet<&'static str>> = LazyLock::new(|| vec![
|
||||
"af", "al", "dz", "ad", "ao", "ag", "ar", "am", "au", "at", "az", "bs", "bh", "bd", "bb", "by",
|
||||
"be", "bz", "bj", "bt", "bo", "ba", "bw", "br", "bn", "bg", "bf", "bi", "cv", "kh", "cm", "ca",
|
||||
"cf", "td", "cl", "cn", "co", "km", "cg", "cr", "hr", "cu", "cy", "cz", "cd", "dk", "dj", "dm",
|
||||
"do", "tl", "ec", "eg", "sv", "gq", "er", "ee", "sz", "et", "fj", "fi", "fr", "ga", "gm", "ge",
|
||||
"de", "gh", "gr", "gd", "gt", "gn", "gw", "gy", "ht", "hn", "hu", "is", "in", "id", "ir", "iq",
|
||||
"ie", "il", "it", "ci", "jm", "jp", "jo", "kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv",
|
||||
"lb", "ls", "lr", "ly", "li", "lt", "lu", "mg", "mw", "my", "mv", "ml", "mt", "mh", "mr", "mu",
|
||||
"mx", "fm", "md", "mc", "mn", "me", "ma", "mz", "mm", "na", "nr", "np", "nl", "nz", "ni", "ne",
|
||||
"ng", "mk", "no", "om", "pk", "pw", "pa", "pg", "py", "pe", "ph", "pl", "pt", "qa", "ro", "ru",
|
||||
"rw", "kn", "lc", "vc", "ws", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sk", "si", "sb",
|
||||
"so", "za", "ss", "es", "lk", "sd", "sr", "se", "ch", "sy", "tw", "tj", "tz", "th", "tg", "to",
|
||||
"tt", "tn", "tr", "tm", "tv", "ug", "ua", "ae", "gb", "us", "uy", "uz", "vu", "va", "ve", "vn",
|
||||
"ye", "zm", "zw",
|
||||
].into_iter().collect::<HashSet<&str>>());
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
use crate::utils::constants::CONSTANTS;
|
||||
|
||||
fn split_by_first_match<'a>(input: &'a str, delimiters: &[char]) -> (Option<&'a str>, &'a str) {
|
||||
for delim in delimiters {
|
||||
@@ -38,7 +23,7 @@ fn split_by_first_match<'a>(input: &'a str, delimiters: &[char]) -> (Option<&'a
|
||||
if !right.is_empty() {
|
||||
let prefix = left.trim();
|
||||
// when we used anything as prefix the result was bad
|
||||
if COUNTRY_CODE.contains(&prefix) {
|
||||
if CONSTANTS.country_codes.contains(&prefix) {
|
||||
return (Some(prefix), right.trim());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@ use crate::model::config::ConfigInput;
|
||||
use crate::model::playlist::{PlaylistGroup, PlaylistItem, PlaylistItemHeader, PlaylistItemType, XtreamCluster};
|
||||
use crate::model::xtream::{XtreamCategory, XtreamSeriesInfo, XtreamSeriesInfoEpisode, XtreamStream};
|
||||
use crate::utils::hash_utils::generate_playlist_uuid;
|
||||
use crate::utils::network::xtream::{get_xtream_stream_url_base, ACTION_GET_SERIES_INFO};
|
||||
use crate::utils::network::xtream::{get_xtream_stream_url_base};
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use crate::model::xtream_const;
|
||||
|
||||
fn map_to_xtream_category(categories: &Value) -> Result<Vec<XtreamCategory>, M3uFilterError> {
|
||||
match serde_json::from_value::<Vec<XtreamCategory>>(categories.to_owned()) {
|
||||
@@ -91,7 +92,7 @@ pub fn get_xtream_url(xtream_cluster: XtreamCluster, url: &str,
|
||||
format!("{url}/movie/{username}/{password}/{stream_id}.{ext}")
|
||||
}
|
||||
XtreamCluster::Series =>
|
||||
format!("{}&action={ACTION_GET_SERIES_INFO}&series_id={stream_id}", get_xtream_stream_url_base(url, username, password))
|
||||
format!("{}&action={}&series_id={stream_id}", get_xtream_stream_url_base(url, username, password), xtream_const::XC_ACTION_GET_SERIES_INFO)
|
||||
};
|
||||
stream_base_url
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user