Files
tuliprox/shared/src/model/stream_info.rs
T
euzu 3c3c8df763 Added GeoIp config and update button to WebUI
Integrated GeoIp to stream Table
Fixed some HdHomerun issues
2025-10-28 18:42:09 +01:00

69 lines
2.2 KiB
Rust

use serde::{Deserialize, Serialize};
use crate::model::{M3uPlaylistItem, PlaylistEntry, PlaylistItemType, XtreamCluster, XtreamPlaylistItem};
use crate::utils::{current_time_secs, StringExt};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct StreamChannel {
pub virtual_id: u32,
pub provider_id: u32,
pub item_type: PlaylistItemType,
pub cluster: XtreamCluster,
pub group: String,
pub title: String,
pub url: String,
pub shared: bool,
}
impl XtreamPlaylistItem {
pub fn to_stream_channel(&self) -> StreamChannel {
StreamChannel {
virtual_id: self.virtual_id,
provider_id: self.provider_id,
item_type: self.item_type,
cluster: self.xtream_cluster,
group: self.group.clone(),
title: String::longest(self.title.as_str(), self.name.as_str()).to_string(),
url: self.url.clone(),
shared: false,
}
}
}
impl M3uPlaylistItem {
pub fn to_stream_channel(&self) -> StreamChannel {
StreamChannel {
virtual_id: self.virtual_id,
provider_id: self.get_provider_id().unwrap_or_default(),
item_type: self.item_type,
cluster: XtreamCluster::try_from(self.item_type).unwrap_or(XtreamCluster::Live),
group: self.group.clone(),
title: String::longest(self.title.as_str(), self.name.as_str()).to_string(),
url: self.url.clone(),
shared: false,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct StreamInfo {
pub username: String,
pub channel: StreamChannel,
pub provider: String,
pub addr: String,
pub user_agent: String,
pub ts: u64,
pub country: Option<String>,
}
impl StreamInfo {
pub fn new(username: &str, addr: &str, provider: &str, stream_channel: StreamChannel, user_agent: String, country: Option<String>) -> Self {
Self {
username: username.to_string(),
channel: stream_channel,
provider: provider.to_string(),
addr: addr.to_string(),
user_agent,
ts: current_time_secs(),
country,
}
}
}