Release 1.0.0.11: repair broken virtual folders
This commit is contained in:
1 parent
0dbf00a055
commit
4bb222af8b
6 files changed
+64
-11
No files matched your search
@@ -1,5 +1,7 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using Jellyfin.Plugin.YandexMusic.Yandex;
|
using Jellyfin.Plugin.YandexMusic.Yandex;
|
||||||
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@@ -16,13 +18,20 @@ public class YandexMusicController : ControllerBase
|
|||||||
private static readonly ConcurrentDictionary<string, DateTimeOffset> Sessions = new();
|
private static readonly ConcurrentDictionary<string, DateTimeOffset> Sessions = new();
|
||||||
|
|
||||||
private readonly YandexMusicClient _client;
|
private readonly YandexMusicClient _client;
|
||||||
|
private readonly IServerApplicationPaths _paths;
|
||||||
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="YandexMusicController"/> class.
|
/// Initializes a new instance of the <see cref="YandexMusicController"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public YandexMusicController(YandexMusicClient client)
|
public YandexMusicController(
|
||||||
|
YandexMusicClient client,
|
||||||
|
IServerApplicationPaths paths,
|
||||||
|
ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
_client = client;
|
_client = client;
|
||||||
|
_paths = paths;
|
||||||
|
_libraryManager = libraryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Starts the device flow.</summary>
|
/// <summary>Starts the device flow.</summary>
|
||||||
@@ -88,6 +97,47 @@ public class YandexMusicController : ControllerBase
|
|||||||
connected ? null : "api.music.yandex.net недоступен");
|
connected ? null : "api.music.yandex.net недоступен");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes broken virtual-folder entries (e.g. a library left without an item id or paths),
|
||||||
|
/// which Jellyfin cannot delete through its own API.
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost("RepairLibraries")]
|
||||||
|
public ActionResult<RepairLibrariesResult> RepairLibraries()
|
||||||
|
{
|
||||||
|
var live = _libraryManager.GetVirtualFolders();
|
||||||
|
var deleted = new List<string>();
|
||||||
|
|
||||||
|
if (Directory.Exists(_paths.DefaultUserViewsPath))
|
||||||
|
{
|
||||||
|
foreach (var directory in Directory.EnumerateDirectories(_paths.DefaultUserViewsPath))
|
||||||
|
{
|
||||||
|
var name = Path.GetFileName(directory);
|
||||||
|
var info = live.FirstOrDefault(v => string.Equals(v.Name, name, StringComparison.OrdinalIgnoreCase));
|
||||||
|
var broken = info is null
|
||||||
|
|| string.IsNullOrEmpty(info.ItemId)
|
||||||
|
|| info.Locations.Length == 0;
|
||||||
|
if (broken)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.Delete(directory, true);
|
||||||
|
deleted.Add(name);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(500, new { error = ex.Message, name });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new RepairLibrariesResult(
|
||||||
|
deleted,
|
||||||
|
live.Where(v => !deleted.Contains(v.Name, StringComparer.OrdinalIgnoreCase))
|
||||||
|
.Select(v => v.Name)
|
||||||
|
.ToList());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Clears the saved token.</summary>
|
/// <summary>Clears the saved token.</summary>
|
||||||
[HttpPost("Logout")]
|
[HttpPost("Logout")]
|
||||||
public ActionResult Logout()
|
public ActionResult Logout()
|
||||||
@@ -115,3 +165,6 @@ public record DevicePollResult(string Status, string? Token, string? Error);
|
|||||||
|
|
||||||
/// <summary>Plugin status.</summary>
|
/// <summary>Plugin status.</summary>
|
||||||
public record StatusResult(bool Connected, bool HasToken, string? Error);
|
public record StatusResult(bool Connected, bool HasToken, string? Error);
|
||||||
|
|
||||||
|
/// <summary>Result of the broken-library cleanup.</summary>
|
||||||
|
public record RepairLibrariesResult(List<string> Deleted, List<string> Remaining);
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>1.0.0.10</Version>
|
<Version>1.0.0.11</Version>
|
||||||
<AssemblyVersion>1.0.0.10</AssemblyVersion>
|
<AssemblyVersion>1.0.0.11</AssemblyVersion>
|
||||||
<FileVersion>1.0.0.10</FileVersion>
|
<FileVersion>1.0.0.11</FileVersion>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<RootNamespace>Jellyfin.Plugin.YandexMusic</RootNamespace>
|
<RootNamespace>Jellyfin.Plugin.YandexMusic</RootNamespace>
|
||||||
<AssemblyName>Jellyfin.Plugin.YandexMusic</AssemblyName>
|
<AssemblyName>Jellyfin.Plugin.YandexMusic</AssemblyName>
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: "Yandex Music"
|
name: "Yandex Music"
|
||||||
guid: "f3b9626b-da14-4cbf-8ad1-33b92cfa6656"
|
guid: "f3b9626b-da14-4cbf-8ad1-33b92cfa6656"
|
||||||
version: "1.0.0.10"
|
version: "1.0.0.11"
|
||||||
targetAbi: "12.4.0.0"
|
targetAbi: "12.4.0.0"
|
||||||
framework: "net10.0"
|
framework: "net10.0"
|
||||||
overview: "Metadata for music from Yandex Music."
|
overview: "Metadata for music from Yandex Music."
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
Vendored
+5
-5
@@ -9,12 +9,12 @@
|
|||||||
"imageUrl": "",
|
"imageUrl": "",
|
||||||
"versions": [
|
"versions": [
|
||||||
{
|
{
|
||||||
"version": "1.0.0.10",
|
"version": "1.0.0.11",
|
||||||
"changelog": "Tag-based matching, artist/genre normalization, provider id repair, artist/genre pre-creation.",
|
"changelog": "Add admin endpoint to remove broken virtual folder entries.",
|
||||||
"targetAbi": "12.4.0.0",
|
"targetAbi": "12.4.0.0",
|
||||||
"sourceUrl": "https://git.midns.ru/1xDed/jellyfin-plugin-yandexmusic/raw/branch/main/dist/Jellyfin.Plugin.YandexMusic_1.0.0.10.zip",
|
"sourceUrl": "https://git.midns.ru/1xDed/jellyfin-plugin-yandexmusic/raw/branch/main/dist/Jellyfin.Plugin.YandexMusic_1.0.0.11.zip",
|
||||||
"checksum": "596e7fedd63ddc805a763900fd40592c",
|
"checksum": "c9ce5fe95bff06823e17b544d65bfe8f",
|
||||||
"timestamp": "2026-11-30T23:28:17Z"
|
"timestamp": "2026-11-30T23:48:50Z"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ set -euo pipefail
|
|||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
VERSION="1.0.0.10"
|
VERSION="1.0.0.11"
|
||||||
NAME="Jellyfin.Plugin.YandexMusic"
|
NAME="Jellyfin.Plugin.YandexMusic"
|
||||||
PUBLISH_DIR="publish"
|
PUBLISH_DIR="publish"
|
||||||
ARTIFACTS_DIR="${ARTIFACTS_DIR:-artifacts}"
|
ARTIFACTS_DIR="${ARTIFACTS_DIR:-artifacts}"
|
||||||
|
|||||||
Reference in new issue
Block a user