mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-30 10:42:29 +01:00
Writing m3u file with index and url database, rewriting response for reverse proxy
This commit is contained in:
@@ -55,6 +55,7 @@ fn skip_digit(it: &mut std::str::Chars) -> Option<char> {
|
||||
|
||||
fn create_empty_playlistitem_header(content: &String, url: String) -> PlaylistItemHeader {
|
||||
PlaylistItemHeader {
|
||||
stream_id: 0,
|
||||
id: default_as_empty_rc_str(),
|
||||
name: default_as_empty_rc_str(),
|
||||
logo: default_as_empty_rc_str(),
|
||||
@@ -102,16 +103,22 @@ fn process_header(video_suffixes: &Vec<&str>, content: &String, url: String) ->
|
||||
let token = token_till(&mut it, '=');
|
||||
if let Some(t) = token {
|
||||
let value = token_value(&mut it);
|
||||
process_header_fields!(plih, t.as_str(),
|
||||
(id, "tvg-id"),
|
||||
(group, "group-title"),
|
||||
(name, "tvg-name"),
|
||||
(parent_code, "parent-code"),
|
||||
(audio_track, "audio-track"),
|
||||
(logo, "tvg-logo"),
|
||||
(logo_small, "tvg-logo-small"),
|
||||
(time_shift, "timeshift"),
|
||||
(rec, "tvg-rec"); value)
|
||||
if t.as_str().eq("str-id") {
|
||||
if let Ok(stream_id) = value.to_string().parse::<u32>() {
|
||||
plih.stream_id = stream_id;
|
||||
}
|
||||
} else {
|
||||
process_header_fields!(plih, t.as_str(),
|
||||
(id, "tvg-id"),
|
||||
(group, "group-title"),
|
||||
(name, "tvg-name"),
|
||||
(parent_code, "parent-code"),
|
||||
(audio_track, "audio-track"),
|
||||
(logo, "tvg-logo"),
|
||||
(logo_small, "tvg-logo-small"),
|
||||
(time_shift, "timeshift"),
|
||||
(rec, "tvg-rec"); value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,13 +160,10 @@ fn extract_id_from_url(url: &str) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
pub(crate) fn parse_m3u(cfg: &Config, lines: &Vec<String>) -> Vec<PlaylistGroup> {
|
||||
let mut groups: std::collections::HashMap<Rc<String>, Vec<PlaylistItem>> = std::collections::HashMap::new();
|
||||
let mut sort_order: Vec<Rc<String>> = vec![];
|
||||
pub(crate) fn consume_m3u<F: FnMut(PlaylistItem)>(cfg: &Config, lines: &Vec<String>, mut visit: F) {
|
||||
let mut header: Option<String> = None;
|
||||
let mut group: Option<String> = None;
|
||||
|
||||
let mut playlist = Vec::new();
|
||||
let video_suffixes = cfg.video.as_ref().unwrap().extensions.iter().map(|ext| ext.as_str()).collect();
|
||||
for line in lines {
|
||||
if line.starts_with("#EXTINF") {
|
||||
@@ -183,12 +187,18 @@ pub(crate) fn parse_m3u(cfg: &Config, lines: &Vec<String>) -> Vec<PlaylistGroup>
|
||||
item.header.borrow_mut().group = Rc::new(string_utils::get_title_group(current_title.as_str()));
|
||||
}
|
||||
}
|
||||
playlist.push(item);
|
||||
visit(item);
|
||||
}
|
||||
header = None;
|
||||
group = None;
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn parse_m3u(cfg: &Config, lines: &Vec<String>) -> Vec<PlaylistGroup> {
|
||||
let mut groups: std::collections::HashMap<Rc<String>, Vec<PlaylistItem>> = std::collections::HashMap::new();
|
||||
let mut sort_order: Vec<Rc<String>> = vec![];
|
||||
let mut playlist = Vec::new();
|
||||
consume_m3u(cfg, lines, |item| playlist.push(item));
|
||||
playlist.drain(..).for_each(|item| {
|
||||
let key = Rc::clone(&item.header.borrow().group);
|
||||
// let key2 = String::from(&item.header.group);
|
||||
|
||||
Reference in New Issue
Block a user