mirror of
https://github.com/euzu/tuliprox.git
synced 2026-09-29 12:32:08 +02:00
some refactoring for constants
This commit is contained in:
@@ -9,13 +9,9 @@ use std::fs::File;
|
||||
use std::io::{BufWriter, Write};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
const FILE_SERIES_INFO: &str = "xtream_series_info";
|
||||
const FILE_VOD_INFO: &str = "xtream_vod_info";
|
||||
const FILE_SUFFIX_WAL: &str = "wal";
|
||||
const FILE_SERIES_EPISODE_RECORD: &str = "series_episode_record";
|
||||
|
||||
use crate::model::xtream_const;
|
||||
use crate::repository::bplustree::BPlusTree;
|
||||
use crate::repository::storage_const;
|
||||
use crate::repository::xtream_repository::xtream_get_record_file_path;
|
||||
use crate::utils::file::file_utils::append_or_crate_file;
|
||||
use crate::utils::network::xtream;
|
||||
@@ -51,7 +47,7 @@ pub(in crate::processing) fn write_info_content_to_wal_file(writer: &mut BufWrit
|
||||
pub(in crate::processing) fn create_resolve_episode_wal_files(cfg: &Config, input: &ConfigInput) -> Option<(File, PathBuf)> {
|
||||
match get_input_storage_path(&input.name, &cfg.working_dir) {
|
||||
Ok(storage_path) => {
|
||||
let info_path = storage_path.join(format!("{FILE_SERIES_EPISODE_RECORD}.{FILE_SUFFIX_WAL}"));
|
||||
let info_path = storage_path.join(format!("{}.{}", xtream_const::XC_FILE_SERIES_EPISODE_RECORD, storage_const::FILE_SUFFIX_WAL));
|
||||
let info_file = append_or_crate_file(&info_path).ok()?;
|
||||
Some((info_file, info_path))
|
||||
}
|
||||
@@ -64,11 +60,11 @@ pub(in crate::processing) fn create_resolve_info_wal_files(cfg: &Config, input:
|
||||
Ok(storage_path) => {
|
||||
if let Some(file_prefix) = match cluster {
|
||||
XtreamCluster::Live => None,
|
||||
XtreamCluster::Video => Some(FILE_VOD_INFO),
|
||||
XtreamCluster::Series => Some(FILE_SERIES_INFO)
|
||||
XtreamCluster::Video => Some(xtream_const::XC_FILE_VOD_INFO),
|
||||
XtreamCluster::Series => Some(xtream_const::XC_FILE_SERIES_INFO)
|
||||
} {
|
||||
let content_path = storage_path.join(format!("{file_prefix}_content.{FILE_SUFFIX_WAL}"));
|
||||
let info_path = storage_path.join(format!("{file_prefix}_record.{FILE_SUFFIX_WAL}"));
|
||||
let content_path = storage_path.join(format!("{file_prefix}_content.{}", storage_const::FILE_SUFFIX_WAL));
|
||||
let info_path = storage_path.join(format!("{file_prefix}_record.{}", storage_const::FILE_SUFFIX_WAL));
|
||||
let content_file = append_or_crate_file(&content_path).ok()?;
|
||||
let info_file = append_or_crate_file(&info_path).ok()?;
|
||||
return Some((content_file, info_file, content_path, info_path));
|
||||
|
||||
@@ -16,11 +16,10 @@ use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
use log::{info, log_enabled, Level};
|
||||
use crate::model::xtream::{XtreamSeriesEpisode, XtreamSeriesInfoEpisode};
|
||||
use crate::model::xtream_const;
|
||||
use crate::utils::bincode_utils::bincode_serialize;
|
||||
use crate::utils::file::file_utils::file_writer;
|
||||
|
||||
const TAG_SERIES_INFO_LAST_MODIFIED: &str = "last_modified";
|
||||
|
||||
create_resolve_options_function_for_xtream_target!(series);
|
||||
|
||||
async fn read_processed_series_info_ids(cfg: &Config, errors: &mut Vec<M3uFilterError>, fpl: &FetchedPlaylist<'_>) -> HashMap<u32, u64> {
|
||||
@@ -53,7 +52,7 @@ fn write_series_episode_record_to_wal_file(
|
||||
}
|
||||
|
||||
fn should_update_series_info(pli: &mut PlaylistItem, processed_provider_ids: &HashMap<u32, u64>) -> (bool, u32, u64) {
|
||||
should_update_info(pli, processed_provider_ids, TAG_SERIES_INFO_LAST_MODIFIED)
|
||||
should_update_info(pli, processed_provider_ids, xtream_const::XC_TAG_SERIES_INFO_LAST_MODIFIED)
|
||||
}
|
||||
|
||||
async fn playlist_resolve_series_info(client: Arc<reqwest::Client>, cfg: &Config, errors: &mut Vec<M3uFilterError>,
|
||||
|
||||
@@ -13,14 +13,9 @@ use std::io::{BufWriter, Write};
|
||||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
use log::{info, log_enabled, Level};
|
||||
use crate::model::xtream_const;
|
||||
use crate::utils::file::file_utils::file_writer;
|
||||
|
||||
const TAG_VOD_INFO_INFO: &str = "info";
|
||||
const TAG_VOD_INFO_MOVIE_DATA: &str = "movie_data";
|
||||
const TAG_VOD_INFO_TMDB_ID: &str = "tmdb_id";
|
||||
const TAG_VOD_INFO_STREAM_ID: &str = "stream_id";
|
||||
const TAG_VOD_INFO_ADDED: &str = "added";
|
||||
|
||||
create_resolve_options_function_for_xtream_target!(vod);
|
||||
|
||||
async fn read_processed_vod_info_ids(cfg: &Config, errors: &mut Vec<M3uFilterError>, fpl: &FetchedPlaylist<'_>) -> HashMap<u32, u64> {
|
||||
@@ -30,18 +25,18 @@ async fn read_processed_vod_info_ids(cfg: &Config, errors: &mut Vec<M3uFilterErr
|
||||
fn extract_info_record_from_vod_info(content: &str) -> Option<(u32, InputVodInfoRecord)> {
|
||||
let doc = serde_json::from_str::<Map<String, Value>>(content).ok()?;
|
||||
|
||||
let movie_data = doc.get(TAG_VOD_INFO_MOVIE_DATA)?.as_object()?;
|
||||
let movie_data = doc.get(xtream_const::XC_TAG_VOD_INFO_MOVIE_DATA)?.as_object()?;
|
||||
let provider_id = get_u32_from_serde_value(
|
||||
movie_data.get(TAG_VOD_INFO_STREAM_ID)?,
|
||||
movie_data.get(xtream_const::XC_TAG_VOD_INFO_STREAM_ID)?,
|
||||
)?;
|
||||
|
||||
let added = movie_data
|
||||
.get(TAG_VOD_INFO_ADDED)
|
||||
.get(xtream_const::XC_TAG_VOD_INFO_ADDED)
|
||||
.and_then(get_u64_from_serde_value)
|
||||
.unwrap_or(0);
|
||||
|
||||
let tmdb_id = doc.get(TAG_VOD_INFO_INFO)?.as_object()
|
||||
.and_then(|info| info.get(TAG_VOD_INFO_TMDB_ID))
|
||||
let tmdb_id = doc.get(xtream_const::XC_TAG_VOD_INFO_INFO)?.as_object()
|
||||
.and_then(|info| info.get(xtream_const::XC_TAG_VOD_INFO_TMDB_ID))
|
||||
.and_then(get_u32_from_serde_value)
|
||||
.unwrap_or(0);
|
||||
|
||||
@@ -63,7 +58,7 @@ fn write_vod_info_record_to_wal_file(
|
||||
}
|
||||
|
||||
fn should_update_vod_info(pli: &mut PlaylistItem, processed_provider_ids: &HashMap<u32, u64>) -> (bool, u32, u64) {
|
||||
should_update_info(pli, processed_provider_ids, TAG_VOD_INFO_ADDED)
|
||||
should_update_info(pli, processed_provider_ids, xtream_const::XC_TAG_VOD_INFO_ADDED)
|
||||
}
|
||||
|
||||
pub async fn playlist_resolve_vod(client: Arc<reqwest::Client>, cfg: &Config, target: &ConfigTarget, errors: &mut Vec<M3uFilterError>, fpl: &mut FetchedPlaylist<'_>) {
|
||||
|
||||
Reference in New Issue
Block a user