From 6848c1a69c65b7c6a5e5709fb1d12426a39bac24 Mon Sep 17 00:00:00 2001 From: euzu Date: Fri, 3 Nov 2023 09:45:22 +0100 Subject: [PATCH] epg fixes for xtream --- src/model/model_m3u.rs | 1 + src/processing/m3u_parser.rs | 6 +++++- src/processing/playlist_processor.rs | 3 ++- src/processing/xtream_parser.rs | 3 ++- src/repository/xtream_repository.rs | 5 ++++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/model/model_m3u.rs b/src/model/model_m3u.rs index baa9a5e28..d38e342f3 100644 --- a/src/model/model_m3u.rs +++ b/src/model/model_m3u.rs @@ -45,6 +45,7 @@ pub(crate) struct PlaylistItemHeader { pub source: String, // this is the source content not the url pub url: String, + pub epg_channel_id: Option, #[serde(default = "default_stream_cluster", skip_serializing, skip_deserializing)] pub xtream_cluster: XtreamCluster, #[serde(skip_serializing, skip_deserializing)] diff --git a/src/processing/m3u_parser.rs b/src/processing/m3u_parser.rs index 2c36eaf3b..7f5700a40 100644 --- a/src/processing/m3u_parser.rs +++ b/src/processing/m3u_parser.rs @@ -64,6 +64,7 @@ fn create_empty_playlistitem_header(content: &String, url: String) -> PlaylistIt rec: String::from(""), source: String::from(content), url, + epg_channel_id: None, xtream_cluster: XtreamCluster::Live, additional_properties: None, } @@ -86,7 +87,10 @@ fn process_header(video_suffixes: &Vec<&str>, content: &String, url: String) -> if let Some(t) = token { let value = token_value(&mut it); match t.as_str() { - "tvg-id" => plih.id = value, + "tvg-id" => { + plih.id = value.to_owned(); + plih.epg_channel_id = Some(value); + }, "tvg-name" => plih.name = value, "group-title" => if !value.is_empty() { plih.group = value }, "parent-code" => plih.parent_code = value, diff --git a/src/processing/playlist_processor.rs b/src/processing/playlist_processor.rs index 62b8441b1..26c927c02 100644 --- a/src/processing/playlist_processor.rs +++ b/src/processing/playlist_processor.rs @@ -435,7 +435,8 @@ pub(crate) fn process_playlist(playlists: &mut [FetchedPlaylist], tv_guides.push(tv_guide); let guide = tv_guides.last().unwrap(); debug!("found epg information for {}", &target.name); - let channel_ids: HashSet<_> = new_playlist.iter().flat_map(|g| &g.channels).map(|c| c.header.borrow().id.to_owned()).collect(); + let channel_ids: HashSet<_> = new_playlist.iter().flat_map(|g| &g.channels) + .filter_map(|c| c.header.borrow().epg_channel_id.clone()).collect(); if !channel_ids.is_empty() { if let Some(epg) = guide.filter(&channel_ids) { new_epg.push(epg); diff --git a/src/processing/xtream_parser.rs b/src/processing/xtream_parser.rs index ec98510e4..deb5c4c53 100644 --- a/src/processing/xtream_parser.rs +++ b/src/processing/xtream_parser.rs @@ -215,7 +215,7 @@ impl XtreamStream { add_str_property_if_exists!(result, self.title, "title"); add_str_property_if_exists!(result, self.year, "year"); add_str_property_if_exists!(result, self.youtube_trailer, "youtube_trailer"); - add_str_property_if_exists!(result, self.epg_channel_id, "epg_channel_id"); + //add_str_property_if_exists!(result, self.epg_channel_id, "epg_channel_id"); add_i64_property_if_exists!(result, self.tv_archive, "tv_archive"); add_i64_property_if_exists!(result, self.tv_archive_duration, "tv_archive_duration"); if result.is_empty() { None } else { Some(result) } @@ -271,6 +271,7 @@ pub(crate) fn parse_xtream(cat_id_cnt: &AtomicI32, xtream_cluster: &XtreamCluste rec: "".to_string(), source: "".to_string(), // String::from(&stream.direct_source), url: if stream.direct_source.is_empty() { format!("{}/{}", stream_base_url, stream.get_stream_id())} else { String::from(&stream.direct_source) }, + epg_channel_id: stream.epg_channel_id.clone(), xtream_cluster: xtream_cluster.clone(), additional_properties: stream.get_additional_properties(), }), diff --git a/src/repository/xtream_repository.rs b/src/repository/xtream_repository.rs index abf68b52b..63964dea6 100644 --- a/src/repository/xtream_repository.rs +++ b/src/repository/xtream_repository.rs @@ -19,7 +19,6 @@ pub(crate) static COL_SERIES: &str = "series"; pub(crate) static COL_VOD: &str = "vod"; const LIVE_STREAM_FIELDS: &[&str] = &[ - "epg_channel_id" ]; const VIDEO_STREAM_FIELDS: &[&str] = &[ @@ -110,6 +109,10 @@ pub(crate) fn write_xtream_playlist(target: &ConfigTarget, cfg: &Config, playlis document.insert("direct_source".to_string(), Value::String(header.url.clone())); document.insert("thumbnail".to_string(), Value::String(header.logo_small.clone())); document.insert("custom_sid".to_string(), Value::String("".to_string())); + document.insert("epg_channel_id".to_string(), match &header.epg_channel_id { + None => Value::Null, + Some(epg_id) => Value::String(epg_id.to_owned()) + }); } XtreamCluster::Video => { document.insert("stream_id".to_string(), stream_id);