Skip to content

Commit

Permalink
Create fallback single-stream catch-up entry if no EPG available.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevinjil committed Jun 27, 2022
1 parent eff25ce commit e273379
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Jellyfin.Xtream/CatchupChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,35 @@ await client.GetLiveStreamsByCategoryAsync(plugin.Creds, categoryId, cancellatio
EpgListings epgs = await client.GetEpgInfoAsync(plugin.Creds, channelId, cancellationToken).ConfigureAwait(false);
List<ChannelItemInfo> items = new List<ChannelItemInfo>();

// Create fallback single-stream catch-up if no EPG is available.
if (epgs.Listings.Count == 0)
{
DateTime now = DateTime.UtcNow;
DateTime start = now.AddDays(-channel.TvArchiveDuration);
int duration = channel.TvArchiveDuration * 24 * 60;
return new ChannelItemResult()
{
Items = new List<ChannelItemInfo>()
{
new ChannelItemInfo()
{
ContentType = ChannelMediaContentType.TvExtra,
FolderType = ChannelFolderType.Container,
Id = $"fallback-{channelId}",
IsLiveStream = false,
MediaSources = new List<MediaSourceInfo>()
{
plugin.StreamService.GetMediaSourceInfo(StreamType.CatchUp, channelString, start: start, durationMinutes: duration)
},
MediaType = ChannelMediaType.Video,
Name = $"No EPG available",
Type = ChannelItemType.Media,
}
},
TotalRecordCount = items.Count
};
}

// Include all EPGs that start during the maximum cache interval of Jellyfin for channels.
DateTime startBefore = DateTime.UtcNow.AddHours(3);
DateTime startAfter = DateTime.UtcNow.AddDays(-channel.TvArchiveDuration);
Expand Down

0 comments on commit e273379

Please sign in to comment.