From ae33e3783b52d8d6d46bf4fe53746e4e769cb497 Mon Sep 17 00:00:00 2001 From: euzu Date: Sun, 5 Nov 2023 20:19:37 +0100 Subject: [PATCH] skipping direct_source for xtream --- CHANGELOG.md | 6 ++++++ README.md | 18 ++++++++++++++---- config.yml | 19 +++++++++++++++++++ src/api/api_model.rs | 4 ++-- src/model/config.rs | 8 ++++++-- src/model/model_m3u.rs | 4 ++-- src/processing/xtream_parser.rs | 9 ++++++--- src/repository/xtream_repository.rs | 12 ++++++++++-- 8 files changed, 65 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a515caded..05469a637 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ # Changelog +# v1.1.3(2023-11-??) +* added new target options + - `xtream_skip_live_direct_source` + - `xtream_skip_video_direct_source` +* internal optimization/refactoring to avoid string cloning. + # v1.1.2(2023-11-03) * Fixed epg for xtream * Fixed some Web-UI Problems diff --git a/README.md b/README.md index 629ad6e3c..5bc62cca6 100644 --- a/README.md +++ b/README.md @@ -193,11 +193,21 @@ sort: ### 1.5.2.2 `output` Is a list of output format: -Each format has 2 properties `type` and `filename` -`type` _mandatory_ ```m3u```, ```strm``` and ```xtream```. -`filename` _mandatory_ if type `m3u` or `strm`, otherwise ignored +Each format has 2 properties +- `type` +- `filename` -`strm` output has additional options `underscore_whitespace`, `cleanup` and `kodi_style`. +`type` is _mandatory_ for `m3u`, `strm` and `xtream`. +`filename` is _mandatory_ if type `m3u` or `strm`, otherwise ignored + +`strm` output has additional options +- `underscore_whitespace` +- `cleanup` +- `kodi_style`. + +`xtream` output has additional options +- `xtream_skip_live_direct_source` +- `xtream_skip_video_direct_source` ```yaml output: diff --git a/config.yml b/config.yml index 86dab6f99..0915eb12d 100644 --- a/config.yml +++ b/config.yml @@ -65,6 +65,25 @@ sources: - Canada watch: - 'FR - Movies' + - name: plxtream + publish: true + filename: playlist_1 + type: xtream + filter: '!ALL_CHAN!' + options: { ignore_logo: true, xtream_skip_live_direct_source: true, , xtream_skip_video_direct_source: true, } + rename: + - { field: group, new_name: 1. DE$1, pattern: ^DE(.*) } + sort: + groups: + order: asc + mapping: + - France TNT + - France Premium + - Belgique + - Suisse + - Canada + watch: + - 'FR - Movies' - filename: playlist_strm type: strm filter: 'Group ~ "^tv-shows.*"' diff --git a/src/api/api_model.rs b/src/api/api_model.rs index 7a3515c92..5e5d7765d 100644 --- a/src/api/api_model.rs +++ b/src/api/api_model.rs @@ -3,7 +3,7 @@ use std::sync::{Arc, Mutex}; use actix_web::web; use serde::{Deserialize, Serialize}; use crate::model::api_proxy::{ApiProxyConfig}; -use crate::model::config::{Config, ConfigOptions, ConfigRename, ConfigSort, InputType, ProcessTargets, TargetOutput, VideoConfig}; +use crate::model::config::{Config, ConfigTargetOptions, ConfigRename, ConfigSort, InputType, ProcessTargets, TargetOutput, VideoConfig}; use crate::model::model_config::{default_as_empty_str, ProcessingOrder}; pub(crate) struct AppState { @@ -75,7 +75,7 @@ pub(crate) struct ServerTargetConfig { pub id: u16, pub enabled: bool, pub name: String, - pub options: Option, + pub options: Option, pub sort: Option, pub filter: String, #[serde(alias = "type")] diff --git a/src/model/config.rs b/src/model/config.rs index ea96cb250..f77a542a8 100644 --- a/src/model/config.rs +++ b/src/model/config.rs @@ -143,7 +143,7 @@ impl ConfigRename { } #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] -pub(crate) struct ConfigOptions { +pub(crate) struct ConfigTargetOptions { #[serde(default = "default_as_false")] pub ignore_logo: bool, #[serde(default = "default_as_false")] @@ -152,6 +152,10 @@ pub(crate) struct ConfigOptions { pub cleanup: bool, #[serde(default = "default_as_false")] pub kodi_style: bool, + #[serde(default = "default_as_false")] + pub xtream_skip_live_direct_source: bool, + #[serde(default = "default_as_false")] + pub xtream_skip_video_direct_source: bool, } #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] @@ -171,7 +175,7 @@ pub(crate) struct ConfigTarget { #[serde(default = "default_as_default")] pub name: String, #[serde(skip_serializing_if = "Option::is_none")] - pub options: Option, + pub options: Option, #[serde(skip_serializing_if = "Option::is_none")] pub sort: Option, pub filter: String, diff --git a/src/model/model_m3u.rs b/src/model/model_m3u.rs index aaf1c139d..7d7c79515 100644 --- a/src/model/model_m3u.rs +++ b/src/model/model_m3u.rs @@ -4,7 +4,7 @@ use std::rc::Rc; use serde::{Deserialize, Serialize}; use serde_json::Value; -use crate::model::config::{ConfigInput, ConfigOptions}; +use crate::model::config::{ConfigInput, ConfigTargetOptions}; use crate::model::xmltv::TVGuide; // https://de.wikipedia.org/wiki/M3U @@ -106,7 +106,7 @@ macro_rules! to_m3u_non_empty_fields { impl PlaylistItem { - pub fn to_m3u(&self, options: &Option) -> String { + pub fn to_m3u(&self, options: &Option) -> String { let header = self.header.borrow(); let ignore_logo = options.as_ref().map_or(false, |o| o.ignore_logo); let mut line = format!("#EXTINF:-1 tvg-id=\"{}\" tvg-name=\"{}\" group-title=\"{}\"", diff --git a/src/processing/xtream_parser.rs b/src/processing/xtream_parser.rs index cfc6d8f0b..c367be470 100644 --- a/src/processing/xtream_parser.rs +++ b/src/processing/xtream_parser.rs @@ -242,8 +242,10 @@ fn process_streams(xtream_cluster: &XtreamCluster, streams: &Value) -> Result Result>, M3uFilterError> { match process_category(category) { Ok(mut categories) => { @@ -270,7 +272,8 @@ pub(crate) fn parse_xtream(cat_id_cnt: &AtomicI32, xtream_cluster: &XtreamCluste audio_track: default_as_empty_rc_str(), time_shift: default_as_empty_rc_str(), rec: default_as_empty_rc_str(), - source: default_as_empty_rc_str(), // String::from(&stream.direct_source), + // source is meant to hold the original provider data + source: default_as_empty_rc_str(), url: if stream.direct_source.is_empty() { Rc::new(format!("{}/{}", stream_base_url, stream.get_stream_id())) } else { diff --git a/src/repository/xtream_repository.rs b/src/repository/xtream_repository.rs index 19ecdaa2e..c370ff690 100644 --- a/src/repository/xtream_repository.rs +++ b/src/repository/xtream_repository.rs @@ -69,6 +69,10 @@ pub(crate) fn write_xtream_playlist(target: &ConfigTarget, cfg: &Config, playlis return Err(M3uFilterError::new(M3uFilterErrorKind::Notify, msg)); } + + let (skip_live_direct_source, skip_video_direct_source) = target.options.as_ref() + .map_or((false, false), |o| (o.xtream_skip_live_direct_source, o.xtream_skip_video_direct_source)); + let mut cat_live_col = vec![]; let mut cat_series_col = vec![]; let mut cat_vod_col = vec![]; @@ -106,7 +110,9 @@ pub(crate) fn write_xtream_playlist(target: &ConfigTarget, cfg: &Config, playlis match header.xtream_cluster { XtreamCluster::Live => { document.insert("stream_id".to_string(), stream_id); - document.insert("direct_source".to_string(), Value::String(header.url.as_ref().clone())); + if !skip_live_direct_source { + document.insert("direct_source".to_string(), Value::String(header.url.as_ref().clone())); + } document.insert("thumbnail".to_string(), Value::String(header.logo_small.as_ref().clone())); document.insert("custom_sid".to_string(), Value::String("".to_string())); document.insert("epg_channel_id".to_string(), match &header.epg_channel_id { @@ -116,7 +122,9 @@ pub(crate) fn write_xtream_playlist(target: &ConfigTarget, cfg: &Config, playlis } XtreamCluster::Video => { document.insert("stream_id".to_string(), stream_id); - document.insert("direct_source".to_string(), Value::String(header.url.as_ref().clone())); + if !skip_video_direct_source { + document.insert("direct_source".to_string(), Value::String(header.url.as_ref().clone())); + } document.insert("custom_sid".to_string(), Value::String("".to_string())); } XtreamCluster::Series => {