Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Jellyfin.Plugin.CinemaMode/IntroManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,14 @@ public List<Movie> QueryPreRolls(PreRollSelectionConfig? SelectionConfig)
public IntroInfo? GetPreRoll()
{
List<Movie> preRolls;

Logger.LogDebug($"|jellyfin-cinema-mode| Fetching Pre-Rolls Type: {this.Category} User: {this.User} Library: {this.PreRollLibrary}");

foreach (PreRollSelectionConfig SelectConfig in this.PreRollsSelections)
{
preRolls = QueryPreRolls(SelectConfig);
if (preRolls.Count > 0) {
if (preRolls.Count > 0)
{
int idx = this.RNG.Next(preRolls.Count);
Video preRoll = preRolls.ElementAt(idx);
return new IntroInfo { ItemId = preRoll.Id, Path = preRoll.Path };
Expand Down Expand Up @@ -423,9 +427,10 @@ public IntroManager(ILogger logger)

public IEnumerable<IntroInfo> Get(BaseItem item, User user)
{

Logger.LogDebug("|jellyfin-cinema-mode| GET called for item: {ItemName} by user: {UserName}", item.Name, user.Username);
if (Plugin.Instance.Configuration.TrailerPreRollsLibrary != "-")
{
Logger.LogDebug("|jellyfin-cinema-mode| Fetching Trailer Pre-Roll from Library {Library}", Plugin.Instance.Configuration.TrailerPreRollsLibrary);
IntroInfo? trailerPreRoll = null;
try
{
Expand All @@ -440,17 +445,22 @@ public IEnumerable<IntroInfo> Get(BaseItem item, User user)

if (trailerPreRoll != null)
{
Logger.LogDebug("|jellyfin-cinema-mode| Trailer Pre-Roll ItemId: {ItemId}, Path: {Path}", trailerPreRoll.ItemId, trailerPreRoll.Path);

yield return trailerPreRoll;
}
}

if (Plugin.Instance.Configuration.NumberOfTrailers > 0)
{
Logger.LogDebug("|jellyfin-cinema-mode| Fetching Trailers");
List<IntroInfo> trailers = new List<IntroInfo>();
try
{
TrailerSelector trailerSelector = new TrailerSelector(item, user, Plugin.Instance.Configuration, this.Logger);
trailers = trailerSelector.GetTrailers().ToList();

Logger.LogDebug("|jellyfin-cinema-mode| Fetched {Count} Trailers for item: {ItemName} by user: {UserName}", trailers.Count, item.Name, user.Username);
}
catch (System.Exception e)
{
Expand All @@ -466,6 +476,8 @@ public IEnumerable<IntroInfo> Get(BaseItem item, User user)

if (Plugin.Instance.Configuration.FeaturePreRollsLibrary != "-")
{
Logger.LogDebug("|jellyfin-cinema-mode| Fetching Feature Pre-Roll from Library {Library}", Plugin.Instance.Configuration.FeaturePreRollsLibrary);

IntroInfo? featurePreRoll = null;
try
{
Expand Down
5 changes: 5 additions & 0 deletions Jellyfin.Plugin.CinemaMode/IntroProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,23 @@ public IntroProvider(ILogger<IntroProvider> logger)

public Task<IEnumerable<IntroInfo>> GetIntros(BaseItem item, User user)
{
Logger.LogDebug("|jellyfin-cinema-mode| GetIntros called for item: {ItemName} by user: {UserName}", item.Name, user.Username);

// Check item type, for now just pre roll movies
if (item is not MediaBrowser.Controller.Entities.Movies.Movie)
{
Logger.LogDebug("|jellyfin-cinema-mode| Item is not a movie, returning empty intros.");
return Task.FromResult(Enumerable.Empty<IntroInfo>());
}

Logger.LogDebug("|jellyfin-cinema-mode| Item is a movie, fetching intros.");
IntroManager introManager = new IntroManager(this.Logger);
return Task.FromResult(introManager.Get(item, user));
}

public IEnumerable<string> GetAllIntroFiles()
{
Logger.LogDebug("|jellyfin-cinema-mode| GetAllIntroFiles called");
// not implemented
return Enumerable.Empty<string>();
}
Expand Down