├── .gitignore ├── .gitattributes ├── .github ├── renovate.json └── workflows │ ├── sync-labels.yaml │ ├── command-dispatch.yaml │ ├── test.yaml │ ├── build.yaml │ ├── scan-codeql.yaml │ ├── changelog.yaml │ ├── publish.yaml │ └── command-rebase.yaml ├── Directory.Build.props ├── Jellyfin.Plugin.ClassicTV.json ├── Jellyfin.Plugin.ClassicTV ├── Jellyfin.Plugin.ClassicTV.json ├── Configuration │ ├── PluginConfiguration.cs │ └── configPage.html ├── Jellyfin.Plugin.ClassicTV.csproj ├── Plugin.cs ├── EpisodeMixer.cs ├── EpisodeFecthcer.cs └── GeneratePlaylistTask.cs ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── Jellyfin.Plugin.ClassicTV.sln ├── IUserDataManager.cs ├── README.md ├── jellyfin.ruleset ├── IUserManager.cs ├── .editorconfig ├── ILibraryManager.cs └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | obj/ 3 | .vs/ 4 | .idea/ 5 | artifacts 6 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "github>jellyfin/.github//renovate-presets/default" 5 | ] 6 | } -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 0.0.0.0 4 | 0.0.0.0 5 | 0.0.0.0 6 | 7 | 8 | -------------------------------------------------------------------------------- /.github/workflows/sync-labels.yaml: -------------------------------------------------------------------------------- 1 | name: '🏷️ Sync labels' 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | call: 8 | uses: jellyfin/jellyfin-meta-plugins/.github/workflows/sync-labels.yaml@master 9 | secrets: 10 | token: ${{ secrets.GITHUB_TOKEN }} 11 | -------------------------------------------------------------------------------- /.github/workflows/command-dispatch.yaml: -------------------------------------------------------------------------------- 1 | # Allows for the definition of PR and Issue /commands 2 | name: '📟 Slash Command Dispatcher' 3 | 4 | on: 5 | issue_comment: 6 | types: 7 | - created 8 | 9 | jobs: 10 | call: 11 | uses: jellyfin/jellyfin-meta-plugins/.github/workflows/command-dispatch.yaml@master 12 | secrets: 13 | token: . 14 | -------------------------------------------------------------------------------- /Jellyfin.Plugin.ClassicTV.json: -------------------------------------------------------------------------------- 1 | { 2 | "category": "General", 3 | "guid": "eb5d7894-8eef-4b36-aa6f-5d124e828ce1", 4 | "name": "ClassicTV", 5 | "description": "Plugin para mezclar episodios de series seleccionadas manteniendo el orden interno de cada serie.", 6 | "owner": "ClassicTV Plugin", 7 | "version": "1.0.0.0", 8 | "targetAbi": "10.9.0.0" 9 | } 10 | -------------------------------------------------------------------------------- /Jellyfin.Plugin.ClassicTV/Jellyfin.Plugin.ClassicTV.json: -------------------------------------------------------------------------------- 1 | { 2 | "category": "General", 3 | "guid": "eb5d7894-8eef-4b36-aa6f-5d124e828ce1", 4 | "name": "ClassicTV", 5 | "description": "Plugin para mezclar episodios de series seleccionadas manteniendo el orden interno de cada serie.", 6 | "owner": "ClassicTV Plugin", 7 | "version": "1.0.0.0", 8 | "targetAbi": "10.9.0.0" 9 | } 10 | -------------------------------------------------------------------------------- /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | name: '🧪 Test Plugin' 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | paths-ignore: 8 | - '**/*.md' 9 | pull_request: 10 | branches: 11 | - master 12 | paths-ignore: 13 | - '**/*.md' 14 | workflow_dispatch: 15 | 16 | jobs: 17 | call: 18 | uses: jellyfin/jellyfin-meta-plugins/.github/workflows/test.yaml@master 19 | -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: '🏗️ Build Plugin' 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | paths-ignore: 8 | - '**/*.md' 9 | pull_request: 10 | branches: 11 | - master 12 | paths-ignore: 13 | - '**/*.md' 14 | workflow_dispatch: 15 | 16 | jobs: 17 | call: 18 | uses: jellyfin/jellyfin-meta-plugins/.github/workflows/build.yaml@master 19 | -------------------------------------------------------------------------------- /.github/workflows/scan-codeql.yaml: -------------------------------------------------------------------------------- 1 | name: '🔬 Run CodeQL' 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths-ignore: 7 | - '**/*.md' 8 | pull_request: 9 | branches: [ master ] 10 | paths-ignore: 11 | - '**/*.md' 12 | schedule: 13 | - cron: '24 2 * * 4' 14 | workflow_dispatch: 15 | 16 | jobs: 17 | call: 18 | uses: jellyfin/jellyfin-meta-plugins/.github/workflows/scan-codeql.yaml@master 19 | with: 20 | repository-name: jellyfin/jellyfin-plugin-template 21 | -------------------------------------------------------------------------------- /.github/workflows/changelog.yaml: -------------------------------------------------------------------------------- 1 | name: '📝 Create/Update Release Draft & Release Bump PR' 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | paths-ignore: 8 | - build.yaml 9 | workflow_dispatch: 10 | repository_dispatch: 11 | types: 12 | - update-prep-command 13 | 14 | jobs: 15 | call: 16 | uses: jellyfin/jellyfin-meta-plugins/.github/workflows/changelog.yaml@master 17 | with: 18 | repository-name: jellyfin/jellyfin-plugin-template 19 | secrets: 20 | token: ${{ secrets.GITHUB_TOKEN }} 21 | -------------------------------------------------------------------------------- /.github/workflows/publish.yaml: -------------------------------------------------------------------------------- 1 | name: '🚀 Publish Plugin' 2 | 3 | on: 4 | release: 5 | types: 6 | - released 7 | workflow_dispatch: 8 | 9 | jobs: 10 | call: 11 | uses: jellyfin/jellyfin-meta-plugins/.github/workflows/publish.yaml@master 12 | with: 13 | version: ${{ github.event.release.tag_name }} 14 | is-unstable: ${{ github.event.release.prerelease }} 15 | secrets: 16 | deploy-host: ${{ secrets.DEPLOY_HOST }} 17 | deploy-user: ${{ secrets.DEPLOY_USER }} 18 | deploy-key: ${{ secrets.DEPLOY_KEY }} 19 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. 3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp 4 | // List of extensions which should be recommended for users of this workspace. 5 | "recommendations": [ 6 | "ms-dotnettools.csharp", 7 | "editorconfig.editorconfig" 8 | ], 9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace. 10 | "unwantedRecommendations": [] 11 | } -------------------------------------------------------------------------------- /.github/workflows/command-rebase.yaml: -------------------------------------------------------------------------------- 1 | name: '🔀 PR Rebase Command' 2 | 3 | on: 4 | repository_dispatch: 5 | types: 6 | - rebase-command 7 | 8 | jobs: 9 | call: 10 | uses: jellyfin/jellyfin-meta-plugins/.github/workflows/command-rebase.yaml@master 11 | with: 12 | rebase-head: ${{ github.event.client_payload.pull_request.head.label }} 13 | repository-full-name: ${{ github.event.client_payload.github.payload.repository.full_name }} 14 | comment-id: ${{ github.event.client_payload.github.payload.comment.id }} 15 | secrets: 16 | token: ${{ secrets.GITHUB_TOKEN }} 17 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Paths and plugin names are configured in settings.json 3 | "version": "0.2.0", 4 | "configurations": [ 5 | { 6 | "type": "coreclr", 7 | "name": "Launch", 8 | "request": "launch", 9 | "preLaunchTask": "build-and-copy", 10 | "program": "${config:jellyfinDir}/bin/Debug/net8.0/jellyfin.dll", 11 | "args": [ 12 | //"--nowebclient" 13 | "--webdir", 14 | "${config:jellyfinWebDir}/dist/" 15 | ], 16 | "cwd": "${config:jellyfinDir}", 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /Jellyfin.Plugin.ClassicTV/Configuration/PluginConfiguration.cs: -------------------------------------------------------------------------------- 1 | using MediaBrowser.Model.Plugins; 2 | using System.Collections.Generic; 3 | 4 | 5 | namespace Jellyfin.Plugin.ClassicTV.Configuration; 6 | 7 | /// 8 | /// Plugin configuration. 9 | /// 10 | public class PluginConfiguration : BasePluginConfiguration 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | public PluginConfiguration() 16 | { 17 | SeriesIds = new List(); 18 | UserIds = new List(); 19 | } 20 | 21 | /// 22 | /// Gets or sets the list of selected series IDs. 23 | /// 24 | public List SeriesIds { get; set; } 25 | 26 | /// 27 | /// Gets or sets the list of selected user IDs. 28 | /// 29 | public List UserIds { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | // jellyfinDir : The directory of the cloned jellyfin server project 3 | // This needs to be built once before it can be used 4 | "jellyfinDir": "${workspaceFolder}/../jellyfin/Jellyfin.Server", 5 | // jellyfinWebDir : The directory of the cloned jellyfin-web project 6 | // This needs to be built once before it can be used 7 | "jellyfinWebDir": "${workspaceFolder}/../jellyfin-web", 8 | // jellyfinDataDir : the root data directory for a running jellyfin instance 9 | // This is where jellyfin stores its configs, plugins, metadata etc 10 | // This is platform specific by default, but on Windows defaults to 11 | // ${env:LOCALAPPDATA}/jellyfin 12 | // and on Linux, it defaults to 13 | // ${env:XDG_DATA_HOME}/jellyfin 14 | // However ${env:XDG_DATA_HOME} does not work in Visual Studio Code's development container! 15 | "jellyfinWindowsDataDir": "${env:LOCALAPPDATA}/jellyfin", 16 | "jellyfinLinuxDataDir": "$HOME/.local/share/jellyfin", 17 | // The name of the plugin 18 | "pluginName": "Jellyfin.Plugin.Template", 19 | } -------------------------------------------------------------------------------- /Jellyfin.Plugin.ClassicTV.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.9.34723.18 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jellyfin.Plugin.ClassicTV", "Jellyfin.Plugin.ClassicTV\Jellyfin.Plugin.ClassicTV.csproj", "{C0C2C685-6632-46B8-80A9-171BBD8F4D16}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {C0C2C685-6632-46B8-80A9-171BBD8F4D16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {C0C2C685-6632-46B8-80A9-171BBD8F4D16}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {C0C2C685-6632-46B8-80A9-171BBD8F4D16}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {C0C2C685-6632-46B8-80A9-171BBD8F4D16}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {723F5D4F-EEAB-46CD-8654-1EFD84D0933B} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Jellyfin.Plugin.ClassicTV/Jellyfin.Plugin.ClassicTV.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | Jellyfin.Plugin.ClassicTV 6 | true 7 | false 8 | enable 9 | AllEnabledByDefault 10 | ../jellyfin.ruleset 11 | 12 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | PreserveNewest 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // Paths and plugin name are configured in settings.json 3 | "version": "2.0.0", 4 | "tasks": [ 5 | { 6 | // A chain task - build the plugin, then copy it to your 7 | // jellyfin server's plugin directory 8 | "label": "build-and-copy", 9 | "dependsOrder": "sequence", 10 | "dependsOn": [ 11 | "build", 12 | "make-plugin-dir", 13 | "copy-dll" 14 | ] 15 | }, 16 | { 17 | // Build the plugin 18 | "label": "build", 19 | "command": "dotnet", 20 | "type": "shell", 21 | "args": [ 22 | "publish", 23 | "--configuration=Debug", 24 | "${workspaceFolder}/${config:pluginName}.sln", 25 | "/property:GenerateFullPaths=true", 26 | "/consoleloggerparameters:NoSummary" 27 | ], 28 | "group": "build", 29 | "presentation": { 30 | "reveal": "silent" 31 | }, 32 | "problemMatcher": "$msCompile" 33 | }, 34 | { 35 | // Ensure the plugin directory exists before trying to use it 36 | "label": "make-plugin-dir", 37 | "type": "shell", 38 | "command": "mkdir", 39 | "windows": { 40 | "args": [ 41 | "-Force", 42 | "-Path", 43 | "${config:jellyfinWindowsDataDir}/plugins/${config:pluginName}/" 44 | ] 45 | }, 46 | "linux": { 47 | "args": [ 48 | "-p", 49 | "${config:jellyfinLinuxDataDir}/plugins/${config:pluginName}/" 50 | ] 51 | } 52 | }, 53 | { 54 | // Copy the plugin dll to the jellyfin plugin install path 55 | // This command copies every .dll from the build directory to the plugin dir 56 | // Usually, you probablly only need ${config:pluginName}.dll 57 | // But some plugins may bundle extra requirements 58 | "label": "copy-dll", 59 | "type": "shell", 60 | "command": "cp", 61 | "windows": { 62 | "args": [ 63 | "./${config:pluginName}/bin/Debug/net8.0/publish/*", 64 | "${config:jellyfinWindowsDataDir}/plugins/${config:pluginName}/" 65 | ] 66 | }, 67 | "linux": { 68 | "args": [ 69 | "-r", 70 | "./${config:pluginName}/bin/Debug/net8.0/publish/*", 71 | "${config:jellyfinLinuxDataDir}/plugins/${config:pluginName}/" 72 | ] 73 | } 74 | }, 75 | ] 76 | } 77 | -------------------------------------------------------------------------------- /Jellyfin.Plugin.ClassicTV/Plugin.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using Jellyfin.Plugin.ClassicTV.Configuration; 5 | using MediaBrowser.Common.Configuration; 6 | using MediaBrowser.Common.Plugins; 7 | using MediaBrowser.Model.Plugins; 8 | using MediaBrowser.Model.Serialization; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace Jellyfin.Plugin.ClassicTV; 12 | 13 | /// 14 | /// The main plugin. 15 | /// 16 | public class Plugin : BasePlugin, IHasWebPages 17 | { 18 | private readonly ILogger _logger; 19 | 20 | /// 21 | /// Initializes a new instance of the class. 22 | /// 23 | /// Instance of the interface. 24 | /// Instance of the interface. 25 | /// Instance of the interface. 26 | public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer, ILogger logger) 27 | : base(applicationPaths, xmlSerializer) 28 | { 29 | _logger = logger; 30 | _logger.LogInformation("ClassicTV Plugin constructor called"); 31 | Instance = this; 32 | _logger.LogInformation("ClassicTV Plugin instance set"); 33 | } 34 | 35 | /// 36 | public override string Name => "ClassicTV"; 37 | 38 | /// 39 | public override Guid Id => Guid.Parse("eb5d7894-8eef-4b36-aa6f-5d124e828ce1"); 40 | 41 | /// 42 | /// Gets the current plugin instance. 43 | /// 44 | public static Plugin? Instance { get; private set; } 45 | 46 | /// 47 | public IEnumerable GetPages() 48 | { 49 | _logger.LogInformation("ClassicTV Plugin GetPages() called"); 50 | 51 | try 52 | { 53 | var resourcePath = "Jellyfin.Plugin.ClassicTV.Configuration.configPage.html"; 54 | _logger.LogInformation("Registering configuration page with resource path: {ResourcePath}", resourcePath); 55 | 56 | return new[] 57 | { 58 | new PluginPageInfo 59 | { 60 | Name = Name, 61 | EmbeddedResourcePath = resourcePath 62 | } 63 | }; 64 | } 65 | catch (Exception ex) 66 | { 67 | _logger.LogError(ex, "Error in GetPages() method"); 68 | return new PluginPageInfo[0]; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Jellyfin.Plugin.ClassicTV/EpisodeMixer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using MediaBrowser.Controller.Entities.TV; 5 | using Microsoft.Extensions.Logging; 6 | 7 | namespace Jellyfin.Plugin.ClassicTV 8 | { 9 | public static class EpisodeMixer 10 | { 11 | /// 12 | /// Mezcla los episodios de varias series en orden interno usando round-robin. 13 | /// Limita el número total de episodios para evitar problemas de memoria. 14 | /// 15 | public static List MixEpisodesRoundRobin(Dictionary> seriesEpisodes) 16 | { 17 | const int maxEpisodes = 1000; // Límite máximo de episodios 18 | var result = new List(); 19 | var random = new Random(Guid.NewGuid().GetHashCode()); 20 | 21 | // Crear listas de episodios para cada serie 22 | var episodeLists = seriesEpisodes.Values 23 | .Select(list => list != null ? new List(list) : new List()) 24 | .ToList(); 25 | 26 | // Reordenar aleatoriamente el orden de las series para obtener una mezcla distinta cada ejecución 27 | Shuffle(episodeLists, random); 28 | 29 | var currentIndexes = new int[episodeLists.Count]; // Índices actuales para cada serie 30 | 31 | bool hasMoreEpisodes; 32 | do 33 | { 34 | hasMoreEpisodes = false; 35 | 36 | // Recorrer cada serie y tomar el siguiente episodio disponible 37 | for (int i = 0; i < episodeLists.Count; i++) 38 | { 39 | var episodeList = episodeLists[i]; 40 | var currentIndex = currentIndexes[i]; 41 | 42 | // Si esta serie tiene más episodios disponibles 43 | if (currentIndex < episodeList.Count && result.Count < maxEpisodes) 44 | { 45 | var episode = episodeList[currentIndex]; 46 | result.Add(episode); 47 | currentIndexes[i]++; // Avanzar al siguiente episodio de esta serie 48 | hasMoreEpisodes = true; 49 | } 50 | } 51 | } while (hasMoreEpisodes && result.Count < maxEpisodes); 52 | 53 | return result; 54 | } 55 | 56 | private static void Shuffle(IList list, Random random) 57 | { 58 | for (int i = list.Count - 1; i > 0; i--) 59 | { 60 | int j = random.Next(i + 1); 61 | (list[i], list[j]) = (list[j], list[i]); 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /IUserDataManager.cs: -------------------------------------------------------------------------------- 1 | #nullable disable 2 | 3 | #pragma warning disable CA1002, CA1707, CS1591 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Threading; 8 | using Jellyfin.Data.Entities; 9 | using MediaBrowser.Controller.Dto; 10 | using MediaBrowser.Controller.Entities; 11 | using MediaBrowser.Model.Dto; 12 | using MediaBrowser.Model.Entities; 13 | 14 | namespace MediaBrowser.Controller.Library 15 | { 16 | /// 17 | /// Interface IUserDataManager. 18 | /// 19 | public interface IUserDataManager 20 | { 21 | /// 22 | /// Occurs when [user data saved]. 23 | /// 24 | event EventHandler UserDataSaved; 25 | 26 | /// 27 | /// Saves the user data. 28 | /// 29 | /// The user id. 30 | /// The item. 31 | /// The user data. 32 | /// The reason. 33 | /// The cancellation token. 34 | void SaveUserData(Guid userId, BaseItem item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken); 35 | 36 | void SaveUserData(User user, BaseItem item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken); 37 | 38 | /// 39 | /// Save the provided user data for the given user. 40 | /// 41 | /// The user. 42 | /// The item. 43 | /// The reason for updating the user data. 44 | /// The reason. 45 | void SaveUserData(User user, BaseItem item, UpdateUserItemDataDto userDataDto, UserDataSaveReason reason); 46 | 47 | UserItemData GetUserData(User user, BaseItem item); 48 | 49 | UserItemData GetUserData(Guid userId, BaseItem item); 50 | 51 | /// 52 | /// Gets the user data dto. 53 | /// 54 | /// Item to use. 55 | /// User to use. 56 | /// User data dto. 57 | UserItemDataDto GetUserDataDto(BaseItem item, User user); 58 | 59 | UserItemDataDto GetUserDataDto(BaseItem item, BaseItemDto itemDto, User user, DtoOptions options); 60 | 61 | /// 62 | /// Get all user data for the given user. 63 | /// 64 | /// The user id. 65 | /// The user item data. 66 | List GetAllUserData(Guid userId); 67 | 68 | /// 69 | /// Save the all provided user data for the given user. 70 | /// 71 | /// The user id. 72 | /// The array of user data. 73 | /// The cancellation token. 74 | void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken); 75 | 76 | /// 77 | /// Updates playstate for an item and returns true or false indicating if it was played to completion. 78 | /// 79 | /// Item to update. 80 | /// Data to update. 81 | /// New playstate. 82 | /// True if playstate was updated. 83 | bool UpdatePlayState(BaseItem item, UserItemData data, long? reportedPositionTicks); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ClassicTV Plugin for Jellyfin 2 | 3 | A Jellyfin plugin that allows mixing episodes from multiple selected series into an ordered playlist, maintaining the internal order of each series using a round-robin algorithm. 4 | 5 | ## Features 6 | 7 | - ✅ **Multiple series selection**: Choose several series from the configuration interface 8 | - ✅ **Round-robin algorithm**: Mixes episodes alternating between series 9 | - ✅ **Respect internal order**: Maintains the chronological order of each series 10 | - ✅ **User filtering**: Only includes episodes not watched by each user 11 | - ✅ **Custom playlists and overwriting**: Creates a unique playlist for each user and overwrites it if it already exists (no duplicates are created) 12 | - ✅ **Scheduled task**: Generates playlists automatically or manually 13 | 14 | ## Installation 15 | 16 | ### Requirements 17 | - Jellyfin Server 10.9.0 or higher 18 | - .NET 8.0 Runtime 19 | 20 | ### Installation steps 21 | 22 | 1. **Download the plugin** 23 | - Download the `Jellyfin.Plugin.ClassicTV.dll` file from the releases section 24 | - Or compile from source code (see development section) 25 | 26 | 2. **Install in Jellyfin** 27 | - Stop the Jellyfin server 28 | - Copy the `Jellyfin.Plugin.ClassicTV.dll` file to the plugins folder: 29 | - **Windows**: `%PROGRAMDATA%\Jellyfin\Server\plugins` 30 | - **Linux**: `/var/lib/jellyfin/plugins` 31 | - **Docker**: Mount the plugins folder in the container 32 | - Restart the Jellyfin server 33 | 34 | 3. **Verify installation** 35 | - Go to **Dashboard** → **Plugins** 36 | - Look for "ClassicTV" in the list of installed plugins 37 | - The plugin should appear as "ClassicTV" in the "General" category 38 | 39 | ## Configuration 40 | 41 | ### Configure selected series 42 | 43 | 1. **Access configuration** 44 | - Go to **Dashboard** → **Plugins** 45 | - Find "ClassicTV" and click **Settings** 46 | 47 | 2. **Select series** 48 | - On the configuration page, you'll see a multiple selector with all your series 49 | - Hold **Ctrl** (Windows) or **Cmd** (Mac) to select multiple series 50 | - You can also use **Shift** to select ranges 51 | - Click **Save** to confirm the selection 52 | 53 | ### Generate playlist 54 | 55 | 1. **Run the task manually** 56 | - Go to **Dashboard** → **Scheduled Tasks** 57 | - Find "Generate ClassicTV Playlist" 58 | - Click **Run Now** 59 | 60 | 2. **Verify the playlist** 61 | - Go to **My Library** → **Playlists** 62 | - Look for the playlist "ClassicTV Playlist - [YourUser]" 63 | - The playlist will contain mixed episodes from the selected series 64 | 65 | ## Usage 66 | 67 | ### How the algorithm works 68 | 69 | The plugin mixes episodes using a **round-robin** algorithm: 70 | 71 | 1. **Sort episodes**: Each series maintains its internal chronological order 72 | 2. **Filter unwatched**: Only includes episodes that the user hasn't watched 73 | 3. **Alternating mix**: Takes one episode from each series in rotation 74 | 4. **Example**: 75 | ``` 76 | Series A: Ep1, Ep2, Ep3, Ep4 77 | Series B: Ep1, Ep2 78 | Series C: Ep1, Ep2, Ep3 79 | 80 | Result: A1, B1, C1, A2, B2, C2, A3, C3, A4 81 | ``` 82 | 83 | ### Playlist features 84 | 85 | - **User-specific**: Each user has their own playlist 86 | - **Unwatched episodes only**: Doesn't include already watched episodes 87 | - **1000 episode limit**: To avoid performance issues 88 | - **Round-robin order**: Maintains balance between series 89 | - **Overwrites existing playlists**: If a playlist with the same name already exists for the user, it's deleted and a new one is created (no duplicates accumulate) 90 | 91 | ## Development 92 | 93 | ### Compile from source code 94 | 95 | 1. **Clone the repository** 96 | ```bash 97 | git clone https://github.com/xtra25/Jellyfin-plugin-ClassicTV 98 | cd jellyfin-plugin-ClassicTV 99 | ``` 100 | 101 | 2. **Development requirements** 102 | - .NET 8.0 SDK 103 | - Visual Studio 2022 or VS Code 104 | 105 | 3. **Compile** 106 | ```bash 107 | cd Jellyfin.Plugin.ClassicTV 108 | dotnet build 109 | ``` 110 | 111 | 4. **Install** 112 | - The DLL file is generated in `bin/Debug/net8.0/` 113 | - Copy `Jellyfin.Plugin.ClassicTV.dll` to Jellyfin's plugins folder 114 | 115 | ### Project structure 116 | 117 | ``` 118 | Jellyfin.Plugin.ClassicTV/ 119 | ├── Plugin.cs # Main plugin class 120 | ├── Configuration/ 121 | │ ├── PluginConfiguration.cs # Plugin configuration 122 | │ └── configPage.html # Web configuration page 123 | ├── EpisodeFetcher.cs # Gets episodes from series 124 | ├── EpisodeMixer.cs # Round-robin mixing algorithm 125 | ├── GeneratePlaylistTask.cs # Scheduled task to generate playlists 126 | └── Jellyfin.Plugin.ClassicTV.csproj 127 | ``` 128 | 129 | ## Troubleshooting 130 | 131 | ### Configuration page doesn't appear 132 | - Verify that the plugin is installed correctly 133 | - Check Jellyfin logs for errors 134 | - Make sure the DLL file is in the correct folder 135 | 136 | ### Playlist only has few episodes 137 | - Verify that selected series have unwatched episodes 138 | - Check that episodes aren't marked as watched 139 | - Review logs to see how many episodes were found 140 | 141 | ### Error generating playlist 142 | - Verify that selected series exist in your library 143 | - Check that you have permissions to create playlists 144 | - Review Jellyfin logs for specific errors 145 | 146 | ### Playlist doesn't update 147 | - If you see multiple playlists with the same name, update the plugin: now the playlist is overwritten correctly and no duplicates are created 148 | - Manually run the "Generate ClassicTV Playlist" task 149 | - Verify that selected series haven't changed 150 | - Check that unwatched episodes are available 151 | 152 | ## Logs 153 | 154 | To diagnose problems, check Jellyfin logs. The plugin logs detailed information about: 155 | 156 | - Selected series 157 | - Episodes found per series 158 | - Unwatched episodes per user 159 | - Round-robin mixing process 160 | - Playlist creation 161 | 162 | ## Contributing 163 | 164 | 1. Fork the repository 165 | 2. Create a branch for your feature (`git checkout -b feature/new-functionality`) 166 | 3. Commit your changes (`git commit -am 'Add new functionality'`) 167 | 4. Push to the branch (`git push origin feature/new-functionality`) 168 | 5. Create a Pull Request 169 | 170 | ## License 171 | 172 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. 173 | 174 | ## Support 175 | 176 | If you have problems or questions: 177 | 178 | 1. Check the [Troubleshooting](#troubleshooting) section 179 | 2. Search in [Issues](https://github.com/xtra25/Jellyfin-plugin-ClassicTV/issues) 180 | 3. Create a new issue with: 181 | - Jellyfin version 182 | - Operating system 183 | - Relevant logs 184 | - Detailed problem description 185 | 186 | --- 187 | 188 | **Enjoy your mixed classic TV experience!** 📺✨ 189 | -------------------------------------------------------------------------------- /jellyfin.ruleset: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /IUserManager.cs: -------------------------------------------------------------------------------- 1 | #pragma warning disable CS1591 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | using Jellyfin.Data.Entities; 7 | using Jellyfin.Data.Events; 8 | using MediaBrowser.Model.Configuration; 9 | using MediaBrowser.Model.Dto; 10 | using MediaBrowser.Model.Users; 11 | 12 | namespace MediaBrowser.Controller.Library 13 | { 14 | /// 15 | /// Interface IUserManager. 16 | /// 17 | public interface IUserManager 18 | { 19 | /// 20 | /// Occurs when a user is updated. 21 | /// 22 | event EventHandler> OnUserUpdated; 23 | 24 | /// 25 | /// Gets the users. 26 | /// 27 | /// The users. 28 | IEnumerable Users { get; } 29 | 30 | /// 31 | /// Gets the user ids. 32 | /// 33 | /// The users ids. 34 | IEnumerable UsersIds { get; } 35 | 36 | /// 37 | /// Initializes the user manager and ensures that a user exists. 38 | /// 39 | /// Awaitable task. 40 | Task InitializeAsync(); 41 | 42 | /// 43 | /// Gets a user by Id. 44 | /// 45 | /// The id. 46 | /// The user with the specified Id, or null if the user doesn't exist. 47 | /// id is an empty Guid. 48 | User? GetUserById(Guid id); 49 | 50 | /// 51 | /// Gets the name of the user by. 52 | /// 53 | /// The name. 54 | /// User. 55 | User? GetUserByName(string name); 56 | 57 | /// 58 | /// Renames the user. 59 | /// 60 | /// The user. 61 | /// The new name. 62 | /// Task. 63 | /// If user is null. 64 | /// If the provided user doesn't exist. 65 | Task RenameUser(User user, string newName); 66 | 67 | /// 68 | /// Updates the user. 69 | /// 70 | /// The user. 71 | /// If user is null. 72 | /// If the provided user doesn't exist. 73 | /// A task representing the update of the user. 74 | Task UpdateUserAsync(User user); 75 | 76 | /// 77 | /// Creates a user with the specified name. 78 | /// 79 | /// The name of the new user. 80 | /// The created user. 81 | /// is null or empty. 82 | /// already exists. 83 | Task CreateUserAsync(string name); 84 | 85 | /// 86 | /// Deletes the specified user. 87 | /// 88 | /// The id of the user to be deleted. 89 | /// A task representing the deletion of the user. 90 | Task DeleteUserAsync(Guid userId); 91 | 92 | /// 93 | /// Resets the password. 94 | /// 95 | /// The user. 96 | /// Task. 97 | Task ResetPassword(User user); 98 | 99 | /// 100 | /// Changes the password. 101 | /// 102 | /// The user. 103 | /// New password to use. 104 | /// Awaitable task. 105 | Task ChangePassword(User user, string newPassword); 106 | 107 | /// 108 | /// Gets the user dto. 109 | /// 110 | /// The user. 111 | /// The remote end point. 112 | /// UserDto. 113 | UserDto GetUserDto(User user, string? remoteEndPoint = null); 114 | 115 | /// 116 | /// Authenticates the user. 117 | /// 118 | /// The user. 119 | /// The password to use. 120 | /// Hash of password. 121 | /// Remove endpoint to use. 122 | /// Specifies if a user session. 123 | /// User wrapped in awaitable task. 124 | Task AuthenticateUser(string username, string password, string passwordSha1, string remoteEndPoint, bool isUserSession); 125 | 126 | /// 127 | /// Starts the forgot password process. 128 | /// 129 | /// The entered username. 130 | /// if set to true [is in network]. 131 | /// ForgotPasswordResult. 132 | Task StartForgotPasswordProcess(string enteredUsername, bool isInNetwork); 133 | 134 | /// 135 | /// Redeems the password reset pin. 136 | /// 137 | /// The pin. 138 | /// true if XXXX, false otherwise. 139 | Task RedeemPasswordResetPin(string pin); 140 | 141 | NameIdPair[] GetAuthenticationProviders(); 142 | 143 | NameIdPair[] GetPasswordResetProviders(); 144 | 145 | /// 146 | /// This method updates the user's configuration. 147 | /// This is only included as a stopgap until the new API, using this internally is not recommended. 148 | /// Instead, modify the user object directly, then call . 149 | /// 150 | /// The user's Id. 151 | /// The request containing the new user configuration. 152 | /// A task representing the update. 153 | Task UpdateConfigurationAsync(Guid userId, UserConfiguration config); 154 | 155 | /// 156 | /// This method updates the user's policy. 157 | /// This is only included as a stopgap until the new API, using this internally is not recommended. 158 | /// Instead, modify the user object directly, then call . 159 | /// 160 | /// The user's Id. 161 | /// The request containing the new user policy. 162 | /// A task representing the update. 163 | Task UpdatePolicyAsync(Guid userId, UserPolicy policy); 164 | 165 | /// 166 | /// Clears the user's profile image. 167 | /// 168 | /// The user. 169 | /// A task representing the clearing of the profile image. 170 | Task ClearProfileImageAsync(User user); 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /Jellyfin.Plugin.ClassicTV/EpisodeFecthcer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Reflection; 6 | using MediaBrowser.Controller.Entities; 7 | using MediaBrowser.Controller.Entities.TV; 8 | using MediaBrowser.Controller.Library; 9 | using MediaBrowser.Model.Entities; 10 | using MediaBrowser.Model.Querying; 11 | using Jellyfin.Data.Enums; 12 | 13 | namespace Jellyfin.Plugin.ClassicTV 14 | { 15 | public class EpisodeFetcher 16 | { 17 | private readonly ILibraryManager _libraryManager; 18 | 19 | public EpisodeFetcher(ILibraryManager libraryManager) 20 | { 21 | _libraryManager = libraryManager; 22 | } 23 | 24 | public Dictionary> GetUnwatchedEpisodesBySeries(List seriesIds, object? user, Guid userId) 25 | { 26 | var result = new Dictionary>(); 27 | 28 | foreach (var id in seriesIds) 29 | { 30 | if (!Guid.TryParse(id, out var guid)) 31 | { 32 | continue; 33 | } 34 | 35 | var item = _libraryManager.GetItemById(guid); 36 | if (item is Series series) 37 | { 38 | var query = new InternalItemsQuery 39 | { 40 | IncludeItemTypes = new[] { BaseItemKind.Episode }, 41 | ParentId = series.Id, 42 | Recursive = true 43 | }; 44 | 45 | if (user != null) 46 | { 47 | TryAssignUserToQuery(query, user); 48 | query.IsPlayed = false; 49 | } 50 | 51 | var allEpisodes = ExecuteQuery(query) 52 | .OfType() 53 | .OrderBy(e => e.ParentIndexNumber ?? 0) 54 | .ThenBy(e => e.IndexNumber ?? 0) 55 | .ToList(); 56 | 57 | var unwatchedEpisodes = allEpisodes 58 | .Where(e => IsUnplayedForUser(e, userId)) 59 | .ToList(); 60 | 61 | result[series.Name] = unwatchedEpisodes; 62 | } 63 | } 64 | 65 | return result; 66 | } 67 | 68 | // Método original para compatibilidad (si se necesita) 69 | public Dictionary> GetOrderedEpisodesBySeries(List seriesIds) 70 | { 71 | var result = new Dictionary>(); 72 | 73 | foreach (var id in seriesIds) 74 | { 75 | if (!Guid.TryParse(id, out var guid)) 76 | continue; 77 | 78 | var item = _libraryManager.GetItemById(guid); 79 | if (item is Series series) 80 | { 81 | var query = new InternalItemsQuery 82 | { 83 | IncludeItemTypes = new[] { BaseItemKind.Episode }, 84 | ParentId = series.Id, 85 | Recursive = true 86 | }; 87 | 88 | var episodes = ExecuteQuery(query) 89 | .OfType() 90 | .OrderBy(e => e.ParentIndexNumber ?? 0) 91 | .ThenBy(e => e.IndexNumber ?? 0) 92 | .ToList(); 93 | 94 | result[series.Name] = episodes; 95 | } 96 | } 97 | 98 | return result; 99 | } 100 | 101 | private static void TryAssignUserToQuery(InternalItemsQuery query, object user) 102 | { 103 | try 104 | { 105 | var setUserMethod = typeof(InternalItemsQuery).GetMethod("SetUser", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 106 | if (setUserMethod != null) 107 | { 108 | setUserMethod.Invoke(query, new[] { user }); 109 | return; 110 | } 111 | 112 | var userProperty = typeof(InternalItemsQuery).GetProperty("User", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 113 | if (userProperty != null && userProperty.CanWrite) 114 | { 115 | userProperty.SetValue(query, user); 116 | } 117 | } 118 | catch 119 | { 120 | // ignorar; el filtro por User es un optimizador y no debe romper la generación 121 | } 122 | } 123 | 124 | private IEnumerable ExecuteQuery(InternalItemsQuery query) 125 | { 126 | // Jellyfin 10.9 expone GetItemList; en 10.11 se reemplazó por QueryItems. 127 | // Usar reflexión para soportar ambas versiones sin recompilar contra assemblies nuevos. 128 | var libraryManagerType = _libraryManager.GetType(); 129 | 130 | // Preferir GetItemList si está disponible. 131 | var getItemList = libraryManagerType.GetMethod("GetItemList", BindingFlags.Instance | BindingFlags.Public, new[] { typeof(InternalItemsQuery) }); 132 | if (getItemList != null) 133 | { 134 | if (getItemList.Invoke(_libraryManager, new object[] { query }) is IEnumerable list) 135 | { 136 | return list; 137 | } 138 | } 139 | 140 | // Fallback a QueryItems (retorna objeto con propiedad Items). 141 | var queryItems = libraryManagerType.GetMethod("QueryItems", BindingFlags.Instance | BindingFlags.Public, new[] { typeof(InternalItemsQuery) }); 142 | if (queryItems != null) 143 | { 144 | var result = queryItems.Invoke(_libraryManager, new object[] { query }); 145 | var itemsProp = result?.GetType().GetProperty("Items", BindingFlags.Instance | BindingFlags.Public); 146 | if (itemsProp?.GetValue(result) is IEnumerable items) 147 | { 148 | return items.OfType(); 149 | } 150 | } 151 | 152 | throw new MissingMethodException("ILibraryManager no expone ni GetItemList ni QueryItems compatibles."); 153 | } 154 | 155 | private static bool IsUnplayedForUser(Episode episode, Guid userId) 156 | { 157 | try 158 | { 159 | var userDataProperty = episode.GetType().GetProperty("UserData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 160 | if (userDataProperty?.GetValue(episode) is IDictionary userDataDict && userDataDict.Contains(userId)) 161 | { 162 | var userData = userDataDict[userId]; 163 | var playedProperty = userData?.GetType().GetProperty("Played", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 164 | var played = (bool?)playedProperty?.GetValue(userData); 165 | return !(played ?? false); 166 | } 167 | 168 | var userDataListProperty = episode.GetType().GetProperty("UserDataList", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 169 | if (userDataListProperty?.GetValue(episode) is IEnumerable userDataList) 170 | { 171 | foreach (var entry in userDataList) 172 | { 173 | var idProperty = entry?.GetType().GetProperty("UserId", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 174 | if (idProperty?.GetValue(entry) is Guid entryUserId && entryUserId == userId) 175 | { 176 | var playedProperty = entry.GetType().GetProperty("Played", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 177 | var played = (bool?)playedProperty?.GetValue(entry); 178 | return !(played ?? false); 179 | } 180 | } 181 | } 182 | } 183 | catch 184 | { 185 | // ignorar y considerar el episodio como no visto 186 | } 187 | 188 | return true; 189 | } 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /Jellyfin.Plugin.ClassicTV/GeneratePlaylistTask.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using MediaBrowser.Controller.Entities; 8 | using MediaBrowser.Controller.Library; 9 | using MediaBrowser.Controller.Playlists; 10 | using MediaBrowser.Model.Tasks; 11 | using MediaBrowser.Model.Playlists; 12 | using MediaBrowser.Model.Querying; 13 | using Microsoft.Extensions.Logging; 14 | 15 | 16 | namespace Jellyfin.Plugin.ClassicTV 17 | { 18 | public class GeneratePlaylistTask : IScheduledTask 19 | { 20 | private readonly ILibraryManager _libraryManager; 21 | private readonly IUserManager _userManager; 22 | private readonly IPlaylistManager _playlistManager; 23 | private readonly ILogger _logger; 24 | 25 | public GeneratePlaylistTask( 26 | ILibraryManager libraryManager, 27 | IUserManager userManager, 28 | IPlaylistManager playlistManager, 29 | ILogger logger) 30 | { 31 | _libraryManager = libraryManager; 32 | _userManager = userManager; 33 | _playlistManager = playlistManager; 34 | _logger = logger; 35 | } 36 | 37 | public string Name => "Generar playlist ClassicTV"; 38 | public string Description => "Mezcla episodios de series seleccionadas y crea una playlist ordenada round-robin."; 39 | public string Category => "ClassicTV"; 40 | 41 | 42 | public IEnumerable GetDefaultTriggers() 43 | { 44 | // Solo ejecución manual desde el panel de tareas 45 | return Array.Empty(); 46 | } 47 | 48 | public string Key => "ClassicTV_PlaylistGenerator"; 49 | 50 | public async Task ExecuteAsync(IProgress progress, CancellationToken cancellationToken) 51 | { 52 | var config = Plugin.Instance?.Configuration; 53 | 54 | if (config == null || config.SeriesIds.Count == 0) 55 | { 56 | _logger.LogWarning("No series configured"); 57 | return; 58 | } 59 | 60 | if (config.UserIds.Count == 0) 61 | { 62 | _logger.LogWarning("No users configured"); 63 | return; 64 | } 65 | 66 | _logger.LogInformation("GeneratePlaylistTask: Starting playlist generation for {SeriesCount} series and {UserCount} users", config.SeriesIds.Count, config.UserIds.Count); 67 | 68 | var fetcher = new EpisodeFetcher(_libraryManager); 69 | 70 | // Crear playlist solo para los usuarios seleccionados 71 | foreach (var userId in config.UserIds) 72 | { 73 | if (!Guid.TryParse(userId, out var userGuid)) 74 | { 75 | _logger.LogWarning("GeneratePlaylistTask: Invalid user ID format {UserId}, skipping", userId); 76 | continue; 77 | } 78 | 79 | string username = userId; 80 | Guid userIdForPlaylist = userGuid; 81 | object? user = null; 82 | 83 | try 84 | { 85 | var getUserByIdMethod = _userManager.GetType().GetMethod("GetUserById", new[] { typeof(Guid) }); 86 | if (getUserByIdMethod != null) 87 | { 88 | user = getUserByIdMethod.Invoke(_userManager, new object[] { userGuid }); 89 | } 90 | 91 | if (user == null) 92 | { 93 | _logger.LogWarning("GeneratePlaylistTask: Could not find user {UserId}, skipping", userId); 94 | continue; 95 | } 96 | 97 | var usernameProp = user.GetType().GetProperty("Username"); 98 | if (usernameProp != null) 99 | { 100 | username = usernameProp.GetValue(user)?.ToString() ?? username; 101 | } 102 | 103 | var idProp = user.GetType().GetProperty("Id"); 104 | if (idProp != null && idProp.GetValue(user) is Guid extractedId) 105 | { 106 | userIdForPlaylist = extractedId; 107 | } 108 | 109 | _logger.LogInformation("GeneratePlaylistTask: Processing user {Username}", username); 110 | 111 | var episodesBySeries = fetcher.GetUnwatchedEpisodesBySeries(config.SeriesIds, user, userIdForPlaylist); 112 | var mixedEpisodes = EpisodeMixer.MixEpisodesRoundRobin(episodesBySeries); 113 | 114 | _logger.LogInformation("GeneratePlaylistTask: Processing {SeriesCount} series for user {Username} with total {TotalEpisodes} unwatched episodes", 115 | episodesBySeries.Count, username, episodesBySeries.Values.Sum(e => e.Count)); 116 | _logger.LogInformation("GeneratePlaylistTask: Mixed playlist for user {Username} will contain {EpisodeCount} episodes", username, mixedEpisodes.Count); 117 | 118 | if (mixedEpisodes.Count == 0) 119 | { 120 | _logger.LogInformation("GeneratePlaylistTask: No unwatched episodes for user {Username}, skipping playlist creation", username); 121 | continue; 122 | } 123 | 124 | var playlistName = $"ClassicTV Playlist - {username}"; 125 | 126 | // Buscar y eliminar playlist existente si existe 127 | try 128 | { 129 | var userPlaylists = _playlistManager.GetPlaylists(userIdForPlaylist); 130 | foreach (var p in userPlaylists) 131 | { 132 | _logger.LogDebug("Found playlist: '{PlaylistName}' for user {Username}", p.Name, username); 133 | } 134 | var existingPlaylist = userPlaylists 135 | .FirstOrDefault(p => string.Equals(p.Name?.Trim(), playlistName.Trim(), StringComparison.OrdinalIgnoreCase)); 136 | 137 | if (existingPlaylist != null) 138 | { 139 | _logger.LogInformation("Found existing playlist '{PlaylistName}' for user {Username}, deleting it", playlistName, username); 140 | try 141 | { 142 | _libraryManager.DeleteItem(existingPlaylist, new MediaBrowser.Controller.Library.DeleteOptions()); 143 | _logger.LogInformation("Deleted playlist '{PlaylistName}' for user {Username}", playlistName, username); 144 | } 145 | catch (Exception ex) 146 | { 147 | _logger.LogError(ex, "Error deleting playlist '{PlaylistName}' for user {Username}", playlistName, username); 148 | } 149 | // Confirmar si sigue existiendo 150 | var afterDelete = _playlistManager.GetPlaylists(userIdForPlaylist) 151 | .FirstOrDefault(p => string.Equals(p.Name?.Trim(), playlistName.Trim(), StringComparison.OrdinalIgnoreCase)); 152 | if (afterDelete != null) 153 | { 154 | _logger.LogWarning("Playlist '{PlaylistName}' still exists after deletion for user {Username}", playlistName, username); 155 | } 156 | } 157 | else 158 | { 159 | _logger.LogDebug("No existing playlist named '{PlaylistName}' found for user {Username}", playlistName, username); 160 | } 161 | } 162 | catch (Exception ex) 163 | { 164 | _logger.LogWarning(ex, "Error while checking/deleting existing playlist for user {Username}", username); 165 | } 166 | 167 | _logger.LogInformation("GeneratePlaylistTask: Creating new playlist '{PlaylistName}' for user {Username}", playlistName, username); 168 | 169 | var request = new PlaylistCreationRequest 170 | { 171 | Name = playlistName, 172 | UserId = userIdForPlaylist, 173 | ItemIdList = mixedEpisodes.Select(e => e.Id).ToList() 174 | }; 175 | 176 | await _playlistManager.CreatePlaylist(request); 177 | _logger.LogInformation("GeneratePlaylistTask: Playlist created for user {Username} with {EpisodeCount} episodes", username, mixedEpisodes.Count); 178 | } 179 | catch (Exception ex) 180 | { 181 | _logger.LogError(ex, "GeneratePlaylistTask: Error creating playlist for user {UserId}", userId); 182 | } 183 | } 184 | } 185 | 186 | 187 | 188 | 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # With more recent updates Visual Studio 2017 supports EditorConfig files out of the box 2 | # Visual Studio Code needs an extension: https://github.com/editorconfig/editorconfig-vscode 3 | # For emacs, vim, np++ and other editors, see here: https://github.com/editorconfig 4 | ############################### 5 | # Core EditorConfig Options # 6 | ############################### 7 | root = true 8 | # All files 9 | [*] 10 | indent_style = space 11 | indent_size = 4 12 | charset = utf-8 13 | trim_trailing_whitespace = true 14 | insert_final_newline = true 15 | end_of_line = lf 16 | max_line_length = off 17 | 18 | # YAML indentation 19 | [*.{yml,yaml}] 20 | indent_size = 2 21 | 22 | # XML indentation 23 | [*.{csproj,xml}] 24 | indent_size = 2 25 | 26 | ############################### 27 | # .NET Coding Conventions # 28 | ############################### 29 | [*.{cs,vb}] 30 | # Organize usings 31 | dotnet_sort_system_directives_first = true 32 | # this. preferences 33 | dotnet_style_qualification_for_field = false:silent 34 | dotnet_style_qualification_for_property = false:silent 35 | dotnet_style_qualification_for_method = false:silent 36 | dotnet_style_qualification_for_event = false:silent 37 | # Language keywords vs BCL types preferences 38 | dotnet_style_predefined_type_for_locals_parameters_members = true:silent 39 | dotnet_style_predefined_type_for_member_access = true:silent 40 | # Parentheses preferences 41 | dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent 42 | dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent 43 | dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent 44 | dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent 45 | # Modifier preferences 46 | dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent 47 | dotnet_style_readonly_field = true:suggestion 48 | # Expression-level preferences 49 | dotnet_style_object_initializer = true:suggestion 50 | dotnet_style_collection_initializer = true:suggestion 51 | dotnet_style_explicit_tuple_names = true:suggestion 52 | dotnet_style_null_propagation = true:suggestion 53 | dotnet_style_coalesce_expression = true:suggestion 54 | dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent 55 | dotnet_style_prefer_inferred_tuple_names = true:suggestion 56 | dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion 57 | dotnet_style_prefer_auto_properties = true:silent 58 | dotnet_style_prefer_conditional_expression_over_assignment = true:silent 59 | dotnet_style_prefer_conditional_expression_over_return = true:silent 60 | 61 | ############################### 62 | # Naming Conventions # 63 | ############################### 64 | # Style Definitions (From Roslyn) 65 | 66 | # Non-private static fields are PascalCase 67 | dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion 68 | dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields 69 | dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style 70 | 71 | dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field 72 | dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected 73 | dotnet_naming_symbols.non_private_static_fields.required_modifiers = static 74 | 75 | dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case 76 | 77 | # Constants are PascalCase 78 | dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion 79 | dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants 80 | dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style 81 | 82 | dotnet_naming_symbols.constants.applicable_kinds = field, local 83 | dotnet_naming_symbols.constants.required_modifiers = const 84 | 85 | dotnet_naming_style.constant_style.capitalization = pascal_case 86 | 87 | # Static fields are camelCase and start with s_ 88 | dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion 89 | dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields 90 | dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style 91 | 92 | dotnet_naming_symbols.static_fields.applicable_kinds = field 93 | dotnet_naming_symbols.static_fields.required_modifiers = static 94 | 95 | dotnet_naming_style.static_field_style.capitalization = camel_case 96 | dotnet_naming_style.static_field_style.required_prefix = _ 97 | 98 | # Instance fields are camelCase and start with _ 99 | dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion 100 | dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields 101 | dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style 102 | 103 | dotnet_naming_symbols.instance_fields.applicable_kinds = field 104 | 105 | dotnet_naming_style.instance_field_style.capitalization = camel_case 106 | dotnet_naming_style.instance_field_style.required_prefix = _ 107 | 108 | # Locals and parameters are camelCase 109 | dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion 110 | dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters 111 | dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style 112 | 113 | dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local 114 | 115 | dotnet_naming_style.camel_case_style.capitalization = camel_case 116 | 117 | # Local functions are PascalCase 118 | dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion 119 | dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions 120 | dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style 121 | 122 | dotnet_naming_symbols.local_functions.applicable_kinds = local_function 123 | 124 | dotnet_naming_style.local_function_style.capitalization = pascal_case 125 | 126 | # By default, name items with PascalCase 127 | dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion 128 | dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members 129 | dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style 130 | 131 | dotnet_naming_symbols.all_members.applicable_kinds = * 132 | 133 | dotnet_naming_style.pascal_case_style.capitalization = pascal_case 134 | 135 | ############################### 136 | # C# Coding Conventions # 137 | ############################### 138 | [*.cs] 139 | # var preferences 140 | csharp_style_var_for_built_in_types = true:silent 141 | csharp_style_var_when_type_is_apparent = true:silent 142 | csharp_style_var_elsewhere = true:silent 143 | # Expression-bodied members 144 | csharp_style_expression_bodied_methods = false:silent 145 | csharp_style_expression_bodied_constructors = false:silent 146 | csharp_style_expression_bodied_operators = false:silent 147 | csharp_style_expression_bodied_properties = true:silent 148 | csharp_style_expression_bodied_indexers = true:silent 149 | csharp_style_expression_bodied_accessors = true:silent 150 | # Pattern matching preferences 151 | csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion 152 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion 153 | # Null-checking preferences 154 | csharp_style_throw_expression = true:suggestion 155 | csharp_style_conditional_delegate_call = true:suggestion 156 | # Modifier preferences 157 | csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion 158 | # Expression-level preferences 159 | csharp_prefer_braces = true:silent 160 | csharp_style_deconstructed_variable_declaration = true:suggestion 161 | csharp_prefer_simple_default_expression = true:suggestion 162 | csharp_style_pattern_local_over_anonymous_function = true:suggestion 163 | csharp_style_inlined_variable_declaration = true:suggestion 164 | 165 | ############################### 166 | # C# Formatting Rules # 167 | ############################### 168 | # New line preferences 169 | csharp_new_line_before_open_brace = all 170 | csharp_new_line_before_else = true 171 | csharp_new_line_before_catch = true 172 | csharp_new_line_before_finally = true 173 | csharp_new_line_before_members_in_object_initializers = true 174 | csharp_new_line_before_members_in_anonymous_types = true 175 | csharp_new_line_between_query_expression_clauses = true 176 | # Indentation preferences 177 | csharp_indent_case_contents = true 178 | csharp_indent_switch_labels = true 179 | csharp_indent_labels = flush_left 180 | # Space preferences 181 | csharp_space_after_cast = false 182 | csharp_space_after_keywords_in_control_flow_statements = true 183 | csharp_space_between_method_call_parameter_list_parentheses = false 184 | csharp_space_between_method_declaration_parameter_list_parentheses = false 185 | csharp_space_between_parentheses = false 186 | csharp_space_before_colon_in_inheritance_clause = true 187 | csharp_space_after_colon_in_inheritance_clause = true 188 | csharp_space_around_binary_operators = before_and_after 189 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false 190 | csharp_space_between_method_call_name_and_opening_parenthesis = false 191 | csharp_space_between_method_call_empty_parameter_list_parentheses = false 192 | # Wrapping preferences 193 | csharp_preserve_single_line_statements = true 194 | csharp_preserve_single_line_blocks = true 195 | -------------------------------------------------------------------------------- /Jellyfin.Plugin.ClassicTV/Configuration/configPage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ClassicTV Configuration 5 | 6 | 7 | 8 |
9 |
10 |
11 |

Configuración ClassicTV

12 |
13 |
14 | 15 | 18 |
Selecciona varias series manteniendo pulsado Ctrl o Shift.
19 |
20 |
21 | 22 | 25 |
Selecciona varios usuarios manteniendo pulsado Ctrl o Shift. Si no seleccionas ninguno, no se crearán playlists.
26 |
27 |
28 | 31 |
32 |
33 |
34 |
35 | 192 |
193 | 194 | 195 | -------------------------------------------------------------------------------- /ILibraryManager.cs: -------------------------------------------------------------------------------- 1 | #pragma warning disable CA1002, CS1591 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using Jellyfin.Data.Entities; 8 | using Jellyfin.Data.Enums; 9 | using MediaBrowser.Controller.Dto; 10 | using MediaBrowser.Controller.Entities; 11 | using MediaBrowser.Controller.Entities.Audio; 12 | using MediaBrowser.Controller.Providers; 13 | using MediaBrowser.Controller.Resolvers; 14 | using MediaBrowser.Controller.Sorting; 15 | using MediaBrowser.Model.Configuration; 16 | using MediaBrowser.Model.Dto; 17 | using MediaBrowser.Model.Entities; 18 | using MediaBrowser.Model.IO; 19 | using MediaBrowser.Model.Querying; 20 | using Episode = MediaBrowser.Controller.Entities.TV.Episode; 21 | using Genre = MediaBrowser.Controller.Entities.Genre; 22 | using Person = MediaBrowser.Controller.Entities.Person; 23 | 24 | namespace MediaBrowser.Controller.Library 25 | { 26 | /// 27 | /// Interface ILibraryManager. 28 | /// 29 | public interface ILibraryManager 30 | { 31 | /// 32 | /// Occurs when [item added]. 33 | /// 34 | event EventHandler? ItemAdded; 35 | 36 | /// 37 | /// Occurs when [item updated]. 38 | /// 39 | event EventHandler? ItemUpdated; 40 | 41 | /// 42 | /// Occurs when [item removed]. 43 | /// 44 | event EventHandler? ItemRemoved; 45 | 46 | /// 47 | /// Gets the root folder. 48 | /// 49 | /// The root folder. 50 | AggregateFolder RootFolder { get; } 51 | 52 | bool IsScanRunning { get; } 53 | 54 | /// 55 | /// Resolves the path. 56 | /// 57 | /// The file information. 58 | /// The parent. 59 | /// An instance of . 60 | /// BaseItem. 61 | BaseItem? ResolvePath( 62 | FileSystemMetadata fileInfo, 63 | Folder? parent = null, 64 | IDirectoryService? directoryService = null); 65 | 66 | /// 67 | /// Resolves a set of files into a list of BaseItem. 68 | /// 69 | /// The list of tiles. 70 | /// Instance of the interface. 71 | /// The parent folder. 72 | /// The library options. 73 | /// The collection type. 74 | /// The items resolved from the paths. 75 | IEnumerable ResolvePaths( 76 | IEnumerable files, 77 | IDirectoryService directoryService, 78 | Folder parent, 79 | LibraryOptions libraryOptions, 80 | CollectionType? collectionType = null); 81 | 82 | /// 83 | /// Gets a Person. 84 | /// 85 | /// The name of the person. 86 | /// Task{Person}. 87 | Person? GetPerson(string name); 88 | 89 | /// 90 | /// Finds the by path. 91 | /// 92 | /// The path. 93 | /// true is the path is a directory; otherwise false. 94 | /// BaseItem. 95 | BaseItem? FindByPath(string path, bool? isFolder); 96 | 97 | /// 98 | /// Gets the artist. 99 | /// 100 | /// The name of the artist. 101 | /// Task{Artist}. 102 | MusicArtist GetArtist(string name); 103 | 104 | MusicArtist GetArtist(string name, DtoOptions options); 105 | 106 | /// 107 | /// Gets a Studio. 108 | /// 109 | /// The name of the studio. 110 | /// Task{Studio}. 111 | Studio GetStudio(string name); 112 | 113 | /// 114 | /// Gets a Genre. 115 | /// 116 | /// The name of the genre. 117 | /// Task{Genre}. 118 | Genre GetGenre(string name); 119 | 120 | /// 121 | /// Gets the genre. 122 | /// 123 | /// The name of the music genre. 124 | /// Task{MusicGenre}. 125 | MusicGenre GetMusicGenre(string name); 126 | 127 | /// 128 | /// Gets a Year. 129 | /// 130 | /// The value. 131 | /// Task{Year}. 132 | /// Throws if year is invalid. 133 | Year GetYear(int value); 134 | 135 | /// 136 | /// Validate and refresh the People sub-set of the IBN. 137 | /// The items are stored in the db but not loaded into memory until actually requested by an operation. 138 | /// 139 | /// The progress. 140 | /// The cancellation token. 141 | /// Task. 142 | Task ValidatePeopleAsync(IProgress progress, CancellationToken cancellationToken); 143 | 144 | /// 145 | /// Reloads the root media folder. 146 | /// 147 | /// The progress. 148 | /// The cancellation token. 149 | /// Task. 150 | Task ValidateMediaLibrary(IProgress progress, CancellationToken cancellationToken); 151 | 152 | /// 153 | /// Reloads the root media folder. 154 | /// 155 | /// The cancellation token. 156 | /// Is remove the library itself allowed. 157 | /// Task. 158 | Task ValidateTopLibraryFolders(CancellationToken cancellationToken, bool removeRoot = false); 159 | 160 | Task UpdateImagesAsync(BaseItem item, bool forceUpdate = false); 161 | 162 | /// 163 | /// Gets the default view. 164 | /// 165 | /// IEnumerable{VirtualFolderInfo}. 166 | List GetVirtualFolders(); 167 | 168 | List GetVirtualFolders(bool includeRefreshState); 169 | 170 | /// 171 | /// Gets the item by id. 172 | /// 173 | /// The id. 174 | /// BaseItem. 175 | /// is null. 176 | BaseItem? GetItemById(Guid id); 177 | 178 | /// 179 | /// Gets the item by id, as T. 180 | /// 181 | /// The item id. 182 | /// The type of item. 183 | /// The item. 184 | T? GetItemById(Guid id) 185 | where T : BaseItem; 186 | 187 | /// 188 | /// Gets the item by id, as T, and validates user access. 189 | /// 190 | /// The item id. 191 | /// The user id to validate against. 192 | /// The type of item. 193 | /// The item if found. 194 | public T? GetItemById(Guid id, Guid userId) 195 | where T : BaseItem; 196 | 197 | /// 198 | /// Gets the item by id, as T, and validates user access. 199 | /// 200 | /// The item id. 201 | /// The user to validate against. 202 | /// The type of item. 203 | /// The item if found. 204 | public T? GetItemById(Guid id, User? user) 205 | where T : BaseItem; 206 | 207 | /// 208 | /// Gets the intros. 209 | /// 210 | /// The item. 211 | /// The user. 212 | /// IEnumerable{System.String}. 213 | Task> GetIntros(BaseItem item, User user); 214 | 215 | /// 216 | /// Adds the parts. 217 | /// 218 | /// The rules. 219 | /// The resolvers. 220 | /// The intro providers. 221 | /// The item comparers. 222 | /// The postscan tasks. 223 | void AddParts( 224 | IEnumerable rules, 225 | IEnumerable resolvers, 226 | IEnumerable introProviders, 227 | IEnumerable itemComparers, 228 | IEnumerable postscanTasks); 229 | 230 | /// 231 | /// Sorts the specified items. 232 | /// 233 | /// The items. 234 | /// The user. 235 | /// The sort by. 236 | /// The sort order. 237 | /// IEnumerable{BaseItem}. 238 | IEnumerable Sort(IEnumerable items, User? user, IEnumerable sortBy, SortOrder sortOrder); 239 | 240 | IEnumerable Sort(IEnumerable items, User? user, IEnumerable<(ItemSortBy OrderBy, SortOrder SortOrder)> orderBy); 241 | 242 | /// 243 | /// Gets the user root folder. 244 | /// 245 | /// UserRootFolder. 246 | Folder GetUserRootFolder(); 247 | 248 | /// 249 | /// Creates the item. 250 | /// 251 | /// Item to create. 252 | /// Parent of new item. 253 | void CreateItem(BaseItem item, BaseItem? parent); 254 | 255 | /// 256 | /// Creates the items. 257 | /// 258 | /// Items to create. 259 | /// Parent of new items. 260 | /// CancellationToken to use for operation. 261 | void CreateItems(IReadOnlyList items, BaseItem? parent, CancellationToken cancellationToken); 262 | 263 | /// 264 | /// Updates the item. 265 | /// 266 | /// Items to update. 267 | /// Parent of updated items. 268 | /// Reason for update. 269 | /// CancellationToken to use for operation. 270 | /// Returns a Task that can be awaited. 271 | Task UpdateItemsAsync(IReadOnlyList items, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken); 272 | 273 | /// 274 | /// Updates the item. 275 | /// 276 | /// The item. 277 | /// The parent item. 278 | /// The update reason. 279 | /// The cancellation token. 280 | /// Returns a Task that can be awaited. 281 | Task UpdateItemAsync(BaseItem item, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken); 282 | 283 | /// 284 | /// Retrieves the item. 285 | /// 286 | /// The id. 287 | /// BaseItem. 288 | BaseItem RetrieveItem(Guid id); 289 | 290 | /// 291 | /// Finds the type of the collection. 292 | /// 293 | /// The item. 294 | /// System.String. 295 | CollectionType? GetContentType(BaseItem item); 296 | 297 | /// 298 | /// Gets the type of the inherited content. 299 | /// 300 | /// The item. 301 | /// System.String. 302 | CollectionType? GetInheritedContentType(BaseItem item); 303 | 304 | /// 305 | /// Gets the type of the configured content. 306 | /// 307 | /// The item. 308 | /// System.String. 309 | CollectionType? GetConfiguredContentType(BaseItem item); 310 | 311 | /// 312 | /// Gets the type of the configured content. 313 | /// 314 | /// The path. 315 | /// System.String. 316 | CollectionType? GetConfiguredContentType(string path); 317 | 318 | /// 319 | /// Normalizes the root path list. 320 | /// 321 | /// The paths. 322 | /// IEnumerable{System.String}. 323 | List NormalizeRootPathList(IEnumerable paths); 324 | 325 | /// 326 | /// Registers the item. 327 | /// 328 | /// The item. 329 | void RegisterItem(BaseItem item); 330 | 331 | /// 332 | /// Deletes the item. 333 | /// 334 | /// Item to delete. 335 | /// Options to use for deletion. 336 | void DeleteItem(BaseItem item, DeleteOptions options); 337 | 338 | /// 339 | /// Deletes the item. 340 | /// 341 | /// Item to delete. 342 | /// Options to use for deletion. 343 | /// Notify parent of deletion. 344 | void DeleteItem(BaseItem item, DeleteOptions options, bool notifyParentItem); 345 | 346 | /// 347 | /// Deletes the item. 348 | /// 349 | /// Item to delete. 350 | /// Options to use for deletion. 351 | /// Parent of item. 352 | /// Notify parent of deletion. 353 | void DeleteItem(BaseItem item, DeleteOptions options, BaseItem parent, bool notifyParentItem); 354 | 355 | /// 356 | /// Gets the named view. 357 | /// 358 | /// The user. 359 | /// The name. 360 | /// The parent identifier. 361 | /// Type of the view. 362 | /// Name of the sort. 363 | /// The named view. 364 | UserView GetNamedView( 365 | User user, 366 | string name, 367 | Guid parentId, 368 | CollectionType? viewType, 369 | string sortName); 370 | 371 | /// 372 | /// Gets the named view. 373 | /// 374 | /// The user. 375 | /// The name. 376 | /// Type of the view. 377 | /// Name of the sort. 378 | /// The named view. 379 | UserView GetNamedView( 380 | User user, 381 | string name, 382 | CollectionType? viewType, 383 | string sortName); 384 | 385 | /// 386 | /// Gets the named view. 387 | /// 388 | /// The name. 389 | /// Type of the view. 390 | /// Name of the sort. 391 | /// The named view. 392 | UserView GetNamedView( 393 | string name, 394 | CollectionType viewType, 395 | string sortName); 396 | 397 | /// 398 | /// Gets the named view. 399 | /// 400 | /// The name. 401 | /// The parent identifier. 402 | /// Type of the view. 403 | /// Name of the sort. 404 | /// The unique identifier. 405 | /// The named view. 406 | UserView GetNamedView( 407 | string name, 408 | Guid parentId, 409 | CollectionType? viewType, 410 | string sortName, 411 | string uniqueId); 412 | 413 | /// 414 | /// Gets the shadow view. 415 | /// 416 | /// The parent. 417 | /// Type of the view. 418 | /// Name of the sort. 419 | /// The shadow view. 420 | UserView GetShadowView( 421 | BaseItem parent, 422 | CollectionType? viewType, 423 | string sortName); 424 | 425 | /// 426 | /// Gets the season number from path. 427 | /// 428 | /// The path. 429 | /// System.Nullable<System.Int32>. 430 | int? GetSeasonNumberFromPath(string path); 431 | 432 | /// 433 | /// Fills the missing episode numbers from path. 434 | /// 435 | /// Episode to use. 436 | /// Option to force refresh of episode numbers. 437 | /// True if successful. 438 | bool FillMissingEpisodeNumbersFromPath(Episode episode, bool forceRefresh); 439 | 440 | /// 441 | /// Parses the name. 442 | /// 443 | /// The name. 444 | /// ItemInfo. 445 | ItemLookupInfo ParseName(string name); 446 | 447 | /// 448 | /// Gets the new item identifier. 449 | /// 450 | /// The key. 451 | /// The type. 452 | /// Guid. 453 | Guid GetNewItemId(string key, Type type); 454 | 455 | /// 456 | /// Finds the extras. 457 | /// 458 | /// The owner. 459 | /// The file system children. 460 | /// An instance of . 461 | /// IEnumerable<BaseItem>. 462 | IEnumerable FindExtras(BaseItem owner, IReadOnlyList fileSystemChildren, IDirectoryService directoryService); 463 | 464 | /// 465 | /// Gets the collection folders. 466 | /// 467 | /// The item. 468 | /// The folders that contain the item. 469 | List GetCollectionFolders(BaseItem item); 470 | 471 | /// 472 | /// Gets the collection folders. 473 | /// 474 | /// The item. 475 | /// The root folders to consider. 476 | /// The folders that contain the item. 477 | List GetCollectionFolders(BaseItem item, IEnumerable allUserRootChildren); 478 | 479 | LibraryOptions GetLibraryOptions(BaseItem item); 480 | 481 | /// 482 | /// Gets the people. 483 | /// 484 | /// The item. 485 | /// List<PersonInfo>. 486 | List GetPeople(BaseItem item); 487 | 488 | /// 489 | /// Gets the people. 490 | /// 491 | /// The query. 492 | /// List<PersonInfo>. 493 | List GetPeople(InternalPeopleQuery query); 494 | 495 | /// 496 | /// Gets the people items. 497 | /// 498 | /// The query. 499 | /// List<Person>. 500 | List GetPeopleItems(InternalPeopleQuery query); 501 | 502 | /// 503 | /// Updates the people. 504 | /// 505 | /// The item. 506 | /// The people. 507 | void UpdatePeople(BaseItem item, List people); 508 | 509 | /// 510 | /// Asynchronously updates the people. 511 | /// 512 | /// The item. 513 | /// The people. 514 | /// The cancellation token. 515 | /// The async task. 516 | Task UpdatePeopleAsync(BaseItem item, List people, CancellationToken cancellationToken); 517 | 518 | /// 519 | /// Gets the item ids. 520 | /// 521 | /// The query. 522 | /// List<Guid>. 523 | List GetItemIds(InternalItemsQuery query); 524 | 525 | /// 526 | /// Gets the people names. 527 | /// 528 | /// The query. 529 | /// List<System.String>. 530 | List GetPeopleNames(InternalPeopleQuery query); 531 | 532 | /// 533 | /// Queries the items. 534 | /// 535 | /// The query. 536 | /// QueryResult<BaseItem>. 537 | QueryResult QueryItems(InternalItemsQuery query); 538 | 539 | string GetPathAfterNetworkSubstitution(string path, BaseItem? ownerItem = null); 540 | 541 | /// 542 | /// Converts the image to local. 543 | /// 544 | /// The item. 545 | /// The image. 546 | /// Index of the image. 547 | /// Whether to remove the image from the item on failure. 548 | /// Task. 549 | Task ConvertImageToLocal(BaseItem item, ItemImageInfo image, int imageIndex, bool removeOnFailure = true); 550 | 551 | /// 552 | /// Gets the items. 553 | /// 554 | /// The query. 555 | /// QueryResult<BaseItem>. 556 | List GetItemList(InternalItemsQuery query); 557 | 558 | List GetItemList(InternalItemsQuery query, bool allowExternalContent); 559 | 560 | /// 561 | /// Gets the items. 562 | /// 563 | /// The query to use. 564 | /// Items to use for query. 565 | /// List of items. 566 | List GetItemList(InternalItemsQuery query, List parents); 567 | 568 | /// 569 | /// Gets the items result. 570 | /// 571 | /// The query. 572 | /// QueryResult<BaseItem>. 573 | QueryResult GetItemsResult(InternalItemsQuery query); 574 | 575 | /// 576 | /// Ignores the file. 577 | /// 578 | /// The file. 579 | /// The parent. 580 | /// true if XXXX, false otherwise. 581 | bool IgnoreFile(FileSystemMetadata file, BaseItem parent); 582 | 583 | Guid GetStudioId(string name); 584 | 585 | Guid GetGenreId(string name); 586 | 587 | Guid GetMusicGenreId(string name); 588 | 589 | Task AddVirtualFolder(string name, CollectionTypeOptions? collectionType, LibraryOptions options, bool refreshLibrary); 590 | 591 | Task RemoveVirtualFolder(string name, bool refreshLibrary); 592 | 593 | void AddMediaPath(string virtualFolderName, MediaPathInfo mediaPath); 594 | 595 | void UpdateMediaPath(string virtualFolderName, MediaPathInfo mediaPath); 596 | 597 | void RemoveMediaPath(string virtualFolderName, string mediaPath); 598 | 599 | QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetGenres(InternalItemsQuery query); 600 | 601 | QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetMusicGenres(InternalItemsQuery query); 602 | 603 | QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetStudios(InternalItemsQuery query); 604 | 605 | QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetArtists(InternalItemsQuery query); 606 | 607 | QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAlbumArtists(InternalItemsQuery query); 608 | 609 | QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAllArtists(InternalItemsQuery query); 610 | 611 | int GetCount(InternalItemsQuery query); 612 | 613 | Task RunMetadataSavers(BaseItem item, ItemUpdateType updateReason); 614 | 615 | BaseItem GetParentItem(Guid? parentId, Guid? userId); 616 | 617 | /// 618 | /// Queue a library scan. 619 | /// 620 | /// 621 | /// This exists so plugins can trigger a library scan. 622 | /// 623 | void QueueLibraryScan(); 624 | } 625 | } 626 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, 373 | or requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------