diff --git a/src/download.rs b/src/download.rs index 56cb310c5..09df59190 100644 --- a/src/download.rs +++ b/src/download.rs @@ -30,7 +30,7 @@ fn prepare_file_path(input: &ConfigInput, working_dir: &String, action: &str) -> pub(crate) async fn get_m3u_playlist(cfg: &Config, input: &ConfigInput, working_dir: &String) -> (Vec, Vec) { let url = input.url.to_owned(); let persist_file_path = prepare_file_path(input, working_dir, ""); - match utils::get_input_text_content(input, working_dir,&url, persist_file_path).await { + match utils::get_input_text_content(input, working_dir, &url, persist_file_path).await { Ok(text) => { let lines = text.lines().map(String::from).collect(); (m3u_parser::parse_m3u(cfg, &lines), vec![]) @@ -49,7 +49,6 @@ pub(crate) async fn get_xtream_playlist(input: &ConfigInput, working_dir: &Strin let username = input.username.as_ref().map_or("", |v| v); let password = input.password.as_ref().map_or("", |v| v); let base_url = format!("{}/player_api.php?username={}&password={}", input.url, username, password); - let stream_base_url = format!("{}/{}/{}", input.url, username, password); let mut errors = vec![]; let category_id_cnt = AtomicI32::new(0); @@ -63,7 +62,7 @@ pub(crate) async fn get_xtream_playlist(input: &ConfigInput, working_dir: &Strin Ok(category_content) => { match utils::get_input_json_content(input, &stream_url, stream_file_path).await { Ok(stream_content) => { - match xtream_parser::parse_xtream(&category_id_cnt, xtream_cluster, &category_content, &stream_content, &stream_base_url) { + match xtream_parser::parse_xtream(&category_id_cnt, xtream_cluster, &category_content,input.url.as_str(),username, password, &stream_content) { Ok(sub_playlist_opt) => { if let Some(mut sub_playlist) = sub_playlist_opt { sub_playlist.drain(..).for_each(|group| playlist.push(group)); @@ -94,7 +93,6 @@ pub(crate) async fn get_xmltv(_cfg: &Config, input: &ConfigInput, working_dir: & } Err(err) => (None, vec![err]) } - } } } \ No newline at end of file diff --git a/src/model/model_m3u.rs b/src/model/model_m3u.rs index c1e98028f..606b52832 100644 --- a/src/model/model_m3u.rs +++ b/src/model/model_m3u.rs @@ -29,7 +29,7 @@ impl Display for XtreamCluster { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "{}", match self { XtreamCluster::Live => "live", - XtreamCluster::Video => "video", + XtreamCluster::Video => "movie", XtreamCluster::Series => "series", }) } diff --git a/src/processing/xtream_parser.rs b/src/processing/xtream_parser.rs index c367be470..679014ec8 100644 --- a/src/processing/xtream_parser.rs +++ b/src/processing/xtream_parser.rs @@ -245,8 +245,10 @@ fn process_streams(xtream_cluster: &XtreamCluster, streams: &Value) -> Result Result>, M3uFilterError> { + url: &str, + username: &str, + password: &str, + streams: &Value) -> Result>, M3uFilterError> { match process_category(category) { Ok(mut categories) => { return match process_streams(xtream_cluster, streams) { @@ -275,7 +277,17 @@ pub(crate) fn parse_xtream(cat_id_cnt: &AtomicI32, // 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())) + let stream_base_url = match xtream_cluster { + XtreamCluster::Live => format!("{}/live/{}/{}/{}.ts", url, username, password, &stream.get_stream_id()), + XtreamCluster::Video => { + let ext = stream.container_extension.as_ref().map_or("mp4", |e| e.as_str()); + format!("{}/live/{}/{}/{}.{}", url, username, password, &stream.get_stream_id(), ext) + }, + XtreamCluster::Series => + format!("{}/player_api.php?username={}&password={}&action=get_series_info&series_id={}", + url, username, password, &stream.get_stream_id()) + }; + Rc::new(stream_base_url) } else { Rc::clone(&stream.direct_source) },