dlna: version bump

This commit is contained in:
Jonas Rabenstein 2025-11-28 14:43:57 +01:00
commit c21b2e1358
5 changed files with 38 additions and 139 deletions

6
flake.lock generated
View file

@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1758198701,
"narHash": "sha256-7To75JlpekfUmdkUZewnT6MoBANS0XVypW6kjUOXQwc=",
"lastModified": 1764242076,
"narHash": "sha256-sKoIWfnijJ0+9e4wRvIgm/HgE27bzwQxcEmo2J/gNpI=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0147c2f1d54b30b5dd6d4a8c8542e8d7edf93b5d",
"rev": "2fad6eac6077f03fe109c4d4eb171cf96791faa4",
"type": "github"
},
"original": {

View file

@ -97,7 +97,7 @@
module =
name: defs:
{ ... }:
builtins.trace "module: jellyfin.${name}" {
{
imports = lib.toList defs;
config.nixpkgs.overlays = [ overlay ];
};

View file

@ -39,7 +39,9 @@ let
mkPlugin = info: result: buildDotnetModule result;
inherit jellyfin;
ignore = builtins.attrNames helper ++ [
"override" "overrideAttrs" "overrideDerivation"
"override"
"overrideAttrs"
"overrideDerivation"
];
};
@ -57,8 +59,8 @@ let
acc: name: value:
acc ++ lib.optional (value == "directory") name
) [ ] (builtins.readDir ("${info.src}/src"));
dotnet-sdk = dotnetCorePackages.sdk_8_0;
dotnet-runtime = dotnetCorePackages.aspnetcore_8_0;
dotnet-sdk = dotnetCorePackages.sdk_9_0;
dotnet-runtime = jellyfin.dotnet-runtime;
dontDotnetBuild = true;
dontDotnetInstall = true;
project = "Jellyfin.Plugin.${capitalize lib.strings.toUpper info.name}";
@ -142,12 +144,30 @@ let
meta = meta jellyfin.meta // meta info;
};
info = helper // defaults // callPackage plugin ({ inherit info; } // args);
in info.mkPlugin info (lib.attrsets.removeAttrs info info.ignore);
in
info.mkPlugin info (lib.attrsets.removeAttrs info info.ignore);
functor = args: (drv args).overrideAttrs (final: prev: {
passthru = builtins.trace "override passthru" (prev.passthru or {}) // {
in-version = { version, rev ? null, hash ? null }@args':
callPackage functor (builtins.removeAttrs args [ "version" "rev" "hash" ] // args');
functor =
args:
(drv args).overrideAttrs (
final: prev: {
passthru = (prev.passthru or { }) // {
in-version =
{
version,
rev ? null,
hash ? null,
}@args':
callPackage functor (
builtins.removeAttrs args [
"version"
"rev"
"hash"
]
// args'
);
};
});
in lib.trivial.mirrorFunctionArgs plugin functor
}
);
in
lib.trivial.mirrorFunctionArgs plugin functor

View file

@ -3,6 +3,10 @@ let
hash = "sha256-5YUX+w4n3nBhAkdgjF9D5yY/jzRKxpW+mTQCBluzsVI=";
rev = "v8";
};
v."10.0.0.0" = {
hash = "sha256-pPhMmH17RKktIX16ozSxsigxo6tU8tlST4IAm3vpjrw=";
rev = "v10";
};
current =
lib:
lib.lists.fold (acc: v: if lib.strings.versionOlder acc v then v else acc) "0.0.0" (

View file

@ -1,125 +0,0 @@
diff --git a/src/Jellyfin.Plugin.Dlna/Didl/DidlBuilder.cs b/src/Jellyfin.Plugin.Dlna/Didl/DidlBuilder.cs
index 150fb49..9160d8a 100644
--- a/src/Jellyfin.Plugin.Dlna/Didl/DidlBuilder.cs
+++ b/src/Jellyfin.Plugin.Dlna/Didl/DidlBuilder.cs
@@ -239,6 +239,17 @@ public class DidlBuilder
writer.WriteFullEndElement();
}
+ private string sanitize(string input)
+ {
+ var valid = input.Where(ch => System.Xml.XmlConvert.IsXmlChar(ch)).ToArray();
+ if (valid.Length == input.Length)
+ {
+ return input;
+ }
+ _logger.LogInformation("Sanitized: {0} (was: {1})", valid, input.Where(ch => true).ToArray());
+ return new string(valid);
+ }
+
private void AddVideoResource(XmlWriter writer, BaseItem video, string deviceId, Filter filter, StreamInfo? streamInfo = null)
{
if (streamInfo is null)
@@ -1009,7 +1020,7 @@ public class DidlBuilder
writer.WriteStartElement("upnp", "artist", NsUpnp);
writer.WriteAttributeString("role", "AlbumArtist");
- writer.WriteString(name);
+ writer.WriteString(sanitize(name));
writer.WriteFullEndElement();
}
@@ -1023,7 +1034,7 @@ public class DidlBuilder
{
try
{
- writer.WriteElementString(prefix, name, namespaceUri, value);
+ writer.WriteElementString(prefix, name, namespaceUri, sanitize(value));
}
catch (XmlException ex)
{
diff --git a/src/Jellyfin.Plugin.Dlna/PlayTo/PlayToController.cs b/src/Jellyfin.Plugin.Dlna/PlayTo/PlayToController.cs
index 4d822e2..9105d46 100644
--- a/src/Jellyfin.Plugin.Dlna/PlayTo/PlayToController.cs
+++ b/src/Jellyfin.Plugin.Dlna/PlayTo/PlayToController.cs
@@ -386,34 +386,38 @@ public class PlayToController : ISessionController, IDisposable
? null :
_userManager.GetUserById(command.ControllingUserId);
- var items = new List<BaseItem>();
- foreach (var id in command.ItemIds)
- {
- AddItemFromId(id, items);
- }
-
var startIndex = command.StartIndex ?? 0;
- int len = items.Count - startIndex;
- if (startIndex > 0)
- {
- items = items.GetRange(startIndex, len);
- }
-
- var playlist = new PlaylistItem[len];
-
- // Not nullable enabled - so this is required.
- playlist[0] = CreatePlaylistItem(
- items[0],
- user,
- command.StartPositionTicks ?? 0,
- command.MediaSourceId ?? string.Empty,
- command.AudioStreamIndex,
- command.SubtitleStreamIndex);
+ var playlist = new List<PlaylistItem>();
+ var first = true;
+ foreach (var id in command.ItemIds) {
+ var item = _libraryManager.GetItemById(id);
+ if (item?.MediaType != MediaType.Audio && item?.MediaType != MediaType.Video)
+ {
+ continue;
+ }
- for (int i = 1; i < len; i++)
- {
- playlist[i] = CreatePlaylistItem(items[i], user, 0, string.Empty, null, null);
- }
+ if (startIndex > 0) {
+ startIndex -= 1;
+ continue;
+ }
+
+ PlaylistItem? playlistItem = null;
+ try {
+ playlistItem = CreatePlaylistItem(item, user,
+ first ? (command.StartPositionTicks ?? 0) : 0,
+ first ? (command.MediaSourceId ?? string.Empty) : string.Empty,
+ first ? command.AudioStreamIndex : null,
+ first ? command.SubtitleStreamIndex : null);
+ } catch (System.NullReferenceException) {
+ _logger.LogError("{0}: could not create playlist item.", item.Path ?? "<unknown>");
+ }
+ first = false;
+
+ if (playlistItem != null)
+ {
+ playlist.Add(playlistItem);
+ }
+ }
_logger.LogDebug("{0} - Playlist created", _session.DeviceName);
@@ -509,15 +513,6 @@ public class PlayToController : ISessionController, IDisposable
return info.IsDirectStream;
}
- private void AddItemFromId(Guid id, List<BaseItem> list)
- {
- var item = _libraryManager.GetItemById(id);
- if (item?.MediaType == MediaType.Audio || item?.MediaType == MediaType.Video)
- {
- list.Add(item);
- }
- }
-
private PlaylistItem CreatePlaylistItem(
BaseItem item,
User? user,