Skip to content

Commit

Permalink
feat: add Use CUID for channel id
Browse files Browse the repository at this point in the history
  • Loading branch information
SenexCrenshaw committed Feb 8, 2024
1 parent 4c57ea2 commit d1130f3
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class UpdateSettingRequest : IRequest<UpdateSettingResponse>
public bool? M3UStationId { get; set; }
public bool? M3UUseChnoForId { get; set; }
public bool? M3UIgnoreEmptyEPGID { get; set; }
public bool? M3UUseCUIDForChannelID { get; set; }
public bool? PrettyEPG { get; set; }
public int? MaxConnectRetry { get; set; }
public int? MaxConnectRetryTimeMS { get; set; }
Expand Down Expand Up @@ -244,6 +245,10 @@ private async Task<bool> UpdateSetting(Setting currentSetting, UpdateSettingRequ
currentSetting.M3UIgnoreEmptyEPGID = (bool)request.M3UIgnoreEmptyEPGID;
}

if (request.M3UUseCUIDForChannelID != null)
{
currentSetting.M3UUseCUIDForChannelID = (bool)request.M3UUseCUIDForChannelID;
}

if (request.MaxLogFiles != null)
{
Expand Down
25 changes: 15 additions & 10 deletions StreamMaster.Application/StreamGroups/Queries/GetStreamGroupM3U.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using StreamMaster.Application.Common.Extensions;
using StreamMaster.Domain.Authentication;
using StreamMaster.SchedulesDirect.Domain.Enums;
using StreamMaster.SchedulesDirect.Helpers;

using System.Collections.Concurrent;
using System.Net;
Expand Down Expand Up @@ -155,26 +154,28 @@ private int GetNextChNo(int chNo)

private (int ChNo, string m3uLine) BuildM3ULineForVideoStream(VideoStreamDto videoStream, string url, GetStreamGroupM3U request, int cid, Setting setting)
{
int epgNumber = EPGHelper.DummyId;
string stationId;

string epgChannelId;

string channelId = string.Empty;
string tvgID = string.Empty;

if (string.IsNullOrEmpty(videoStream.User_Tvg_ID))
{
stationId = videoStream.User_Tvg_group;
epgChannelId = videoStream.User_Tvg_group;
}
else
{
if (epgHelper.IsValidEPGId(videoStream.User_Tvg_ID))
{
(epgNumber, stationId) = videoStream.User_Tvg_ID.ExtractEPGNumberAndStationId();
(_, epgChannelId) = videoStream.User_Tvg_ID.ExtractEPGNumberAndStationId();
MxfService? service = schedulesDirectDataService.GetService(videoStream.User_Tvg_ID);
channelId = service?.CallSign ?? stationId;
tvgID = service?.CallSign ?? epgChannelId;
channelId = setting.M3UUseCUIDForChannelID ? videoStream.Id : tvgID;
}
else
{
stationId = videoStream.User_Tvg_ID;
epgChannelId = tvgID = channelId = videoStream.User_Tvg_ID;
}
}

Expand Down Expand Up @@ -212,15 +213,19 @@ private int GetNextChNo(int chNo)

if (setting.M3UUseChnoForId)
{
channelId = videoStream.User_Tvg_chno.ToString();
tvgID = videoStream.User_Tvg_chno.ToString();
if (!setting.M3UUseCUIDForChannelID)
{
channelId = tvgID;
}
}

List<string> fieldList = [$"#EXTINF:0 CUID=\"{videoStream.Id}\""];

fieldList.Add($"tvg-name=\"{name}\"");

fieldList.Add($"channel-id=\"{channelId}\"");
fieldList.Add($"tvg-id=\"{channelId}\"");
fieldList.Add($"tvg-id=\"{tvgID}\"");

fieldList.Add($"tvg-logo=\"{videoStream.User_Tvg_logo}\"");

Expand All @@ -231,7 +236,7 @@ private int GetNextChNo(int chNo)

if (setting.M3UStationId)
{
string toDisplay = string.IsNullOrEmpty(videoStream.StationId) ? stationId : videoStream.StationId;
string toDisplay = string.IsNullOrEmpty(videoStream.StationId) ? epgChannelId : videoStream.StationId;
fieldList.Add($"tvc-guide-stationid=\"{toDisplay}\"");
}

Expand Down
1 change: 1 addition & 0 deletions StreamMaster.Domain/Common/Setting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class M3USettings
//public bool M3UFieldTvgName { get; set; } = true;
public bool M3UIgnoreEmptyEPGID { get; set; } = true;
public bool M3UUseChnoForId { get; set; } = true;
public bool M3UUseCUIDForChannelID { get; set; } = false;
public bool M3UStationId { get; set; } = false;
}

Expand Down
1 change: 1 addition & 0 deletions StreamMaster.Domain/Dto/VideoStreamDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace StreamMaster.Domain.Dto;
[RequireAll]
public class VideoStreamDto : BaseVideoStreamDto, IMapFrom<VideoStream>
{
public bool IsReadOnly { get; set; } = false;
public int MaxStreams { get; set; } = 0;
public bool IsLoading { get; set; } = false;
public int ChannelGroupId { get; set; } = 0;
Expand Down
7 changes: 7 additions & 0 deletions StreamMaster.SchedulesDirect/Converters/XMLTVBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,13 @@ private XmltvChannel BuildXmltvChannel(MxfService mxfService)
id = mxfService.ChNo.ToString();
}

//if (settings.M3UUseCUIDForChannelID)
//{
// VideoStreamConfig? vc = mxfService.extras["videoStreamConfig"] as VideoStreamConfig;
// id = vc.Id;
// //id = mxfService.ChNo.ToString();
//}

// initialize the return channel
XmltvChannel ret = new()
{
Expand Down
11 changes: 5 additions & 6 deletions streammasterwebui/features/settings/FilesEPGM3USettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ export function FilesEPGM3USettings(): React.ReactElement {
{getCheckBoxLine({ field: 'cacheIcons', selectedCurrentSettingDto, onChange })}
{getCheckBoxLine({ field: 'videoStreamAlwaysUseEPGLogo', selectedCurrentSettingDto, onChange })}
{getInputTextLine({ field: 'dummyRegex', selectedCurrentSettingDto, onChange })}
{getCheckBoxLine({ field: 'm3UIgnoreEmptyEPGID', selectedCurrentSettingDto, onChange })}
{getCheckBoxLine({ field: 'm3UFieldGroupTitle', selectedCurrentSettingDto, onChange })}
{getCheckBoxLine({ field: 'm3UUseChnoForId', selectedCurrentSettingDto, onChange })}
{getCheckBoxLine({ field: 'm3UStationId', selectedCurrentSettingDto, onChange })}
{getCheckBoxLine({ field: 'm3UUseCUIDForChannelID', selectedCurrentSettingDto, onChange })}
<Fieldset className="mt-4 pt-10" collapsed legend={GetMessage('nameregexSettings')} toggleable>
<SettingsNameRegexDataSelector data={settingsQuery.data?.nameRegex} />
</Fieldset>
<Fieldset className="mt-4 pt-10" collapsed legend={GetMessage('m3uSettings')} toggleable>
{getCheckBoxLine({ field: 'm3UIgnoreEmptyEPGID', selectedCurrentSettingDto, onChange })}
{getCheckBoxLine({ field: 'm3UFieldGroupTitle', selectedCurrentSettingDto, onChange })}
{getCheckBoxLine({ field: 'm3UUseChnoForId', selectedCurrentSettingDto, onChange })}
{getCheckBoxLine({ field: 'm3UStationId', selectedCurrentSettingDto, onChange })}
</Fieldset>
</Fieldset>
);
}
6 changes: 3 additions & 3 deletions streammasterwebui/lib/iptvApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1623,10 +1623,7 @@ export type VideoStreamHandlers = 0 | 1 | 2;
export type BaseVideoStreamDto = {
id: string;
shortId: string;
isActive: boolean;
isDeleted: boolean;
isHidden: boolean;
isReadOnly: boolean;
isUserCreated: boolean;
m3UFileId: number;
m3UFileName: string;
Expand All @@ -1650,6 +1647,7 @@ export type BaseVideoStreamDto = {
videoStreamHandler: VideoStreamHandlers;
};
export type VideoStreamDto = BaseVideoStreamDto & {
isReadOnly: boolean;
maxStreams: number;
isLoading: boolean;
channelGroupId: number;
Expand Down Expand Up @@ -1768,6 +1766,7 @@ export type M3USettings = {
m3UFieldGroupTitle?: boolean;
m3UIgnoreEmptyEPGID?: boolean;
m3UUseChnoForId?: boolean;
m3UUseCUIDForChannelID?: boolean;
m3UStationId?: boolean;
};
export type TestSettings = {
Expand Down Expand Up @@ -1899,6 +1898,7 @@ export type UpdateSettingRequest = {
m3UStationId?: boolean | null;
m3UUseChnoForId?: boolean | null;
m3UIgnoreEmptyEPGID?: boolean | null;
m3UUseCUIDForChannelID?: boolean | null;
prettyEPG?: boolean | null;
maxConnectRetry?: number | null;
maxConnectRetryTimeMS?: number | null;
Expand Down
2 changes: 1 addition & 1 deletion streammasterwebui/lib/locales/MessagesEn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const MessagesEn: messages_enType = {
enablePrometheus: 'Enable Prometheus Metrics',
loading: 'Loading',
set: 'Set',

m3UUseCUIDForChannelID: 'Use CUID for channel id',
settings: 'Settings',

show: 'Show',
Expand Down

0 comments on commit d1130f3

Please sign in to comment.