using System;
using System.Collections.Generic;
using MediaBrowser.Controller.Notifications;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Notifications;
namespace Jellyfin.Plugin.Simkl.Services
{
///
public class SimklNotificationsFactory : INotificationTypeFactory
{
///
/// Notification category.
///
public const string NotificationCategory = "Simkl Scrobbling";
///
/// Notification movie type.
///
public const string NotificationMovieType = "SimklScrobblingMovie";
///
/// Notification show type.
///
public const string NotificationShowType = "SimklScrobblingShow";
///
public IEnumerable GetNotificationTypes()
{
yield return new NotificationTypeInfo
{
Type = NotificationMovieType,
Name = "Scrobbling Movie",
Category = NotificationCategory,
Enabled = true,
IsBasedOnUserEvent = false
};
yield return new NotificationTypeInfo
{
Type = NotificationShowType,
Name = "Scrobbling TV Show",
Category = NotificationCategory,
Enabled = true,
IsBasedOnUserEvent = false
};
}
///
/// Get notification request.
///
/// Item.
/// USer id.
/// The notification request.
public static NotificationRequest GetNotificationRequest(BaseItemDto item, Guid userId)
{
var nr = new NotificationRequest
{
Date = DateTime.UtcNow,
UserIds = new[] { userId },
SendToUserMode = SendToUserType.Custom
};
// TODO: Set url parameter to simkl's movie url
if (item.IsMovie == true || item.Type == "Movie")
{
nr.NotificationType = NotificationMovieType;
nr.Name = "Movie Scrobbled to Simkl";
nr.Description = "The movie " + item.Name;
nr.Description += " has been scrobbled to your account";
}
if (item.IsSeries == true || item.Type == "Episode")
{
nr.NotificationType = NotificationShowType;
nr.Name = "Episode Scrobbled to Simkl";
nr.Description = item.SeriesName;
nr.Description += " S" + item.ParentIndexNumber + ":E" + item.IndexNumber;
nr.Description += " - " + item.Name;
nr.Description += " has been scrobbled to your account";
}
return nr;
}
}
}