Compare commits
153 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 622079c887 | |||
| c9cc4f150e | |||
| 52342b3dc3 | |||
| 9fff31c451 | |||
| 233595baac | |||
| a968ae838c | |||
| 44d00af16f | |||
| 8edb8c9202 | |||
| 625b6b6958 | |||
| 6e76761994 | |||
| b07ffb2a83 | |||
| b3ef252edb | |||
| 4ffdbaf7f8 | |||
| fc221e4407 | |||
| b65f6332cb | |||
| 1a3fa6e823 | |||
| 962794c62c | |||
| 9a40ba93e8 | |||
| fd4a9a0130 | |||
| cc28016984 | |||
| 9179ea8602 | |||
| 8b49afad25 | |||
| e355c304a2 | |||
| 2bdee20beb | |||
| a085a5a4bf | |||
| 3f0267ced0 | |||
| 70123f597a | |||
| b4d6ea2646 | |||
| e0ef8b1e86 | |||
| 362582dddf | |||
| 1c49427761 | |||
| 49effb3d3f | |||
| 66e6a49cc7 | |||
| 3dca19c3e5 | |||
| 55ab16a01a | |||
| 08c8df0292 | |||
| 1a8f3b1aa7 | |||
| 59bfaa077e | |||
| 9635a49c06 | |||
| 00eeff552c | |||
| 4294e7d138 | |||
| b2c7ba6509 | |||
| 81895dadab | |||
| 59710b2aba | |||
| f34db507b0 | |||
| a2432beaa2 | |||
| c908ea5b9c | |||
| e61beea66b | |||
| 61b3849406 | |||
| cb9f79b3fa | |||
| cf7cdb1ab3 | |||
| f202240fe6 | |||
| b9d0aeeb05 | |||
| 46ac3cfdfa | |||
| a00060ca9c | |||
| c3f5248c80 | |||
| 9921dd2308 | |||
| 1fcbbba49f | |||
| 4557ab6efd | |||
| 9febfef12a | |||
| 56e8c29a94 | |||
| 7ea9d20e86 | |||
| bff3b2b59a | |||
| c4b1d1d954 | |||
| 8842a5fdf9 | |||
| bc5fd7fa20 | |||
| 13fd9de010 | |||
| 6803016a17 | |||
| 00047b6753 | |||
| 107aa0ed6c | |||
| c93d705216 | |||
| 8cbdeee818 | |||
| f70527d218 | |||
| 9f2c7e4510 | |||
| a5904a5310 | |||
| a7c6d575ed | |||
| 5b14b3ac87 | |||
| 8b6eae7a6c | |||
| 3c33025cfa | |||
| da56d00689 | |||
| aab2de6189 | |||
| 9b0c4b5d34 | |||
| d6cf76f948 | |||
| 03c77fcbc5 | |||
| 1f33b908be | |||
| ebb74cf7f5 | |||
| 59550760eb | |||
| 3b9d235aee | |||
| 857ca0f8e0 | |||
| 80f1091af3 | |||
| d1ddd4d32d | |||
| 924f85260e | |||
| ca56fcac34 | |||
| 37c7056204 | |||
| 8d89c82660 | |||
| 06efee0051 | |||
| 83b92f5dfe | |||
| 8e77326c20 | |||
| 37a49ddabd | |||
| 6e24a61623 | |||
| ddd61fa39c | |||
| 3ba7e2ec52 | |||
| 40d5c90c4c | |||
| 634b3f7dc7 | |||
| 057020f0ba | |||
| 02846a7d00 | |||
| c9fee17716 | |||
| 195acd2f1b | |||
| 14032d3ed3 | |||
| 604ed24f7c | |||
| eefdd2a635 | |||
| 30715d5c26 | |||
| c12340583e | |||
| a9b335f797 | |||
| 6d5c0b86b2 | |||
| 347b2131db | |||
| 5a7b43f6e9 | |||
| 6f6cb3dab6 | |||
| 80b236d643 | |||
| 8b491ee673 | |||
| 7e6a757aa1 | |||
| c3b2512f6a | |||
| df36579616 | |||
| 46088c2373 | |||
| f9a82e2109 | |||
| 7436c8643c | |||
| c1969a949c | |||
| a2429c89ff | |||
| 06860f43fc | |||
| d03ee06947 | |||
| a3cf4564b4 | |||
| 57263ee789 | |||
| 313a53fe44 | |||
| 3514ab34d4 | |||
| 23e4c38944 | |||
| 78564eea98 | |||
| 2c33e28d36 | |||
| 4fdd41ed0f | |||
| 38d0b2c261 | |||
| 6db6ee2ebb | |||
| 33ab2109ed | |||
| c6780ba66a | |||
| 84c5f7d00a | |||
| f9a6edc7a5 | |||
| 7d8787bea9 | |||
| acb9be9b06 | |||
| 7ba2813105 | |||
| 9aa49ece01 | |||
| b45eb0ce52 | |||
| 039786e1d7 | |||
| a503714647 | |||
| dc7c30a55f | |||
| 24650861c0 |
@@ -0,0 +1,55 @@
|
||||
name: Bug Report
|
||||
description: File a bug report
|
||||
title: "[Bug]: "
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to help improve this project! Please read the [how to open an issue](https://github.com/tubearchivist/tubearchivist/blob/master/CONTRIBUTING.md#how-to-open-an-issue) guide carefully before continuing.
|
||||
|
||||
- type: checkboxes
|
||||
id: latest
|
||||
attributes:
|
||||
label: "I've read the documentation"
|
||||
options:
|
||||
- label: I'm running the latest version of tubearchivist-jf-plugin.
|
||||
required: true
|
||||
- label: I have read the [how to open an issue](https://github.com/tubearchivist/tubearchivist/blob/master/CONTRIBUTING.md#how-to-open-an-issue) guide, particularly the [bug report](https://github.com/tubearchivist/tubearchivist/blob/master/CONTRIBUTING.md#bug-report) section.
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: os
|
||||
attributes:
|
||||
label: Operating System
|
||||
description: On what operating system are you running Tube Archivist on?
|
||||
placeholder: eg. Linux, Windows, ...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: what-happened
|
||||
attributes:
|
||||
label: Your Bug Report
|
||||
value: "## Describe the bug\n\n## Steps To Reproduce\n\n## Expected behavior"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Relevant Jellyfin log output
|
||||
description: Please copy and paste any relevant Jellyfin logs. This will be automatically formatted into code, so no need for backticks.
|
||||
render: shell
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Anything else?
|
||||
description: |
|
||||
Links? References? Anything that will give us more context about the issue you are encountering!
|
||||
|
||||
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
|
||||
validations:
|
||||
required: false
|
||||
@@ -0,0 +1,34 @@
|
||||
name: Feature Request
|
||||
description: I have an idea for a great addition to this project
|
||||
title: "[Feature Request]: "
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to help improve this project! This project is *very* selective with accepting new feature requests. Please read the [how to open an issue](https://github.com/tubearchivist/tubearchivist/blob/master/CONTRIBUTING.md#how-to-open-an-issue) guide carefully before continuing.
|
||||
|
||||
- type: checkboxes
|
||||
id: already
|
||||
attributes:
|
||||
label: "I've read the documentation"
|
||||
options:
|
||||
- label: I have read the [how to open an issue](https://github.com/tubearchivist/tubearchivist/blob/master/CONTRIBUTING.md#how-to-open-an-issue) guide, particularly the [feature request](https://github.com/tubearchivist/tubearchivist/blob/master/CONTRIBUTING.md#feature-request) section.
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Your Feature Request
|
||||
value: "## Is your feature request related to a problem? Please describe.\n\n## Describe the solution you'd like\n\n## Additional context"
|
||||
placeholder: Tell us what you see!
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: checkboxes
|
||||
id: help
|
||||
attributes:
|
||||
label: Your help is needed!
|
||||
description: This project is ambitious as it is, please contribute.
|
||||
options:
|
||||
- label: Yes I will work on this in the next few days or weeks.
|
||||
@@ -0,0 +1,86 @@
|
||||
name: TubeArchivistMetadata Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Build & Release
|
||||
permissions:
|
||||
contents: write
|
||||
packages: read
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get release version
|
||||
id: newtag
|
||||
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
||||
|
||||
- name: Setup .Net
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
|
||||
- name: Add Jellyfin GitHub Nuget registry to sources
|
||||
run: |
|
||||
dotnet nuget add source \
|
||||
--username DarkFighterLuke \
|
||||
--password ${{ secrets.GITHUB_TOKEN }} \
|
||||
--store-password-in-clear-text \
|
||||
--name github https://nuget.pkg.github.com/jellyfin/index.json
|
||||
|
||||
- name: Get version number only
|
||||
run: |
|
||||
TAG=${{ steps.newtag.outputs.tag }}
|
||||
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
|
||||
|
||||
- name: Generate release message
|
||||
run: |
|
||||
# Read the YAML file and extract the value of the 'changelog' field
|
||||
changelog=$(awk '/changelog:/ {flag=1; next} /^[^ ]/ {flag=0} flag' build.yaml | awk '{$1=$1};1')
|
||||
|
||||
# Check if changelog contains multiple lines
|
||||
if [[ $(echo "$changelog" | wc -l) -gt 1 ]]; then
|
||||
changelog=$(echo "$changelog" | sed 's/^/* /')
|
||||
else
|
||||
changelog="* $changelog"
|
||||
fi
|
||||
|
||||
# Create release-changelog.md
|
||||
echo "Changelog:" > release-changelog.md
|
||||
echo "$changelog" >> release-changelog.md
|
||||
|
||||
|
||||
- name: Build Jellyfin Plugin
|
||||
uses: DarkFighterLuke/jellyfin-plugin-repository-manager@7a96768accc155ac7b597351b5033532f3c48173
|
||||
id: jprm
|
||||
with:
|
||||
dotnet-target: net8.0
|
||||
version: ${VERSION}
|
||||
update-manifest: "true"
|
||||
|
||||
- name: Create release
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
artifacts: ${{ steps.jprm.outputs.artifact }}
|
||||
makeLatest: latest
|
||||
bodyFile: release-changelog.md
|
||||
tag: ${{ steps.newtag.outputs.tag }}
|
||||
allowUpdates: true
|
||||
|
||||
- name: Commit manifest.json
|
||||
uses: EndBug/add-and-commit@v9
|
||||
with:
|
||||
add: manifest.json
|
||||
commit: --signoff
|
||||
message: "Update manifest.json"
|
||||
pull: "--no-rebase -X ours origin master"
|
||||
@@ -0,0 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>1.3.0.0</Version>
|
||||
<AssemblyVersion>1.3.0.0</AssemblyVersion>
|
||||
<FileVersion>1.3.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,4 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
|
||||
using MediaBrowser.Model.Plugins;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
||||
{
|
||||
@@ -7,14 +13,34 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
||||
/// </summary>
|
||||
public class PluginConfiguration : BasePluginConfiguration
|
||||
{
|
||||
private ILogger _logger;
|
||||
private string _tubeArchivistUrl;
|
||||
private string _tubeArchivistApiKey;
|
||||
private HashSet<string> _jfUsernamesTo;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PluginConfiguration"/> class.
|
||||
/// </summary>
|
||||
public PluginConfiguration()
|
||||
{
|
||||
CollectionTitle = "YouTube";
|
||||
TubeArchivistUrl = string.Empty;
|
||||
TubeArchivistApiKey = string.Empty;
|
||||
if (Plugin.Instance == null)
|
||||
{
|
||||
throw new DataException("Uninitialized plugin!");
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger = Plugin.Instance.Logger;
|
||||
}
|
||||
|
||||
CollectionTitle = string.Empty;
|
||||
_tubeArchivistUrl = string.Empty;
|
||||
_tubeArchivistApiKey = string.Empty;
|
||||
MaxDescriptionLength = 500;
|
||||
JFTASync = false;
|
||||
JFUsernameFrom = string.Empty;
|
||||
TAJFSync = false;
|
||||
_jfUsernamesTo = new HashSet<string>();
|
||||
TAJFTaskInterval = 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -25,11 +51,97 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
||||
/// <summary>
|
||||
/// Gets or sets TubeArchivist URL.
|
||||
/// </summary>
|
||||
public string TubeArchivistUrl { get; set; }
|
||||
public string TubeArchivistUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
return _tubeArchivistUrl;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value.StartsWith("http://", StringComparison.CurrentCulture) || value.StartsWith("https://", StringComparison.CurrentCulture))
|
||||
{
|
||||
_tubeArchivistUrl = Utils.SanitizeUrl(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation("{Message}", "Given TubeArchivist URL contains no schema. Adding http://...");
|
||||
_tubeArchivistUrl = Utils.SanitizeUrl("http://" + value);
|
||||
}
|
||||
|
||||
Plugin.Instance?.LogTAApiConnectionStatus();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets TubeArchivist API key.
|
||||
/// </summary>
|
||||
public string TubeArchivistApiKey { get; set; }
|
||||
public string TubeArchivistApiKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return _tubeArchivistApiKey;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_tubeArchivistApiKey = value;
|
||||
Plugin.Instance?.LogTAApiConnectionStatus();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets maximum series and episodes overviews length.
|
||||
/// </summary>
|
||||
public int MaxDescriptionLength { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to enable TA->JF playback progress synchronization.
|
||||
/// </summary>
|
||||
public bool TAJFSync { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to enable JF->TA playback progress synchronization.
|
||||
/// </summary>
|
||||
public bool JFTASync { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the playback progress owner Jellyfin username to synchronize data to TubeArchivist.
|
||||
/// </summary>
|
||||
public string JFUsernameFrom { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the playback progress owners Jellyfin usernames to synchronize data from TubeArchivist.
|
||||
/// </summary>
|
||||
public string JFUsernamesTo
|
||||
{
|
||||
get
|
||||
{
|
||||
_logger.LogInformation("JFUsernamesTo configured: {Message}", string.Join(", ", _jfUsernamesTo));
|
||||
return string.Join(", ", _jfUsernamesTo);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
value.Replace(" ", string.Empty, StringComparison.CurrentCulture).Split(',').ToList().ForEach(u => _jfUsernamesTo.Add(u));
|
||||
_logger.LogInformation("Set JFUsernamesTo to: {Message}", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the interval in seconds at which the TubeArchivist to Jellyfin playback progress synchronization task should run.
|
||||
/// It requires Jellyfin server restart to take effect.
|
||||
/// </summary>
|
||||
public int TAJFTaskInterval { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the playback progress owners Jellyfin usernames to synchronize data from TubeArchivist.
|
||||
/// </summary>
|
||||
/// <returns>An array of usernames.</returns>
|
||||
public HashSet<string> GetJFUsernamesToArray()
|
||||
{
|
||||
return _jfUsernamesTo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Template</title>
|
||||
<title>TubeArchivistMetadata</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -12,21 +12,73 @@
|
||||
<div data-role="content">
|
||||
<div class="content-primary">
|
||||
<form id="TemplateConfigForm">
|
||||
<div>
|
||||
<h1>TubeArchivistMetadata</h1>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="CollectionTitle">Collection Title</label>
|
||||
<input id="CollectionTitle" name="CollectionTitle" type="text" is="emby-input" />
|
||||
<input id="CollectionTitle" name="CollectionTitle" type="text" is="emby-input"
|
||||
placeholder="eg. YouTube" />
|
||||
<div class="fieldDescription">TubeArchivist collection display name</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="TubeArchivistUrl">TubeArchivist URL</label>
|
||||
<input id="TubeArchivistUrl" name="TubeArchivistUrl" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">TubeArchivist collection display name</div>
|
||||
<input id="TubeArchivistUrl" name="TubeArchivistUrl" type="text" is="emby-input"
|
||||
placeholder="http://..." />
|
||||
<div class="fieldDescription">TubeArchivist URL</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="TubeArchivistApiKey">TubeArchivist API key</label>
|
||||
<label class="inputLabel inputLabelUnfocused" for="TubeArchivistApiKey">TubeArchivist API
|
||||
key</label>
|
||||
<input id="TubeArchivistApiKey" name="TubeArchivistApiKey" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">TubeArchivist API key</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="MaxDescriptionLength">Maximum overviews
|
||||
length</label>
|
||||
<input id="MaxDescriptionLength" name="MaxDescriptionLength" type="number" is="emby-input"
|
||||
min="0" />
|
||||
<div class="fieldDescription">This is the maximum length of the descriptions showed in series
|
||||
and episodes</div>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Playback synchronization</h2>
|
||||
</div>
|
||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||
<label class="emby-checkbox-label" for="JFTASync">
|
||||
<input id="JFTASync" name="JFTASync" type="checkbox" is="emby-checkbox" />
|
||||
<span>Synchronize Jellyfin playback progress to TubeArchivist</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="JFUsernameFrom">Jellyfin username to sync
|
||||
playback status from</label>
|
||||
<input id="JFUsernameFrom" name="JFUsernameFrom" type="text" is="emby-input"
|
||||
placeholder="Username1, username2, ..." />
|
||||
<div class="fieldDescription">This is the Jellyfin username to synchronize data from on
|
||||
TubeArchivist</div>
|
||||
</div>
|
||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||
<label class="emby-checkbox-label" for="TAJFSync">
|
||||
<input id="TAJFSync" name="TAJFSync" type="checkbox" is="emby-checkbox" />
|
||||
<span>Synchronize TubeArchivist playback progress to Jellyfin</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="JFUsernamesTo">Jellyfin usernames to sync
|
||||
playback status to</label>
|
||||
<input id="JFUsernamesTo" name="JFUsernamesTo" type="text" is="emby-input"
|
||||
placeholder="Username1, username2, ..." />
|
||||
<div class="fieldDescription">These are the (comma separated) Jellyfin usernames to synchronize
|
||||
data from TubeArchivist</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="TAJFTaskInterval">TubeArchivist to Jellyfin
|
||||
playback progress synchronization interval</label>
|
||||
<input id="TAJFTaskInterval" name="TAJFTaskInterval" type="number" is="emby-input" min="1" />
|
||||
<div class="fieldDescription">This is the TubeArchivist to Jellyfin playback progress
|
||||
synchronization interval in seconds (Jellyfin restart required).</div>
|
||||
</div>
|
||||
<div>
|
||||
<button is="emby-button" type="submit" class="raised button-submit block emby-button">
|
||||
<span>Save</span>
|
||||
@@ -47,6 +99,12 @@
|
||||
document.querySelector('#CollectionTitle').value = config.CollectionTitle;
|
||||
document.querySelector('#TubeArchivistUrl').value = config.TubeArchivistUrl;
|
||||
document.querySelector('#TubeArchivistApiKey').value = config.TubeArchivistApiKey;
|
||||
document.querySelector('#MaxDescriptionLength').value = config.MaxDescriptionLength;
|
||||
document.querySelector('#JFTASync').checked = config.JFTASync;
|
||||
document.querySelector('#JFUsernamesTo').value = config.JFUsernamesTo;
|
||||
document.querySelector('#TAJFSync').checked = config.TAJFSync;
|
||||
document.querySelector('#JFUsernameFrom').value = config.JFUsernameFrom;
|
||||
document.querySelector('#TAJFTaskInterval').value = config.TAJFTaskInterval;
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
});
|
||||
@@ -58,6 +116,12 @@
|
||||
config.CollectionTitle = document.querySelector('#CollectionTitle').value;
|
||||
config.TubeArchivistUrl = document.querySelector('#TubeArchivistUrl').value;
|
||||
config.TubeArchivistApiKey = document.querySelector('#TubeArchivistApiKey').value;
|
||||
config.MaxDescriptionLength = document.querySelector('#MaxDescriptionLength').value;
|
||||
config.JFTASync = document.querySelector('#JFTASync').checked;
|
||||
config.JFUsernamesTo = document.querySelector('#JFUsernamesTo').value;
|
||||
config.TAJFSync = document.querySelector('#TAJFSync').checked;
|
||||
config.JFUsernameFrom = document.querySelector('#JFUsernameFrom').value;
|
||||
config.TAJFTaskInterval = document.querySelector('#TAJFTaskInterval').value;
|
||||
ApiClient.updatePluginConfiguration(TAMetadataConfig.pluginUniqueId, config).then(function (result) {
|
||||
Dashboard.processPluginConfigurationUpdateResult(result);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>Jellyfin.Plugin.TubeArchivistMetadata</RootNamespace>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
@@ -11,8 +11,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Jellyfin.Controller" Version="10.8.13" />
|
||||
<PackageReference Include="Jellyfin.Model" Version="10.8.13" />
|
||||
<PackageReference Include="Jellyfin.Controller" Version="10.9.0-20240509061132" />
|
||||
<PackageReference Include="Jellyfin.Model" Version="10.9.0-20240509061132" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.Configuration;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.Tasks;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Plugins;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Plugin.TubeArchivistMetadata
|
||||
@@ -16,13 +27,28 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
||||
/// </summary>
|
||||
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
||||
{
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Plugin"/> class.
|
||||
/// </summary>
|
||||
/// <param name="applicationPaths">Instance of the <see cref="IApplicationPaths"/> interface.</param>
|
||||
/// <param name="xmlSerializer">Instance of the <see cref="IXmlSerializer"/> interface.</param>
|
||||
/// <param name="logger">Instance of the <see cref="ILogger"/> interface.</param>
|
||||
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer, ILogger<Plugin> logger)
|
||||
/// <param name="sessionManager">Instance of the <see cref="ISessionManager"/> interface.</param>
|
||||
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
|
||||
/// <param name="taskManager">Instance of the <see cref="ITaskManager"/> interface.</param>
|
||||
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
|
||||
/// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
|
||||
public Plugin(
|
||||
IApplicationPaths applicationPaths,
|
||||
IXmlSerializer xmlSerializer,
|
||||
ILogger<Plugin> logger,
|
||||
ISessionManager sessionManager,
|
||||
ILibraryManager libraryManager,
|
||||
ITaskManager taskManager,
|
||||
IUserManager userManager,
|
||||
IUserDataManager userDataManager)
|
||||
: base(applicationPaths, xmlSerializer)
|
||||
{
|
||||
Instance = this;
|
||||
@@ -32,6 +58,33 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
||||
handler.CheckCertificateRevocationList = true;
|
||||
HttpClient = new HttpClient(handler);
|
||||
HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Token", Instance?.Configuration.TubeArchivistApiKey);
|
||||
SessionManager = sessionManager;
|
||||
sessionManager.PlaybackProgress += OnPlaybackProgress;
|
||||
LibraryManager = libraryManager;
|
||||
_userManager = userManager;
|
||||
userDataManager.UserDataSaved += OnWatchedStatusChange;
|
||||
|
||||
var taToJellyfinProgressSyncTask = new TAToJellyfinProgressSyncTask(logger, libraryManager, userManager, userDataManager);
|
||||
var jfToTubearchivistProgressSyncTask = new JFToTubearchivistProgressSyncTask(logger, libraryManager, userManager, userDataManager);
|
||||
var isTAJFTaskPresent = taskManager.ScheduledTasks.Any(t => t.Name.Equals(taToJellyfinProgressSyncTask.Name, StringComparison.Ordinal));
|
||||
if (Instance!.Configuration.TAJFSync && !isTAJFTaskPresent)
|
||||
{
|
||||
logger.LogInformation("Queueing task {TaskName}.", taToJellyfinProgressSyncTask.Name);
|
||||
taskManager.AddTasks([taToJellyfinProgressSyncTask]);
|
||||
taskManager.Execute<TAToJellyfinProgressSyncTask>();
|
||||
}
|
||||
|
||||
var isJFTATaskPresent = taskManager.ScheduledTasks.Any(t => t.Name.Equals(jfToTubearchivistProgressSyncTask.Name, StringComparison.Ordinal));
|
||||
if (Instance!.Configuration.JFTASync && !isJFTATaskPresent)
|
||||
{
|
||||
logger.LogInformation("Queueing task {TaskName}.", jfToTubearchivistProgressSyncTask.Name);
|
||||
taskManager.AddTasks([jfToTubearchivistProgressSyncTask]);
|
||||
taskManager.Execute<JFToTubearchivistProgressSyncTask>();
|
||||
}
|
||||
|
||||
logger.LogInformation("{Message}", "Collection display name: " + Instance?.Configuration.CollectionTitle);
|
||||
logger.LogInformation("{Message}", "TubeArchivist API URL: " + Instance?.Configuration.TubeArchivistUrl);
|
||||
logger.LogInformation("{Message}", "Pinging TubeArchivist API...");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -55,6 +108,16 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
||||
/// </summary>
|
||||
public HttpClient HttpClient { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the SessionManager used globally by the plugin.
|
||||
/// </summary>
|
||||
public ISessionManager SessionManager { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the LibraryManager used globally by the plugin.
|
||||
/// </summary>
|
||||
public ILibraryManager LibraryManager { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<PluginPageInfo> GetPages() => new[]
|
||||
{
|
||||
@@ -64,5 +127,76 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
||||
EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Configuration.configPage.html", GetType().Namespace)
|
||||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Logs the TubeArchivist API connection status.
|
||||
/// </summary>
|
||||
public void LogTAApiConnectionStatus()
|
||||
{
|
||||
Logger.LogInformation("{Message}", "Ping...");
|
||||
|
||||
var api = TubeArchivistApi.GetInstance();
|
||||
Task.Run(() => api.Ping()).ContinueWith(
|
||||
task =>
|
||||
{
|
||||
if (task.Result != null)
|
||||
{
|
||||
Logger.LogInformation("{Message}", "TubeArchivist API said: " + task.Result.Response + "!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogCritical("{Message}", "TubeArchivist API was unreachable!");
|
||||
}
|
||||
},
|
||||
TaskScheduler.Default);
|
||||
}
|
||||
|
||||
private async void OnPlaybackProgress(object? sender, PlaybackProgressEventArgs eventArgs)
|
||||
{
|
||||
if (Instance!.Configuration.JFTASync && eventArgs.Users.Any(u => Instance!.Configuration.JFUsernameFrom.Equals(u.Username, StringComparison.Ordinal)))
|
||||
{
|
||||
BaseItem? channel = LibraryManager.GetItemById(eventArgs.Item.ParentId);
|
||||
BaseItem? collection = LibraryManager.GetItemById(channel!.ParentId);
|
||||
if (collection?.Name.ToLower(CultureInfo.CurrentCulture) == Instance?.Configuration.CollectionTitle.ToLower(CultureInfo.CurrentCulture) && eventArgs.PlaybackPositionTicks != null)
|
||||
{
|
||||
long progress = (long)eventArgs.PlaybackPositionTicks / TimeSpan.TicksPerSecond;
|
||||
var videoId = Utils.GetVideoNameFromPath(eventArgs.Item.Path);
|
||||
var statusCode = await TubeArchivistApi.GetInstance().SetProgress(videoId, progress).ConfigureAwait(true);
|
||||
if (statusCode != System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
Logger.LogInformation("{Message}", $"POST /video/{videoId}/progress returned {statusCode} for video {eventArgs.Item.Name} with progress {progress} seconds");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnWatchedStatusChange(object? sender, UserDataSaveEventArgs eventArgs)
|
||||
{
|
||||
var user = _userManager.GetUserById(eventArgs.UserId);
|
||||
if (user != null && Configuration.GetJFUsernamesToArray().Contains(user!.Username))
|
||||
{
|
||||
var isPlayed = eventArgs.Item.IsPlayed(user);
|
||||
Logger.LogInformation("User {UserId} changed watched status to {Status} for the item {ItemName}", eventArgs.UserId, isPlayed, eventArgs.Item.Name);
|
||||
string itemYTId;
|
||||
if (eventArgs.Item is Series)
|
||||
{
|
||||
itemYTId = Utils.GetChannelNameFromPath(eventArgs.Item.Path);
|
||||
}
|
||||
else if (eventArgs.Item is Episode)
|
||||
{
|
||||
itemYTId = Utils.GetVideoNameFromPath(eventArgs.Item.Path);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var statusCode = await TubeArchivistApi.GetInstance().SetWatchedStatus(itemYTId, isPlayed).ConfigureAwait(true);
|
||||
if (statusCode != System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
Logger.LogInformation("POST /watched returned {StatusCode} for item {ItemName} ({VideoYTId}) with watched status {IsPlayed}", statusCode, eventArgs.Item.Name, itemYTId, isPlayed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
@@ -58,7 +60,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
|
||||
{
|
||||
var list = new List<RemoteImageInfo>();
|
||||
var taApi = TubeArchivistApi.GetInstance();
|
||||
var videoTAId = item.Path.Split("/").Last().Split(".").First();
|
||||
var videoTAId = Utils.GetVideoNameFromPath(item.Path);
|
||||
var video = await taApi.GetVideo(videoTAId).ConfigureAwait(true);
|
||||
_logger.LogInformation("{Message}", string.Format(CultureInfo.CurrentCulture, "Getting images for video: {0} ({1})", video?.Title, videoTAId));
|
||||
_logger.LogInformation("{Message}", "Thumb URI: " + video?.VidThumbUrl);
|
||||
@@ -85,7 +87,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
|
||||
}
|
||||
else
|
||||
{
|
||||
return await Plugin.Instance.HttpClient.GetAsync(new Uri(Plugin.Instance.Configuration.TubeArchivistUrl + url), cancellationToken).ConfigureAwait(false);
|
||||
return await Plugin.Instance.HttpClient.GetAsync(new Uri(Utils.SanitizeUrl(Plugin.Instance.Configuration.TubeArchivistUrl + url).TrimEnd('/')), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
@@ -49,7 +51,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
|
||||
{
|
||||
var result = new MetadataResult<Episode>();
|
||||
var taApi = TubeArchivistApi.GetInstance();
|
||||
var videoTAId = info.Path.Split("/").Last().Split(".").First();
|
||||
var videoTAId = Utils.GetVideoNameFromPath(info.Path);
|
||||
var video = await taApi.GetVideo(videoTAId).ConfigureAwait(true);
|
||||
_logger.LogInformation("{Message}", string.Format(CultureInfo.CurrentCulture, "Getting metadata for video: {0} ({1})", video?.Title, videoTAId));
|
||||
_logger.LogInformation("{Message}", "Received metadata: \n" + JsonConvert.SerializeObject(video));
|
||||
@@ -61,7 +63,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
|
||||
{
|
||||
Name = video.Channel.Name,
|
||||
ImageUrl = video.Channel.ThumbUrl,
|
||||
Type = PersonType.Actor,
|
||||
Type = Data.Enums.PersonKind.Actor,
|
||||
});
|
||||
result.HasMetadata = true;
|
||||
result.Item = video.ToEpisode();
|
||||
@@ -78,7 +80,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
|
||||
var results = new List<RemoteSearchResult>();
|
||||
|
||||
var taApi = TubeArchivistApi.GetInstance();
|
||||
var videoTAId = searchInfo.Path.Split("/").Last().Split(".").First();
|
||||
var videoTAId = Utils.GetVideoNameFromPath(searchInfo.Path);
|
||||
var video = await taApi.GetVideo(videoTAId).ConfigureAwait(true);
|
||||
if (video != null)
|
||||
{
|
||||
@@ -97,7 +99,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
|
||||
}
|
||||
else
|
||||
{
|
||||
return await Plugin.Instance.HttpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
|
||||
return await Plugin.Instance.HttpClient.GetAsync(new Uri(Utils.SanitizeUrl(Plugin.Instance.Configuration.TubeArchivistUrl + url).TrimEnd('/')), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
@@ -57,7 +58,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
|
||||
{
|
||||
var list = new List<RemoteImageInfo>();
|
||||
var taApi = TubeArchivistApi.GetInstance();
|
||||
var channelTAId = item.Path.Split("/").Last();
|
||||
var channelTAId = Utils.GetChannelNameFromPath(item.Path);
|
||||
var channel = await taApi.GetChannel(channelTAId).ConfigureAwait(true);
|
||||
_logger.LogInformation("{Message}", string.Format(CultureInfo.CurrentCulture, "Getting images for channel: {0} ({1})", channel?.Name, channelTAId));
|
||||
_logger.LogInformation("{Message}", "Thumb URI: " + channel?.ThumbUrl);
|
||||
@@ -98,7 +99,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
|
||||
}
|
||||
else
|
||||
{
|
||||
return await Plugin.Instance.HttpClient.GetAsync(new Uri(Plugin.Instance.Configuration.TubeArchivistUrl + url), cancellationToken).ConfigureAwait(false);
|
||||
return await Plugin.Instance.HttpClient.GetAsync(new Uri(Utils.SanitizeUrl(Plugin.Instance.Configuration.TubeArchivistUrl + url).TrimEnd('/')), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
@@ -49,7 +50,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
|
||||
{
|
||||
var result = new MetadataResult<Series>();
|
||||
var taApi = TubeArchivistApi.GetInstance();
|
||||
var channelTAId = info.Path.Split("/").Last();
|
||||
var channelTAId = Utils.GetChannelNameFromPath(info.Path);
|
||||
var channel = await taApi.GetChannel(channelTAId).ConfigureAwait(true);
|
||||
_logger.LogInformation("{Message}", string.Format(CultureInfo.CurrentCulture, "Getting metadata for channel: {0} ({1})", channel?.Name, channelTAId));
|
||||
_logger.LogInformation("{Message}", "Received metadata: \n" + JsonConvert.SerializeObject(channel));
|
||||
@@ -61,7 +62,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
|
||||
{
|
||||
Name = channel.Name,
|
||||
ImageUrl = channel.ThumbUrl,
|
||||
Type = PersonType.Actor,
|
||||
Type = Data.Enums.PersonKind.Actor,
|
||||
});
|
||||
result.HasMetadata = true;
|
||||
result.Item = channel.ToSeries();
|
||||
@@ -78,7 +79,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
|
||||
var results = new List<RemoteSearchResult>();
|
||||
|
||||
var taApi = TubeArchivistApi.GetInstance();
|
||||
var channelTAId = searchInfo.Path.Split("/").Last();
|
||||
var channelTAId = Utils.GetChannelNameFromPath(searchInfo.Path);
|
||||
var channel = await taApi.GetChannel(channelTAId).ConfigureAwait(true);
|
||||
if (channel != null)
|
||||
{
|
||||
@@ -97,7 +98,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
|
||||
}
|
||||
else
|
||||
{
|
||||
return await Plugin.Instance.HttpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
|
||||
return await Plugin.Instance.HttpClient.GetAsync(new Uri(Utils.SanitizeUrl(Plugin.Instance.Configuration.TubeArchivistUrl + url).TrimEnd('/')), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Plugin.TubeArchivistMetadata.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Task to sync Jellyfin playback progresses to TubeArchivist.
|
||||
/// </summary>
|
||||
public class JFToTubearchivistProgressSyncTask : IScheduledTask
|
||||
{
|
||||
private readonly ILogger<Plugin> _logger;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IUserDataManager _userDataManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="JFToTubearchivistProgressSyncTask"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">Logger.</param>
|
||||
/// <param name="libraryManager">Library manager.</param>
|
||||
/// <param name="userManager">User manager.</param>
|
||||
/// <param name="userDataManager">User data manager.</param>
|
||||
public JFToTubearchivistProgressSyncTask(ILogger<Plugin> logger, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_libraryManager = libraryManager;
|
||||
_userManager = userManager;
|
||||
_userDataManager = userDataManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Name => "JFToTubeArchivistProgressSyncTask";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Description => "This tasks syncs TubeArchivist playback progresses to Jellyfin";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Category => "TubeArchivistMetadata";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Key => "JFToTubeArchivistProgressSyncTask";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task ExecuteAsync(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
if (Plugin.Instance!.Configuration.JFTASync)
|
||||
{
|
||||
var start = DateTime.Now;
|
||||
_logger.LogInformation("Starting Jellyfin->TubeArchivist playback progresses synchronization.");
|
||||
var taApi = TubeArchivistApi.GetInstance();
|
||||
foreach (var jfUsername in Plugin.Instance!.Configuration.GetJFUsernamesToArray())
|
||||
{
|
||||
var user = _userManager.GetUserByName(jfUsername);
|
||||
if (user == null)
|
||||
{
|
||||
_logger.LogInformation("{Message}", $"Jellyfin user with username {jfUsername} not found");
|
||||
continue;
|
||||
}
|
||||
|
||||
var collectionItem = _libraryManager.GetItemList(new InternalItemsQuery
|
||||
{
|
||||
Name = Plugin.Instance?.Configuration.CollectionTitle,
|
||||
IncludeItemTypes = new[] { BaseItemKind.CollectionFolder }
|
||||
}).FirstOrDefault();
|
||||
|
||||
if (collectionItem == null)
|
||||
{
|
||||
var message = $"Collection '{Plugin.Instance?.Configuration.CollectionTitle}' not found.";
|
||||
_logger.LogCritical("{Message}", message);
|
||||
}
|
||||
else
|
||||
{
|
||||
var collection = (CollectionFolder)collectionItem;
|
||||
var channels = collection.GetChildren(user, false, new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { BaseItemKind.Series }
|
||||
});
|
||||
_logger.LogInformation("Analyzing collection {Id} with name {Name}", collectionItem.Id, collectionItem.Name);
|
||||
_logger.LogInformation("Found {Message} channels", channels.Count);
|
||||
|
||||
foreach (Series channel in channels)
|
||||
{
|
||||
var channelYTId = Utils.GetChannelNameFromPath(channel.Path);
|
||||
var isChannelWatched = false;
|
||||
var isChannelCheckedForWatched = false;
|
||||
var years = channel.GetChildren(user, false, new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { BaseItemKind.Season }
|
||||
});
|
||||
_logger.LogInformation("Found {Years} years in channel {ChannelName}", years.Count, channel.Name);
|
||||
|
||||
foreach (Season year in years)
|
||||
{
|
||||
var videos = year.GetChildren(user, false, new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { BaseItemKind.Episode }
|
||||
});
|
||||
_logger.LogInformation("Found {Videos} videos in year {YearName} of the channel {ChannelName}", videos.Count, year.Name, channel.Name);
|
||||
|
||||
foreach (Episode video in videos)
|
||||
{
|
||||
var videoYTId = Utils.GetVideoNameFromPath(video.Path);
|
||||
var playbackProgress = _userDataManager.GetUserData(user.Id, video).PlaybackPositionTicks / TimeSpan.TicksPerSecond;
|
||||
var statusCode = await taApi.SetProgress(videoYTId, playbackProgress).ConfigureAwait(true);
|
||||
if (statusCode != System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
_logger.LogInformation("{Message}", $"POST /video/{videoYTId}/progress returned {statusCode} for video {video.Name} with progress {progress} seconds");
|
||||
}
|
||||
|
||||
if (!isChannelCheckedForWatched && channel.IsPlayed(user))
|
||||
{
|
||||
var isChannelPlayed = channel.IsPlayed(user);
|
||||
statusCode = await taApi.SetWatchedStatus(channelYTId, isChannelPlayed).ConfigureAwait(true);
|
||||
if (statusCode != System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
_logger.LogInformation("{Message}", $"POST /watched returned {statusCode} for channel {channel.Name} ({channelYTId}) with wacthed status {isChannelPlayed}");
|
||||
}
|
||||
else
|
||||
{
|
||||
isChannelWatched = true;
|
||||
}
|
||||
|
||||
isChannelCheckedForWatched = true;
|
||||
}
|
||||
|
||||
if (!isChannelWatched)
|
||||
{
|
||||
var isVideoPlayed = video.IsPlayed(user);
|
||||
statusCode = await taApi.SetWatchedStatus(videoYTId, isVideoPlayed).ConfigureAwait(true);
|
||||
if (statusCode != System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
_logger.LogInformation("{Message}", $"POST /watched returned {statusCode} for video {video.Name} ({videoYTId}) with wacthed status {isVideoPlayed}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation("Time elapsed: {Time}", DateTime.Now - start);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation("Jellyfin->TubeArchivist playback synchronization is currently disabled.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
||||
{
|
||||
return
|
||||
[
|
||||
new TaskTriggerInfo
|
||||
{
|
||||
Type = TaskTriggerInfo.TriggerStartup,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Plugin.TubeArchivistMetadata.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Task to sync TubeArchivist playback progresses to Jellyfin.
|
||||
/// </summary>
|
||||
public class TAToJellyfinProgressSyncTask : IScheduledTask
|
||||
{
|
||||
private readonly ILogger<Plugin> _logger;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IUserDataManager _userDataManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TAToJellyfinProgressSyncTask"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">Logger.</param>
|
||||
/// <param name="libraryManager">Library manager.</param>
|
||||
/// <param name="userManager">User manager.</param>
|
||||
/// <param name="userDataManager">User data manager.</param>
|
||||
public TAToJellyfinProgressSyncTask(ILogger<Plugin> logger, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_libraryManager = libraryManager;
|
||||
_userManager = userManager;
|
||||
_userDataManager = userDataManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Name => "TAToJellyfinProgressSyncTask";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Description => "This tasks syncs TubeArchivist playback progresses to Jellyfin";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Category => "TubeArchivistMetadata";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Key => "TAToJellyfinProgressSyncTask";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task ExecuteAsync(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
if (Plugin.Instance!.Configuration.TAJFSync)
|
||||
{
|
||||
var start = DateTime.Now;
|
||||
_logger.LogInformation("Starting TubeArchivist->Jellyfin playback progresses synchronization.");
|
||||
var taApi = TubeArchivistApi.GetInstance();
|
||||
foreach (var jfUsername in Plugin.Instance!.Configuration.GetJFUsernamesToArray())
|
||||
{
|
||||
var user = _userManager.GetUserByName(jfUsername);
|
||||
if (user == null)
|
||||
{
|
||||
_logger.LogInformation("{Message}", $"Jellyfin user with username {jfUsername} not found");
|
||||
continue;
|
||||
}
|
||||
|
||||
var collectionItem = _libraryManager.GetItemList(new InternalItemsQuery
|
||||
{
|
||||
Name = Plugin.Instance?.Configuration.CollectionTitle,
|
||||
IncludeItemTypes = new[] { BaseItemKind.CollectionFolder }
|
||||
}).FirstOrDefault();
|
||||
|
||||
if (collectionItem == null)
|
||||
{
|
||||
var message = $"Collection '{Plugin.Instance?.Configuration.CollectionTitle}' not found.";
|
||||
_logger.LogCritical("{Message}", message);
|
||||
}
|
||||
else
|
||||
{
|
||||
var collection = (CollectionFolder)collectionItem;
|
||||
var channels = collection.GetChildren(user, false, new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { BaseItemKind.Series }
|
||||
});
|
||||
_logger.LogInformation("Analyzing collection {Id} with name {Name}", collectionItem.Id, collectionItem.Name);
|
||||
_logger.LogInformation("Found {Message} channels", channels.Count);
|
||||
|
||||
foreach (Series channel in channels)
|
||||
{
|
||||
var years = channel.GetChildren(user, false, new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { BaseItemKind.Season }
|
||||
});
|
||||
_logger.LogInformation("Found {Years} years in channel {ChannelName}", years.Count, channel.Name);
|
||||
|
||||
foreach (Season year in years)
|
||||
{
|
||||
var videos = year.GetChildren(user, false, new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { BaseItemKind.Episode }
|
||||
});
|
||||
_logger.LogInformation("Found {Videos} videos in year {YearName} of the channel {ChannelName}", videos.Count, year.Name, channel.Name);
|
||||
|
||||
foreach (Episode video in videos)
|
||||
{
|
||||
var playbackProgress = await taApi.GetProgress(Utils.GetVideoNameFromPath(video.Path)).ConfigureAwait(true);
|
||||
if (playbackProgress != null)
|
||||
{
|
||||
var userItemData = _userDataManager.GetUserData(user, video);
|
||||
var userUpdateData = new UpdateUserItemDataDto
|
||||
{
|
||||
PlaybackPositionTicks = playbackProgress.Position * TimeSpan.TicksPerSecond
|
||||
};
|
||||
|
||||
var taVideoInfo = await taApi.GetVideo(Utils.GetVideoNameFromPath(video.Path)).ConfigureAwait(true);
|
||||
if (taVideoInfo != null)
|
||||
{
|
||||
if (taVideoInfo.Player.IsWatched)
|
||||
{
|
||||
userUpdateData.Played = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
userUpdateData.Played = false;
|
||||
}
|
||||
}
|
||||
|
||||
_userDataManager.SaveUserData(user, video, userUpdateData, UserDataSaveReason.UpdateUserData);
|
||||
_logger.LogInformation("{Message}", $"Playback progress for video {video.Name} set to {userItemData.PlaybackPositionTicks / TimeSpan.TicksPerSecond} seconds for user {jfUsername}.");
|
||||
_logger.LogInformation("{Message}", $"Watched status for video {video.Name} set to {userItemData.Played} seconds for user {jfUsername}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation("Time elapsed: {Time}", DateTime.Now - start);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation("TubeArchivist->Jellyfin playback synchronization is currently disabled.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
||||
{
|
||||
return
|
||||
[
|
||||
new TaskTriggerInfo
|
||||
{
|
||||
Type = TaskTriggerInfo.TriggerInterval,
|
||||
IntervalTicks = TimeSpan.FromSeconds(Plugin.Instance!.Configuration.TAJFTaskInterval).Ticks
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
{
|
||||
/// <summary>
|
||||
/// A class representing TubeArchivist API video watched status.
|
||||
/// </summary>
|
||||
public class Watched
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Watched"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">Id of the video/channel/playlist.</param>
|
||||
/// <param name="isWatched">Watched status.</param>
|
||||
public Watched(string id, bool isWatched)
|
||||
{
|
||||
Id = id;
|
||||
IsWatched = isWatched;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the id of the video/channel/playlist.
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "id")]
|
||||
public string Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the item has been watched or not.
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "is_watched")]
|
||||
public bool IsWatched { get; }
|
||||
}
|
||||
}
|
||||
+3
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Model.Entities;
|
||||
@@ -70,6 +71,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
/// Gets channel tags.
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "channel_tags")]
|
||||
[JsonConverter(typeof(TagsJsonConverter))]
|
||||
public Collection<string> Tags { get; }
|
||||
|
||||
/// <summary>
|
||||
@@ -108,6 +110,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
return new Series
|
||||
{
|
||||
Name = Name,
|
||||
Overview = Utils.FormatDescription(Description),
|
||||
Studios = new[] { Name },
|
||||
ProviderIds = new Dictionary<string, string>()
|
||||
{
|
||||
@@ -0,0 +1,44 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
{
|
||||
/// <summary>
|
||||
/// A class representing TubeArchivist API ping response data.
|
||||
/// </summary>
|
||||
public class PingResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PingResponse"/> class.
|
||||
/// </summary>
|
||||
/// <param name="response">Response from the API ("pong").</param>
|
||||
/// <param name="user">TubeArchivist user id.</param>
|
||||
/// <param name="version">TubeArchivist version.</param>
|
||||
public PingResponse(
|
||||
string response,
|
||||
int user,
|
||||
string version)
|
||||
{
|
||||
this.Response = response;
|
||||
this.User = user;
|
||||
this.Version = version;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets response to the ping ("pong").
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "response")]
|
||||
public string Response { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets user id.
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "user")]
|
||||
public int User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets TubeArchivist version.
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "version")]
|
||||
public string Version { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom JsonConverter to handle tags list that could be null.
|
||||
/// </summary>
|
||||
public class TagsJsonConverter : JsonConverter
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType == typeof(Collection<string>);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
|
||||
{
|
||||
JToken token = JToken.Load(reader);
|
||||
var tags = new Collection<string>();
|
||||
|
||||
if (token.Type == JTokenType.Array)
|
||||
{
|
||||
var stringArray = token.ToObject<string[]>();
|
||||
if (stringArray != null)
|
||||
{
|
||||
foreach (var tag in stringArray)
|
||||
{
|
||||
tags.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tags;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
|
||||
{
|
||||
var tags = (Collection<string>)(value ?? Array.Empty<string>());
|
||||
|
||||
writer.WriteStartArray();
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
writer.WriteValue(tag);
|
||||
}
|
||||
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,9 @@ using System;
|
||||
using System.Data;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@@ -67,12 +68,13 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
ResponseContainer<Channel>? channel = null;
|
||||
|
||||
var channelsEndpoint = "/api/channel/";
|
||||
var url = new Uri(Plugin.Instance?.Configuration.TubeArchivistUrl + channelsEndpoint + channelId);
|
||||
var url = new Uri(Utils.SanitizeUrl(Plugin.Instance?.Configuration.TubeArchivistUrl + channelsEndpoint + channelId));
|
||||
var response = await client.GetAsync(url).ConfigureAwait(true);
|
||||
while (response.StatusCode == HttpStatusCode.Moved)
|
||||
{
|
||||
_logger.LogInformation("{Message}", "Received redirect to: " + response.Headers.Location);
|
||||
response = await client.GetAsync(response.Headers.Location).ConfigureAwait(true);
|
||||
url = response.Headers.Location;
|
||||
_logger.LogInformation("{Message}", "Received redirect to: " + url);
|
||||
response = await client.GetAsync(url).ConfigureAwait(true);
|
||||
}
|
||||
|
||||
_logger.LogInformation("{Message}", url + ": " + response.StatusCode);
|
||||
@@ -96,12 +98,13 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
ResponseContainer<Video>? video = null;
|
||||
|
||||
var videosEndpoint = "/api/video/";
|
||||
var url = new Uri(Plugin.Instance?.Configuration.TubeArchivistUrl + videosEndpoint + videoId);
|
||||
var url = new Uri(Utils.SanitizeUrl(Plugin.Instance?.Configuration.TubeArchivistUrl + videosEndpoint + videoId));
|
||||
var response = await client.GetAsync(url).ConfigureAwait(true);
|
||||
while (response.StatusCode == HttpStatusCode.Moved)
|
||||
{
|
||||
_logger.LogInformation("{Message}", "Received redirect to: " + response.Headers.Location);
|
||||
response = await client.GetAsync(response.Headers.Location).ConfigureAwait(true);
|
||||
url = response.Headers.Location;
|
||||
_logger.LogInformation("{Message}", "Received redirect to: " + url);
|
||||
response = await client.GetAsync(url).ConfigureAwait(true);
|
||||
}
|
||||
|
||||
_logger.LogInformation("{Message}", url + ": " + response.StatusCode);
|
||||
@@ -114,5 +117,92 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
|
||||
return video?.Data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates connection and authentication to TubeArchivist.
|
||||
/// </summary>
|
||||
/// <returns>The ping response.</returns>
|
||||
public async Task<PingResponse?> Ping()
|
||||
{
|
||||
PingResponse? pong = null;
|
||||
|
||||
var pingEndpoint = "/api/ping/";
|
||||
var url = new Uri(Utils.SanitizeUrl(Plugin.Instance!.Configuration.TubeArchivistUrl + pingEndpoint));
|
||||
var response = await client.GetAsync(url).ConfigureAwait(true);
|
||||
|
||||
while (response.StatusCode == HttpStatusCode.Moved)
|
||||
{
|
||||
url = response.Headers.Location;
|
||||
_logger.LogInformation("{Message}", "Received redirect to: " + url);
|
||||
response = await client.GetAsync(url).ConfigureAwait(true);
|
||||
}
|
||||
|
||||
_logger.LogInformation("{Message}", url + ": " + response.StatusCode);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string rawData = await response.Content.ReadAsStringAsync().ConfigureAwait(true);
|
||||
pong = JsonConvert.DeserializeObject<PingResponse>(rawData);
|
||||
}
|
||||
|
||||
return pong;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send video playback progress to TubeArchivist.
|
||||
/// </summary>
|
||||
/// <param name="videoId">Video id.</param>
|
||||
/// <param name="progress">Progress in seconds.</param>
|
||||
/// <returns>The response <see cref="HttpStatusCode"/>.</returns>
|
||||
public async Task<HttpStatusCode> SetProgress(string videoId, long progress)
|
||||
{
|
||||
var progressEndpoint = $"/api/video/{videoId}/progress/";
|
||||
var url = new Uri(Utils.SanitizeUrl(Plugin.Instance!.Configuration.TubeArchivistUrl + progressEndpoint));
|
||||
var body = JsonConvert.SerializeObject(new Progress(progress));
|
||||
|
||||
var response = await client.PostAsync(url, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(true);
|
||||
|
||||
return response.StatusCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send video playback progress to TubeArchivist.
|
||||
/// </summary>
|
||||
/// <param name="videoId">Video id.</param>
|
||||
/// <returns>Video playback progress data.</returns>
|
||||
public async Task<Progress?> GetProgress(string videoId)
|
||||
{
|
||||
Progress? progress = null;
|
||||
|
||||
var progressEndpoint = $"/api/video/{videoId}/progress/";
|
||||
var url = new Uri(Utils.SanitizeUrl(Plugin.Instance!.Configuration.TubeArchivistUrl + progressEndpoint));
|
||||
|
||||
var response = await client.GetAsync(url).ConfigureAwait(true);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string rawData = await response.Content.ReadAsStringAsync().ConfigureAwait(true);
|
||||
progress = JsonConvert.DeserializeObject<Progress>(rawData);
|
||||
}
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set video/channel/playlist as watched on TubeArchivist.
|
||||
/// </summary>
|
||||
/// <param name="itemId">Video/channel/playlist id.</param>
|
||||
/// <param name="isWatched">Whether the item has been watched or not.</param>
|
||||
/// <returns>The response <see cref="HttpStatusCode"/>.</returns>
|
||||
public async Task<HttpStatusCode> SetWatchedStatus(string itemId, bool isWatched)
|
||||
{
|
||||
var watchedEndpoint = $"/api/watched/";
|
||||
var url = new Uri(Utils.SanitizeUrl(Plugin.Instance!.Configuration.TubeArchivistUrl + watchedEndpoint));
|
||||
var body = JsonConvert.SerializeObject(new Watched(itemId, isWatched));
|
||||
|
||||
var response = await client.PostAsync(url, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(true);
|
||||
|
||||
return response.StatusCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
{
|
||||
/// <summary>
|
||||
/// A class representing TubeArchivist API video player data.
|
||||
/// </summary>
|
||||
public class Player
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Player"/> class.
|
||||
/// </summary>
|
||||
/// <param name="duration">Duration of the video.</param>
|
||||
/// <param name="isWatched">Whether the video is marked as watched.</param>
|
||||
/// <param name="watchedUnixTime">Unix time of when the video has been marked watched.</param>
|
||||
public Player(long duration, bool isWatched, long watchedUnixTime)
|
||||
{
|
||||
Duration = duration;
|
||||
IsWatched = isWatched;
|
||||
WatchedUnixTime = watchedUnixTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the duration of the video.
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "duration")]
|
||||
public long Duration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the video is marked as watched.
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "watched")]
|
||||
public bool IsWatched { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Unix date and time when the video has been marked as watched.
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "watched_date")]
|
||||
public long WatchedUnixTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date and time when the video has been marked as watched.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public DateTime WatchedTime
|
||||
{
|
||||
get => DateTimeOffset.FromUnixTimeSeconds(WatchedUnixTime).DateTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
{
|
||||
/// <summary>
|
||||
/// A class representing TubeArchivist API video progress data.
|
||||
/// </summary>
|
||||
public class Progress
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Progress"/> class.
|
||||
/// </summary>
|
||||
/// <param name="position">Playback progress in seconds.</param>
|
||||
/// <param name="youtubeId">Video YouTube id.</param>
|
||||
/// <param name="userId">Playback progress user id.</param>
|
||||
[JsonConstructor]
|
||||
public Progress(
|
||||
long position,
|
||||
string? youtubeId,
|
||||
long? userId)
|
||||
{
|
||||
YoutubeId = youtubeId;
|
||||
UserId = userId;
|
||||
Position = position;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Progress"/> class.
|
||||
/// </summary>
|
||||
/// <param name="position">Playback progress in seconds.</param>
|
||||
public Progress(long position)
|
||||
{
|
||||
Position = position;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the video YouTube id.
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "youtube_id")]
|
||||
public string? YoutubeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets playback progress user id.
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "user_id")]
|
||||
public long? UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets video playback progress (in seconds).
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "position")]
|
||||
public long Position { get; set; }
|
||||
}
|
||||
}
|
||||
+13
-1
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Model.Entities;
|
||||
@@ -26,6 +27,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
/// <param name="published">Video published date.</param>
|
||||
/// <param name="vidThumbUrl">Video thuumb image URL.</param>
|
||||
/// <param name="youtubeId">Video YouTube id.</param>
|
||||
/// <param name="player">Player info.</param>
|
||||
public Video(
|
||||
Channel channel,
|
||||
Collection<string> tags,
|
||||
@@ -33,7 +35,8 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
string description,
|
||||
DateTime published,
|
||||
string vidThumbUrl,
|
||||
string youtubeId)
|
||||
string youtubeId,
|
||||
Player player)
|
||||
{
|
||||
this.Channel = channel;
|
||||
this.Tags = tags;
|
||||
@@ -42,6 +45,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
this.Published = published;
|
||||
this.VidThumbUrl = vidThumbUrl;
|
||||
this.YoutubeId = youtubeId;
|
||||
Player = player;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -54,6 +58,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
/// Gets video tags.
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "tags")]
|
||||
[JsonConverter(typeof(TagsJsonConverter))]
|
||||
public Collection<string> Tags { get; }
|
||||
|
||||
/// <summary>
|
||||
@@ -86,6 +91,12 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
[JsonProperty(PropertyName = "youtube_id")]
|
||||
public string YoutubeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Getsthe player related info.
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "player")]
|
||||
public Player Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Converts the TubeArchivist API video to a Jellyfin <see cref="RemoteSearchResult"/> object.
|
||||
/// </summary>
|
||||
@@ -112,6 +123,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||
return new Episode
|
||||
{
|
||||
Name = Title,
|
||||
Overview = Utils.FormatDescription(Description),
|
||||
SeasonName = Published.Year.ToString(CultureInfo.CurrentCulture),
|
||||
ParentIndexNumber = Published.Year,
|
||||
SeriesName = Channel.Name,
|
||||
@@ -0,0 +1,94 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Jellyfin.Plugin.TubeArchivistMetadata.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Class containing common utils.
|
||||
/// </summary>
|
||||
public static class Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Sanitize the given URL.
|
||||
/// </summary>
|
||||
/// <param name="inputUrl">An URL string.</param>
|
||||
/// <returns>The URL string without spaces, doubled slashes and with a trailing slash.</returns>
|
||||
public static string SanitizeUrl(string inputUrl)
|
||||
{
|
||||
// Extract the schema part
|
||||
Match schemaMatch = Regex.Match(inputUrl, @"^(?<schema>https?://)");
|
||||
|
||||
// Remove double slashes and spaces from the remaining part of the URL
|
||||
string cleanedPath = Regex.Replace(inputUrl.Substring(schemaMatch.Length), @"[/\s]+", "/");
|
||||
|
||||
// Remove slashes at the start
|
||||
cleanedPath = cleanedPath.TrimStart('/');
|
||||
|
||||
// Add a trailing slash if not already present
|
||||
cleanedPath = cleanedPath.TrimEnd('/') + "/";
|
||||
|
||||
// Combine the schema and cleaned path
|
||||
string cleanedUrl = schemaMatch.Groups["schema"].Value + cleanedPath;
|
||||
|
||||
return cleanedUrl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Format episodes and series descriptions replacing newlines with br tags.
|
||||
/// </summary>
|
||||
/// <param name="description">String to format.</param>
|
||||
/// <returns>A string with \n replaced by br tags.</returns>
|
||||
public static string FormatDescription(string description)
|
||||
{
|
||||
var maxLength = 500;
|
||||
if (Plugin.Instance != null)
|
||||
{
|
||||
maxLength = Plugin.Instance.Configuration.MaxDescriptionLength;
|
||||
}
|
||||
|
||||
if (description.Length > maxLength)
|
||||
{
|
||||
description = description.Substring(0, maxLength);
|
||||
description = description.Replace("\n", "<br>", System.StringComparison.CurrentCulture);
|
||||
}
|
||||
|
||||
return description;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get video name from file path on the disk.
|
||||
/// </summary>
|
||||
/// <param name="path">File path on disk.</param>
|
||||
/// <returns>The video name.</returns>
|
||||
public static string GetVideoNameFromPath(string path)
|
||||
{
|
||||
return path.Split(DetectDirectorySeparator(path)).Last().Split(".").First();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get channel name from directory path on the disk.
|
||||
/// </summary>
|
||||
/// <param name="path">Directory path on disk.</param>
|
||||
/// <returns>The channel name.</returns>
|
||||
public static string GetChannelNameFromPath(string path)
|
||||
{
|
||||
return path.Split(DetectDirectorySeparator(path)).Last();
|
||||
}
|
||||
|
||||
private static char DetectDirectorySeparator(string path)
|
||||
{
|
||||
int backslashCount = path.Count(c => c == '\\');
|
||||
int forwardSlashCount = path.Count(c => c == '/');
|
||||
|
||||
if (backslashCount > forwardSlashCount)
|
||||
{
|
||||
return '\\'; // Windows directory separator
|
||||
}
|
||||
else
|
||||
{
|
||||
return '/'; // Unix directory separator
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,373 +1,81 @@
|
||||
# So you want to make a Jellyfin plugin
|
||||
<h1 align="center">Jellyfin TubeArchivist Plugin</h1>
|
||||
|
||||
Awesome! This guide is for you. Jellyfin plugins are written using the dotnet standard framework. What that means is you can write them in any language that implements the CLI or the DLI and can compile to net6.0. The examples on this page are in C# because that is what most of Jellyfin is written in, but F#, Visual Basic, and IronPython should all be compatible once compiled.
|
||||
<p align="center">
|
||||
<img alt="Plugin Banner" src="https://raw.githubusercontent.com/tubearchivist/tubearchivist-jf-plugin/master/images/logo.png"/>
|
||||
<br/>
|
||||
</p>
|
||||
|
||||
## 0. Things you need to get started
|
||||
> [!IMPORTANT]
|
||||
> Jellyfin 10.9.1 has been finally released and since starting with the version 1.3.0 the plugin supports only the latest Jellyfin release, in order to continue using this plugin with all the latest features you will need to upgrade your Jellyfin installation.
|
||||
|
||||
- [Dotnet SDK 6.0](https://dotnet.microsoft.com/download)
|
||||
## About
|
||||
|
||||
- An editor of your choice. Some free choices are:
|
||||
<p>This plugin adds the metadata provider for <a href="https://www.tubearchivist.com/">TubeArchivist</a>, offering improved flexibility and native integration with Jellyfin compared to previous solutions.</p>
|
||||
|
||||
[Visual Studio Code](https://code.visualstudio.com)
|
||||
## How it works
|
||||
The media organization is a `Shows` collection, where each channel is a show and its videos are the episodes, organized in seasons by year.<br>
|
||||
The plugin interacts with TubeArchivist APIs to fetch videos and channels metadata.
|
||||
|
||||
[Visual Studio Community Edition](https://visualstudio.microsoft.com/downloads)
|
||||
### Features
|
||||
- Add metadata for videos (episodes)
|
||||
- Add metadata for channels (shows)
|
||||
- Add images for videos (episodes), ie. thumb images
|
||||
- Add images for channels (shows), ie. thumb, tvart and banner images
|
||||
- Organize videos (episodes) by year (seasons)
|
||||
|
||||
[Mono Develop](https://www.monodevelop.com)
|
||||
## Installation
|
||||
### From official repository (recommended)
|
||||
1. Go to `Dashboard -> Plugins` and select the `Repositories` tab
|
||||
2. Add a new repository with the following details:
|
||||
- Repository name: `TubeArchivistMetadata`
|
||||
- Repository URL: `https://github.com/tubearchivist/tubearchivist-jf-plugin/raw/master/manifest.json`
|
||||

|
||||
|
||||
## 0.5. Quickstarts
|
||||
3. Go to the `Catalog` tab
|
||||
4. Find `TubeArchivistMetadata` in the `Metadata` section and install it
|
||||

|
||||
5. Restart Jellyfin to apply the changes
|
||||
|
||||
We have a number of quickstart options available to speed you along the way.
|
||||
### From ZIP in GitHub releases
|
||||
1. Download the latest available release (`tubearchivistmetadata_*.zip`) from the repository releases section
|
||||
2. Extract the contained files in the `plugins/TubeArchivistMetadata` folder (you might need to create the folders) of your Jellyfin installation
|
||||
3. Restart Jellyfin to apply the changes
|
||||
|
||||
- [Download the Example Plugin Project](https://github.com/jellyfin/jellyfin-plugin-template/tree/master/Jellyfin.Plugin.Template) from this repository, open it in your IDE and go to [step 3](https://github.com/jellyfin/jellyfin-plugin-template#3-customize-plugin-information)
|
||||
## Configuration
|
||||
<p>This plugin requires that you have already an instance of TubeArchivist up and running.</p>
|
||||
Once installed, you have to configure the following parameters in the plugin configuration:
|
||||
<ul>
|
||||
<li>Collection display name</li>
|
||||
<li>TubeArchivist instance address</li>
|
||||
<li>TubeArchivist API key</li>
|
||||
<li>Overviews length (channels and videos descriptions)</li>
|
||||
</ul>
|
||||
|
||||
- Install our dotnet template by [downloading the dotnet-template/content folder from this repo](https://github.com/jellyfin/jellyfin-plugin-template/tree/master/dotnet-template/content) or off of Nuget (Coming soon)
|
||||

|
||||
|
||||
```
|
||||
dotnet new -i /path/to/templatefolder
|
||||
```
|
||||
|
||||
- Run this command then skip to step 4
|
||||
## Use the plugin
|
||||
<p>Using the plugin is very simple. Let's start from the beginning:</p>
|
||||
|
||||
```
|
||||
dotnet new Jellyfin-plugin -name MyPlugin
|
||||
```
|
||||
_NOTE: If you are using Docker containers, it is important to mount the TubeArchivist media path into Jellyfin container as **read-only**, in order to avoid possible operations on the media files that will break TubeArchivist._ <br>
|
||||
1. Go to `Dashboard -> Libraries` and add a media library
|
||||
2. In the form select `Shows` as Content type, set a display name for the library and set the TubeArchivist media folder in the `Folders` section
|
||||

|
||||
|
||||
If you'd rather start from scratch keep going on to step one. This assumes no specific editor or IDE and requires only the command line with dotnet in the path.
|
||||
4. Scrolling down, uncheck all metadata and image providers except `TubeArchivist`. (You won't find TubeArchivist in seasons providers, so just disable everything there)
|
||||
5. Save and come back to Home, you will see the newly added library. Jellyfin will have executed the metadata fetching for you after the collection creation and then you will see the metadata and the images of channels and videos
|
||||
|
||||
## 1. Initialize Your Project
|
||||
## Build
|
||||
|
||||
Make a new dotnet standard project with the following command, it will make a directory for itself.
|
||||
1. To build this plugin you will need [.Net 8.x](https://dotnet.microsoft.com/download/dotnet/8.0).
|
||||
|
||||
```
|
||||
dotnet new classlib -f net6.0 -n MyJellyfinPlugin
|
||||
```
|
||||
2. Build plugin with following command
|
||||
```
|
||||
$ dotnet publish Jellyfin.Plugin.TubeArchivistMetadata --configuration Release --output bin
|
||||
```
|
||||
|
||||
Now add the Jellyfin shared libraries.
|
||||
3. Place the dll-file in the `plugins/tubearchivist-jf-plugin` folder (you might need to create the folders) of your Jellyfin installation
|
||||
|
||||
```
|
||||
dotnet add package Jellyfin.Model
|
||||
dotnet add package Jellyfin.Controller
|
||||
```
|
||||
## License
|
||||
|
||||
You have an autogenerated Class1.cs file. You won't be needing this, so go ahead and delete it.
|
||||
|
||||
## 2. Set Up the Basics
|
||||
|
||||
There are a few mandatory classes you'll need for a plugin so we need to make them.
|
||||
|
||||
### PluginConfiguration
|
||||
|
||||
You can call it whatever you'd like really. This class is used to hold settings your plugin might need. We can leave it empty for now. This class should inherit from `MediaBrowser.Model.Plugins.BasePluginConfiguration`
|
||||
|
||||
### Plugin
|
||||
|
||||
This is the main class for your plugin. It will define your name, version and Id. It should inherit from `MediaBrowser.Common.Plugins.BasePlugin<PluginConfiguration>`
|
||||
|
||||
Note: If you called your PluginConfiguration class something different, you need to put that between the <>
|
||||
|
||||
### Implement Required Properties
|
||||
|
||||
The Plugin class needs a few properties implemented before it can work correctly.
|
||||
|
||||
It needs an override on ID, an override on Name, and a constructor that follows a specific model. To get started you can use the following section.
|
||||
|
||||
```c#
|
||||
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths, xmlSerializer){}
|
||||
public override string Name => throw new System.NotImplementedException();
|
||||
public override Guid Id => Guid.Parse("");
|
||||
```
|
||||
|
||||
## 3. Customize Plugin Information
|
||||
|
||||
You need to populate some of your plugin's information. Go ahead a put in a string of the Name you've overridden name, and generate a GUID
|
||||
|
||||
- **Windows Users**: you can use the Powershell command `New-Guid`, `[guid]::NewGuid()` or the Visual Studio GUID generator
|
||||
|
||||
- **Linux and OS X Users**: you can use the Powershell Core command `New-Guid` or this command from your shell of choice:
|
||||
|
||||
```bash
|
||||
od -x /dev/urandom | head -1 | awk '{OFS="-"; srand($6); sub(/./,"4",$5); sub(/./,substr("89ab",rand()*4,1),$6); print $2$3,$4,$5,$6,$7$8$9}'
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
uuidgen
|
||||
```
|
||||
|
||||
- Place that guid inside the `Guid.Parse("")` quotes to define your plugin's ID.
|
||||
|
||||
## 4. Adding Functionality
|
||||
|
||||
Congratulations, you now have everything you need for a perfectly functional functionless Jellyfin plugin! You can try it out right now if you'd like by compiling it, then placing the dll you generate in the plugins folder under your Jellyfin config directory. If you want to try and hook it up to a debugger make sure you copy the generated PDB file alongside it.
|
||||
|
||||
Most people aren't satisfied with just having an entry in a menu for their plugin, most people want to have some functionality, so lets look at how to add it.
|
||||
|
||||
### 4a. Implement Interfaces
|
||||
|
||||
If the functionality you are trying to add is functionality related to something that Jellyfin has an interface for you're in luck. Jellyfin uses some automatic discovery and injection to allow any interfaces you implement in your plugin to be available in Jellyfin.
|
||||
|
||||
Here's some interfaces you could implement for common use cases:
|
||||
|
||||
- **IAuthenticationProvider** - Allows you to add an authentication provider that can authenticate a user based on a name and a password, but that doesn't expect to deal with local users.
|
||||
- **IBaseItemComparer** - Allows you to add sorting rules for dealing with media that will show up in sort menus
|
||||
- **IIntroProvider** - Allows you to play a piece of media before another piece of media (i.e. a trailer before a movie, or a network bumper before an episode of a show)
|
||||
- **IItemResolver** - Allows you to define custom media types
|
||||
- **ILibraryPostScanTask** - Allows you to define a task that fires after scanning a library
|
||||
- **IMetadataSaver** - Allows you to define a metadata standard that Jellyfin can use to write metadata
|
||||
- **IResolverIgnoreRule** - Allows you to define subpaths that are ignored by media resolvers for use with another function (i.e. you wanted to have a theme song for each tv series stored in a subfolder that could be accessed by your plugin for playback in a menu).
|
||||
- **IScheduledTask** - Allows you to create a scheduled task that will appear in the scheduled task lists on the dashboard.
|
||||
|
||||
There are loads of other interfaces that can be used, but you'll need to poke around the API to get some info. If you're an expert on a particular interface, you should help [contribute some documentation](https://docs.jellyfin.org/general/contributing/index.html)!
|
||||
|
||||
### 4b. Use plugin aimed interfaces to add custom functionality
|
||||
|
||||
If your plugin doesn't fit perfectly neatly into a predefined interface, never fear, there are a set of interfaces and classes that allow your plugin to extend Jellyfin any which way you please. Here's a quick overview on how to use them
|
||||
|
||||
- **IPluginConfigurationPage** - Allows you to have a plugin config page on the dashboard. If you used one of the quickstart example projects, a premade page with some useful components to work with has been created for you! If not you can check out this guide here for how to whip one up.
|
||||
|
||||
- **IServerEntryPoint** - Allows you to run code at server startup that will stay in memory. You can make as many of these as you need and it is wildly useful for loading configs or persisting state. **Be aware that your main plugin class (IBasePlugin) cannot also be a IServerEntryPoint.**
|
||||
|
||||
- **ControllerBase** - Allows you to define custom REST-API endpoints. This is the default ASP.NET Web-API controller. You can use it exactly as you would in a normal Web-API project. Learn more about it [here](https://docs.microsoft.com/aspnet/core/web-api/?view=aspnetcore-5.0).
|
||||
|
||||
Likewise you might need to get data and services from the Jellyfin core, Jellyfin provides a number of interfaces you can add as parameters to your plugin constructor which are then made available in your project (you can see the 2 mandatory ones that are needed by the plugin system in the constructor as is).
|
||||
|
||||
- **IBlurayExaminer** - Allows you to examine blu-ray folders
|
||||
- **IDtoService** - Allows you to create data transport objects, presumably to send to other plugins or to the core
|
||||
- **ILibraryManager** - Allows you to directly access the media libraries without hopping through the API
|
||||
- **ILocalizationManager** - Allows you tap into the main localization engine which governs translations, rating systems, units etc...
|
||||
- **INetworkManager** - Allows you to get information about the server's networking status
|
||||
- **IServerApplicationPaths** - Allows you to get the running server's paths
|
||||
- **IServerConfigurationManager** - Allows you to write or read server configuration data into the application paths
|
||||
- **ITaskManager** - Allows you to execute and manipulate scheduled tasks
|
||||
- **IUserManager** - Allows you to retrieve user info and user library related info
|
||||
- **IXmlSerializer** - Allows you to use the main xml serializer
|
||||
- **IZipClient** - Allows you to use the core zip client for compressing and decompressing data
|
||||
|
||||
## 5. Create a Repository
|
||||
|
||||
- [See blog post](https://jellyfin.org/posts/plugin-updates/)
|
||||
|
||||
## 6. Set Up Debugging
|
||||
|
||||
Debugging can be set up by creating tasks which will be executed when running the plugin project. The specifics on setting up these tasks are not included as they may differ from IDE to IDE. The following list describes the general process:
|
||||
|
||||
- Compile the plugin in debug mode.
|
||||
- Create the plugin directory if it doesn't exist.
|
||||
- Copy the plugin into your server's plugin directory. The server will then execute it.
|
||||
- Make sure to set the working directory of the program being debugged to the working directory of the Jellyfin Server.
|
||||
- Start the server.
|
||||
|
||||
Some IDEs like Visual Studio Code may need the following compile flags to compile the plugin:
|
||||
|
||||
```shell
|
||||
dotnet build Your-Plugin.sln /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary
|
||||
```
|
||||
|
||||
These flags generate the full paths for file names and **do not** generate a summary during the build process as this may lead to duplicate errors in the problem panel of your IDE.
|
||||
|
||||
### 6.a Set Up Debugging on Visual Studio
|
||||
|
||||
Visual Studio allows developers to connect to other processes and debug them, setting breakpoints and inspecting the variables of the program. We can set this up following this steps:
|
||||
On this section we will explain how to set up our solution to enable debugging before the server starts.
|
||||
|
||||
1. Right-click on the solution, And click on Add -> Existing Project...
|
||||
2. Locate Jellyfin executable in your installation folder and click on 'Open'. It is called `Jellyfin.exe`. Now The solution will have a new "Project" called Jellyfin. This is the executable, not the source code of Jellyfin.
|
||||
3. Right-click on this new project and click on 'Set up as Startup Project'
|
||||
4. Right-click on this new project and click on 'Properties'
|
||||
5. Make sure that the 'Attach' parameter is set to 'No'
|
||||
|
||||
From now on, everytime you click on start from Visual Studio, it will start Jellyfin attached to the debugger!
|
||||
|
||||
The only thing left to do is to compile the project as it is specified a few lines above and you are done.
|
||||
|
||||
### 6.b Automate the Setup on Visual Studio Code
|
||||
|
||||
Visual Studio Code allows developers to automate the process of starting all necessary dependencies to start debugging the plugin. This guide assumes the reader is familiar with the [documentation on debugging in Visual Studio Code](https://code.visualstudio.com/docs/editor/debugging) and has read the documentation in this file. It is assumed that the Jellyfin Server has already been compiled once. However, should one desire to automatically compile the server before the start of the debugging session, this can be easily implemented, but is not further discussed here.
|
||||
|
||||
A full example, which aims to be portable may be found in this repo's `.vscode` folder.
|
||||
|
||||
This example expects you to clone `jellyfin`, `jellyfin-web` and `jellyfin-plugin-template` under the same parent directory, though you can customize this in `settings.json`
|
||||
|
||||
1. Create a `settings.json` file inside your `.vscode` folder, to specify common options specific to your local setup.
|
||||
```jsonc
|
||||
{
|
||||
// jellyfinDir : The directory of the cloned jellyfin server project
|
||||
// This needs to be built once before it can be used
|
||||
"jellyfinDir" : "${workspaceFolder}/../jellyfin/Jellyfin.Server",
|
||||
// jellyfinWebDir : The directory of the cloned jellyfin-web project
|
||||
// This needs to be built once before it can be used
|
||||
"jellyfinWebDir" : "${workspaceFolder}/../jellyfin-web",
|
||||
// jellyfinDataDir : the root data directory for a running jellyfin instance
|
||||
// This is where jellyfin stores its configs, plugins, metadata etc
|
||||
// This is platform specific by default, but on Windows defaults to
|
||||
// ${env:LOCALAPPDATA}/jellyfin
|
||||
"jellyfinDataDir" : "${env:LOCALAPPDATA}/jellyfin",
|
||||
// The name of the plugin
|
||||
"pluginName" : "Jellyfin.Plugin.Template",
|
||||
}
|
||||
```
|
||||
|
||||
1. To automate the launch process, create a new `launch.json` file for C# projects inside the `.vscode` folder. The example below shows only the relevant parts of the file. Adjustments to your specific setup and operating system may be required.
|
||||
|
||||
```jsonc
|
||||
{
|
||||
// Paths and plugin names are configured in settings.json
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "coreclr",
|
||||
"name": "Launch",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build-and-copy",
|
||||
"program": "${config:jellyfinDir}/bin/Debug/net6.0/jellyfin.dll",
|
||||
"args": [
|
||||
//"--nowebclient"
|
||||
"--webdir",
|
||||
"${config:jellyfinWebDir}/dist/"
|
||||
],
|
||||
"cwd": "${config:jellyfinDir}",
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
The `request` type is specified as `launch`, as this `launch.json` file will start the Jellyfin Server process. The `preLaunchTask` defines a task that will run before the Jellyfin Server starts. More on this later. It is important to set the `program` path to the Jellyin Server program and set the current working directory (`cwd`) to the working directory of the Jellyfin Server.
|
||||
The `args` option allows to specify arguments to be passed to the server, e.g. whether Jellyfin should start with the web-client or without it.
|
||||
|
||||
2. Create a `tasks.json` file inside your `.vscode` folder and specify a `build-and-copy` task that will run in `sequence` order. This tasks depends on multiple other tasks and all of those other tasks can be defined as simple `shell` tasks that run commands like the `cp` command to copy a file. The sequence to run those tasks in is given below. Please note that it might be necessary to adjust the examples for your specific setup and operating system.
|
||||
|
||||
The full file is shown here - Specific sections will be discussed in depth
|
||||
```jsonc
|
||||
{
|
||||
// Paths and plugin name are configured in settings.json
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
// A chain task - build the plugin, then copy it to your
|
||||
// jellyfin server's plugin directory
|
||||
"label": "build-and-copy",
|
||||
"dependsOrder": "sequence",
|
||||
"dependsOn": ["build", "make-plugin-dir", "copy-dll"]
|
||||
},
|
||||
{
|
||||
// Build the plugin
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "shell",
|
||||
"args": [
|
||||
"publish",
|
||||
"${workspaceFolder}/${config:pluginName}.sln",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"reveal": "silent"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
// Ensure the plugin directory exists before trying to use it
|
||||
"label": "make-plugin-dir",
|
||||
"type": "shell",
|
||||
"command": "mkdir",
|
||||
"args": [
|
||||
"-Force",
|
||||
"-Path",
|
||||
"${config:jellyfinDataDir}/plugins/${config:pluginName}/"
|
||||
]
|
||||
},
|
||||
{
|
||||
// Copy the plugin dll to the jellyfin plugin install path
|
||||
// This command copies every .dll from the build directory to the plugin dir
|
||||
// Usually, you probablly only need ${config:pluginName}.dll
|
||||
// But some plugins may bundle extra requirements
|
||||
"label": "copy-dll",
|
||||
"type": "shell",
|
||||
"command": "cp",
|
||||
"args": [
|
||||
"./${config:pluginName}/bin/Debug/net6.0/publish/*",
|
||||
"${config:jellyfinDataDir}/plugins/${config:pluginName}/"
|
||||
]
|
||||
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
```
|
||||
1. The "build-and-copy" task which triggers all of the other tasks
|
||||
```jsonc
|
||||
{
|
||||
// A chain task - build the plugin, then copy it to your
|
||||
// jellyfin server's plugin directory
|
||||
"label": "build-and-copy",
|
||||
"dependsOrder": "sequence",
|
||||
"dependsOn": ["build", "make-plugin-dir", "copy-dll"]
|
||||
},
|
||||
```
|
||||
2. A build task. This task builds the plugin without generating summary, but with full paths for file names enabled.
|
||||
|
||||
```jsonc
|
||||
{
|
||||
// Build the plugin
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "shell",
|
||||
"args": [
|
||||
"publish",
|
||||
"${workspaceFolder}/${config:pluginName}.sln",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"reveal": "silent"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
```
|
||||
|
||||
3. A tasks which creates the necessary plugin directory and a sub-folder for the specific plugin. The plugin directory is located below the [data directory](https://jellyfin.org/docs/general/administration/configuration.html) of the Jellyfin Server. As an example, the following path can be used for the bookshelf plugin: `$HOME/.local/share/jellyfin/plugins/Bookshelf/`
|
||||
```jsonc
|
||||
{
|
||||
// Ensure the plugin directory exists before trying to use it
|
||||
"label": "make-plugin-dir",
|
||||
"type": "shell",
|
||||
"command": "mkdir",
|
||||
"args": [
|
||||
"-Force",
|
||||
"-Path",
|
||||
"${config:jellyfinDataDir}/plugins/${config:pluginName}/"
|
||||
]
|
||||
},
|
||||
```
|
||||
|
||||
4. A tasks which copies the plugin dll which has been built in step 2.1. The file is copied into it's specific plugin directory within the server's plugin directory.
|
||||
|
||||
```jsonc
|
||||
{
|
||||
// Copy the plugin dll to the jellyfin plugin install path
|
||||
// This command copies every .dll from the build directory to the plugin dir
|
||||
// Usually, you probablly only need ${config:pluginName}.dll
|
||||
// But some plugins may bundle extra requirements
|
||||
"label": "copy-dll",
|
||||
"type": "shell",
|
||||
"command": "cp",
|
||||
"args": [
|
||||
"./${config:pluginName}/bin/Debug/net6.0/publish/*",
|
||||
"${config:jellyfinDataDir}/plugins/${config:pluginName}/"
|
||||
]
|
||||
},
|
||||
```
|
||||
|
||||
## Licensing
|
||||
|
||||
Licensing is a complex topic. This repository features a GPLv3 license template that can be used to provide a good default license for your plugin. You may alter this if you like, but if you do a permissive license must be chosen.
|
||||
|
||||
Due to how plugins in Jellyfin work, when your plugin is compiled into a binary, it will link against the various Jellyfin binary NuGet packages. These packages are licensed under the GPLv3. Thus, due to the nature and restrictions of the GPL, the binary plugin you get will also be licensed under the GPLv3.
|
||||
|
||||
If you accept the default GPLv3 license from this template, all will be good. However if you choose a different license, please keep this fact in mind, as it might not always be obvious that an, e.g. MIT-licensed plugin would become GPLv3 when compiled.
|
||||
|
||||
Please note that this also means making "proprietary", source-unavailable, or otherwise "hidden" plugins for public consumption is not permitted. To build a Jellyfin plugin for distribution to others, it must be under the GPLv3 or a permissive open-source license that can be linked against the GPLv3.
|
||||
This plugins code and packages are distributed under the GPLv3 License. See [LICENSE](./LICENSE) for more information.
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.Plugin.TubeArchivistMetadata", "Jellyfin.Plugin.TubeArchivistMetadata\Jellyfin.Plugin.TubeArchivistMetadata.csproj", "{7A112ACB-79E8-4FC9-BCF6-B3AC849DA2D4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7A112ACB-79E8-4FC9-BCF6-B3AC849DA2D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7A112ACB-79E8-4FC9-BCF6-B3AC849DA2D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7A112ACB-79E8-4FC9-BCF6-B3AC849DA2D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7A112ACB-79E8-4FC9-BCF6-B3AC849DA2D4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
+5
-4
@@ -1,9 +1,10 @@
|
||||
---
|
||||
name: "TubeArchivistMetadata"
|
||||
guid: "dc97d0c6-28b0-4242-afb4-5833ae1b3715"
|
||||
version: "1.0.0.0"
|
||||
targetAbi: "10.8.0.0"
|
||||
framework: "net6.0"
|
||||
imageUrl: https://raw.githubusercontent.com/tubearchivist/tubearchivist-jf-plugin/master/images/logo.png
|
||||
version: "1.3.0.0"
|
||||
targetAbi: "10.9.1.0"
|
||||
framework: "net8.0"
|
||||
overview: "Metadata for your TubeArchivist library on Jellyfin"
|
||||
description: >
|
||||
TubeArchivistMetadata is a plugin that automatically manages
|
||||
@@ -13,4 +14,4 @@ owner: "DarkFighterLuke"
|
||||
artifacts:
|
||||
- "Jellyfin.Plugin.TubeArchivistMetadata.dll"
|
||||
changelog: >
|
||||
First release
|
||||
Add support for Jellyfin 10.9.1
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 65 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 289 KiB |
+81
-8
@@ -3,18 +3,91 @@
|
||||
"category": "Metadata",
|
||||
"guid": "dc97d0c6-28b0-4242-afb4-5833ae1b3715",
|
||||
"name": "TubeArchivistMetadata",
|
||||
"description": "A new and fully integrated way to manage metadata and organize your TubeArchivist library videos on Jellyfin.",
|
||||
"description": "TubeArchivistMetadata is a plugin that automatically manages metadata for videos downloaded with TubeArchivist from YouTube.\n",
|
||||
"owner": "DarkFighterLuke",
|
||||
"overview": "Metadata for your TubeArchivist library on Jellyfin.",
|
||||
"overview": "Metadata for your TubeArchivist library on Jellyfin",
|
||||
"imageUrl": "https://raw.githubusercontent.com/tubearchivist/tubearchivist-jf-plugin/master/images/logo.png",
|
||||
"versions": [
|
||||
{
|
||||
"checksum": "07c81d5b5359b018ca251646d81910f5",
|
||||
"changelog": "First release",
|
||||
"version": "1.3.0.0",
|
||||
"changelog": "Add support for Jellyfin 10.9.1\n",
|
||||
"targetAbi": "10.9.1.0",
|
||||
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.3.0/tubearchivistmetadata_1.3.0.0.zip",
|
||||
"checksum": "e1fde6f75a10a5f17bc9cc5814949180",
|
||||
"timestamp": "2024-05-14T20:20:13Z"
|
||||
},
|
||||
{
|
||||
"version": "1.2.5.0",
|
||||
"changelog": "Ping the TA API to validate connection\n",
|
||||
"targetAbi": "10.8.0.0",
|
||||
"sourceUrl": "https://github.com/DarkFighterLuke/TubeArchivistMetadata/releases/download/v1.0.1/TubeArchivistMetadata-1.0.0.zip",
|
||||
"timestamp": "2024-03-11 16:02:00",
|
||||
"version": "1.0.0.0"
|
||||
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.2.5/tubearchivistmetadata_1.2.5.0.zip",
|
||||
"checksum": "e4a0d076ffd84c976ad66dde91dfb840",
|
||||
"timestamp": "2024-05-14T17:37:17Z"
|
||||
},
|
||||
{
|
||||
"version": "1.2.4.0",
|
||||
"changelog": "Fix issues with directory separators\n",
|
||||
"targetAbi": "10.8.0.0",
|
||||
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.2.4/tubearchivistmetadata_1.2.4.0.zip",
|
||||
"checksum": "b418a46d458fe28354580d70748b1ced",
|
||||
"timestamp": "2024-05-09 15:41:00"
|
||||
},
|
||||
{
|
||||
"version": "1.2.3.0",
|
||||
"changelog": "Add fix for unclosed HTML breaks\n",
|
||||
"targetAbi": "10.8.0.0",
|
||||
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.2.3/tubearchivistmetadata_1.2.3.0.zip",
|
||||
"checksum": "f5328a662444739eaa7c59855bfcb203",
|
||||
"timestamp": "2024-04-18 21:45:00"
|
||||
},
|
||||
{
|
||||
"version": "1.2.2.0",
|
||||
"changelog": "Fix bug on description length substringing\n",
|
||||
"targetAbi": "10.8.0.0",
|
||||
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.2.2/tubearchivistmetadata_1.2.2.0.zip",
|
||||
"checksum": "82d04546916e1ba76d56de28e648447a",
|
||||
"timestamp": "2024-03-15 10:12:00"
|
||||
},
|
||||
{
|
||||
"version": "1.2.1.0",
|
||||
"changelog": "Make maximum description length configurable\nTruncate descriptions to 500 characters\n",
|
||||
"targetAbi": "10.8.0.0",
|
||||
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.2.1/tubearchivistmetadata_1.2.1.0.zip",
|
||||
"checksum": "cf68d169956f166a6ee68a06192651c2",
|
||||
"timestamp": "2024-03-14 21:50:00"
|
||||
},
|
||||
{
|
||||
"version": "1.2.0.0",
|
||||
"changelog": "Add episodes and series overview\n",
|
||||
"targetAbi": "10.8.0.0",
|
||||
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.2.0/tubearchivistmetadata_1.2.0.0.zip",
|
||||
"checksum": "75812a4464bf68c43fb9dcdb74d924e3",
|
||||
"timestamp": "2024-03-14 20:00:00"
|
||||
},
|
||||
{
|
||||
"version": "1.1.1.0",
|
||||
"changelog": "Handle empty tags for videos and channels\nFix URL by removing trailing slash for images\n",
|
||||
"targetAbi": "10.8.0.0",
|
||||
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.1.1/tubearchivistmetadata_1.1.1.0.zip",
|
||||
"checksum": "84ce752ce662e834690512c88ba48664",
|
||||
"timestamp": "2024-03-14 16:35:00"
|
||||
},
|
||||
{
|
||||
"version": "1.1.0.0",
|
||||
"changelog": "Fix field name and add placeholders\nFix URL in logs after redirection\nAdd schema to TubeArchivist URL if not present in settings\nFix a particular case\nLog configuration settings at initialization\nSanitize URLs\n",
|
||||
"targetAbi": "10.8.0.0",
|
||||
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.1.0/tubearchivistmetadata_1.1.0.0.zip",
|
||||
"checksum": "de4b6562973b7f75b6afe3a441bb0e19",
|
||||
"timestamp": "2024-03-13 15:02:00"
|
||||
},
|
||||
{
|
||||
"version": "1.0.0.0",
|
||||
"changelog": "First release\n",
|
||||
"targetAbi": "10.8.0.0",
|
||||
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.0.0/tubearchivistmetadata_1.0.0.0.zip",
|
||||
"checksum": "444f8980671de494b1875ee7d1657bcf",
|
||||
"timestamp": "2024-03-11 16:02:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
Reference in New Issue
Block a user