refactor: use arbitrary strings as playlist ids.

This commit is contained in:
redxef 2024-10-30 19:33:01 +01:00
parent b5bab52c6b
commit 4993bdfa4c
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921
5 changed files with 10 additions and 22 deletions

View file

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Serialization;
namespace Jellyfin.Plugin.SmartPlaylist {
public class PluginConfiguration : BasePluginConfiguration {

View file

@ -5,23 +5,11 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Playlists;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.IO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
using MediaBrowser.Model.Entities;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Playlists;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Playlists;
using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging;
using Jellyfin.Plugin.SmartPlaylist.Lisp;
using Jellyfin.Plugin.SmartPlaylist.Lisp.Compiler;
@ -93,7 +81,7 @@ namespace Jellyfin.Plugin.SmartPlaylist.ScheduledTasks {
}
}
private SmartPlaylistId CreateNewPlaylist(string name, UserId userId) {
private PlaylistId CreateNewPlaylist(string name, UserId userId) {
_logger.LogDebug("Creating playlist '{0}'", name);
var req = new PlaylistCreationRequest {
Name = name,

View file

@ -50,7 +50,7 @@ namespace Jellyfin.Plugin.SmartPlaylist {
public bool Enabled { get; set; }
public SmartPlaylistDto() {
Id = Guid.NewGuid();
Id = "";
Playlists = [];
Name = Id.ToString();
Program = DEFAULT_PROGRAM;
@ -62,7 +62,7 @@ namespace Jellyfin.Plugin.SmartPlaylist {
if (info.GetValue("Id", typeof(SmartPlaylistId)) is SmartPlaylistId _Id) {
Id = _Id;
} else {
Id = Guid.NewGuid();
Id = "";
}
if (info.GetValue("Playlists", typeof(SmartPlaylistLinkDto[])) is SmartPlaylistLinkDto[] _Playlists) {
Playlists = _Playlists;

View file

@ -19,7 +19,12 @@ namespace Jellyfin.Plugin.SmartPlaylist {
if (dto == null) {
throw new ApplicationException("");
}
if (dto.Id == Path.GetFileNameWithoutExtension(filename)) {
dto.Id = Path.GetFileNameWithoutExtension(filename);
}
if (dto.Filename != filename) {
dto.Filename = filename;
}
return dto;
}
public async Task<SmartPlaylistDto> GetSmartPlaylistAsync(SmartPlaylistId smartPlaylistId) {

View file

@ -2,4 +2,4 @@ global using System;
global using UserId = System.Guid;
global using PlaylistId = System.Guid;
global using SmartPlaylistId = System.Guid;
global using SmartPlaylistId = string;