Compare commits

...

51 Commits

Author SHA1 Message Date
REPLYNET\l.consoli d49fd4e1a1 Update version and changelog 2025-12-02 14:39:55 +01:00
DarkFighterLuke 13553ef1c6 Merge pull request #77 from DerSeegler/master
Add error handling to SetProgress calls
2025-12-02 14:37:59 +01:00
DarkFighterLuke ac2e4dac9c Merge branch 'master' into master 2025-12-02 14:37:51 +01:00
REPLYNET\l.consoli 0bbb3c36cd Add Playlist ToString method 2025-12-02 14:27:19 +01:00
REPLYNET\l.consoli db0d9b115c Update version 2025-12-02 12:37:15 +01:00
REPLYNET\l.consoli bc343dd0c8 Edit SanitizeUrl to handle also query parameters
modified:   Jellyfin.Plugin.TubeArchivistMetadata/Tasks/TAToJellyfinPlaylistsSyncTask.cs
	modified:   Jellyfin.Plugin.TubeArchivistMetadata/TubeArchivist/TubeArchivistApi.cs
	modified:   Jellyfin.Plugin.TubeArchivistMetadata/Utils/Utils.cs
2025-12-02 12:31:44 +01:00
Yannik S. 9ed4869ece Add error handling to SetProgress calls 2025-11-28 23:59:02 +01:00
REPLYNET\l.consoli c2eebbe1a9 Handle TA playlists pagination 2025-11-18 15:52:13 +01:00
DarkFighterLuke e198b0fb92 Update manifest.json
Signed-off-by: DarkFighterLuke <DarkFighterLuke@users.noreply.github.com>
2025-11-13 19:31:52 +00:00
DarkFighterLuke f6f6bbf978 Merge pull request #73 from Jurrer/fix-on-watched-status-changed
fix condition for onWatchedStatusChanged
2025-11-13 20:27:36 +01:00
DarkFighterLuke 75c2fce017 Merge branch 'master' into fix-on-watched-status-changed 2025-11-13 20:27:29 +01:00
DarkFighterLuke 3c08e3c70c Merge pull request #72 from Jurrer/check-TA-video-status-before-syncing-to-TA
Check TA watched status before syncing to TA
2025-11-13 20:27:09 +01:00
DarkFighterLuke d5c706b833 Merge branch 'master' into check-TA-video-status-before-syncing-to-TA 2025-11-13 20:26:59 +01:00
DarkFighterLuke ad4fb92577 Merge pull request #71 from Jurrer/fix-watch-status-sync-to-TA-itemdata
fix video watch status sync to TA IsPlayed method
2025-11-13 20:26:44 +01:00
DarkFighterLuke 8aec7f804d Merge branch 'master' into fix-watch-status-sync-to-TA-itemdata 2025-11-13 20:26:29 +01:00
Jurrer 4c3de5146b collection name + user name check to OnWatchedStatusChange 2025-11-13 00:55:18 +01:00
Jurrer 1ce6587078 fix condition for onWatchedStatusChanged 2025-11-10 00:39:47 +01:00
Jurrer 7942e89341 check TA video status before syncing to TA 2025-11-09 05:33:05 +01:00
Jurrer 764dc8f326 fix video watch status sync to TA IsPlayed method 2025-11-09 03:17:39 +01:00
DarkFighterLuke af8a02d289 Update manifest.json
Signed-off-by: DarkFighterLuke <DarkFighterLuke@users.noreply.github.com>
2025-10-23 20:27:36 +00:00
DarkFighterLuke 9d745b0bc5 Use string.Empty 2025-10-23 22:26:39 +02:00
DarkFighterLuke a8e0896284 Bump version 2025-10-23 22:24:00 +02:00
DarkFighterLuke 53d9a17c2a Merge pull request #51 from wolffshots/master
Episodes by YYYYMMDD and some other cleanup
2025-10-23 22:21:19 +02:00
DarkFighterLuke 0c8bc243c6 Update Utils.cs 2025-10-23 22:19:22 +02:00
wolffshots 03ea6b9e5c chore: move episode naming to general options 2025-10-23 15:38:18 +02:00
wolffshots 6c9a824546 chore: merge remote-tracking branch 'parent/master' 2025-10-23 15:22:50 +02:00
DarkFighterLuke 5dc99e2fcf Update tasks intervals section in README
Added note about resource consumption with lower intervals.
2025-10-22 17:28:39 +02:00
DarkFighterLuke 478537bf0a Revise synchronization and add playlists features
Updated synchronization sections and added playlists synchronization details.
2025-10-22 17:13:02 +02:00
wolffshots 184c53ba00 chore: remove missed template entrie 2025-10-22 11:47:13 +02:00
wolffshots 70f063d33b Merge pull request #4 from wolffshots/jellyfin-10.11-merge
Merge commits from the upstream project to get the plugin working properly on Jellyfin 10.11
2025-10-22 11:43:22 +02:00
wolffshots 60753cb828 chore: merge upstream master and fix conflicts 2025-10-22 11:35:12 +02:00
DarkFighterLuke cba12adaa4 Update manifest.json
Signed-off-by: DarkFighterLuke <DarkFighterLuke@users.noreply.github.com>
2025-10-22 07:00:32 +00:00
DarkFighterLuke d94fd1bac3 Update manifest.json
Signed-off-by: DarkFighterLuke <DarkFighterLuke@users.noreply.github.com>
2025-10-22 06:57:57 +00:00
DarkFighterLuke dfdfac6be7 Update manifest.json
Signed-off-by: DarkFighterLuke <DarkFighterLuke@users.noreply.github.com>
2025-10-21 21:54:14 +00:00
wolffshots cf87c6e829 Merge branch 'master' into master 2025-08-05 12:16:38 +02:00
wolffshots d7f4f5cbcc chore: explicitly handle null description 2025-08-05 10:37:54 +02:00
wolffshots 6e8b9ca744 doc: update README.md to reflect numbering options 2025-08-04 21:18:57 +02:00
wolffshots b0ca3a49a5 chore: catch errors on FormatDescription 2025-08-04 18:46:30 +02:00
wolffshots 4358072001 feat: add configuration for episode numbering scheme 2025-08-04 18:21:30 +02:00
DarkFighterLuke 38ed5dd9e0 Merge branch 'master' into master 2025-07-13 15:42:09 +02:00
DarkFighterLuke ff55b9f517 Update Plugin.cs 2025-07-13 14:49:41 +02:00
DarkFighterLuke 93a2de5d46 Merge branch 'master' into master 2025-07-13 13:26:17 +02:00
DarkFighterLuke 5b62e4c001 Update JFToTubeArchivistProgressSyncTask.cs 2025-07-13 13:22:18 +02:00
wolffshots 3e95ca26aa chore: make sync task logs debugs 2025-05-29 11:23:44 +02:00
wolffshots a58139eca0 chore: remove duplicated efforts 2025-05-29 11:19:27 +02:00
wolffshots 5ab5224328 chore: ran dotnet format on Plugin.cs 2025-05-29 11:00:44 +02:00
wolffshots d36d677179 chore: remove unused import 2025-05-29 10:57:02 +02:00
wolffshots 784592b362 chore: remove debugging log statements 2025-05-29 10:52:07 +02:00
jadon 2f90d6a03e chore: remove extra season and move into if 2025-05-28 23:32:06 +02:00
jadon af375987ee chore: check library before updating watch status 2025-05-28 23:29:33 +02:00
jadon ee683d5737 feat: set e# and logging 2025-05-28 23:25:17 +02:00
17 changed files with 398 additions and 52 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<Version>1.4.1.0</Version>
<AssemblyVersion>1.4.1.0</AssemblyVersion>
<FileVersion>1.4.1.0</FileVersion>
<Version>1.4.4.0</Version>
<AssemblyVersion>1.4.4.0</AssemblyVersion>
<FileVersion>1.4.4.0</FileVersion>
</PropertyGroup>
</Project>
@@ -0,0 +1,17 @@
namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration;
/// <summary>
/// The NumberingScheme.
/// </summary>
public enum NumberingScheme
{
/// <summary>
/// Default (no numbering).
/// </summary>
Default,
/// <summary>
/// YYYYMMDD (e.g. 20250804 for August 4th, 2025).
/// </summary>
YYYYMMDD,
}
@@ -186,6 +186,11 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
/// </summary>
public int TAJFPlaylistsSyncTaskInterval { get; set; }
/// <summary>
/// Gets or sets the preferred numbering scheme for episodes (index number) in Jellyfin.
/// </summary>
public NumberingScheme EpisodeNumberingScheme { get; set; } = NumberingScheme.Default;
/// <summary>
/// Gets the playback progress owners Jellyfin usernames to synchronize data from TubeArchivist.
/// </summary>
@@ -41,6 +41,18 @@
<div class="fieldDescription">This is the maximum length of the descriptions showed in series
and episodes</div>
</div>
<div class="selectContainer">
<label class="selectLabel" for="EpisodeNumberingScheme">Episode numbering scheme</label>
<select is="emby-select" id="EpisodeNumberingScheme" name="EpisodeNumberingScheme" label="Description markup" class="emby-select-withcolor emby-select">
<option value="Default">Default (no specified numbering)</option>
<option value="YYYYMMDD">YYYYMMDD (e.g. 20250804 for August 4th, 2025)</option>
</select>
<div class="selectArrowContainer">
<span class="selectArrow material-icons keyboard_arrow_down" aria-hidden="true"></span>
</div>
<div class="fieldDescription">This is the numbering scheme for episodes in Jellyfin (IndexNumber).
Default is the same as no numbering which allows Jellyfin to use the fallback numbering scheme.
</div>
<div>
<h2>Synchronization</h2>
</div>
@@ -160,6 +172,7 @@
document.querySelector('#JFTAPlaylistsSync').checked = config.JFTAPlaylistsSync;
document.querySelector('#TAJFPlaylistsSync').checked = config.TAJFPlaylistsSync;
document.querySelector('#JFUsernameFrom').value = config.JFUsernameFrom;
document.querySelector('#EpisodeNumberingScheme').value = config.EpisodeNumberingScheme;
document.querySelector('#TAJFProgressTaskInterval').value = config.TAJFProgressTaskInterval;
document.querySelector('#JFTAPlaylistsSyncTaskInterval').value = config.JFTAPlaylistsSyncTaskInterval;
document.querySelector('#TAJFPlaylistsSyncTaskInterval').value = config.TAJFPlaylistsSyncTaskInterval;
@@ -181,6 +194,7 @@
config.JFTAPlaylistsSync = document.querySelector('#JFTAPlaylistsSync').checked;
config.TAJFPlaylistsSync = document.querySelector('#TAJFPlaylistsSync').checked;
config.JFUsernameFrom = document.querySelector('#JFUsernameFrom').value;
config.EpisodeNumberingScheme = document.querySelector('#EpisodeNumberingScheme').value;
config.TAJFProgressTaskInterval = document.querySelector('#TAJFProgressTaskInterval').value;
config.JFTAPlaylistsSyncTaskInterval = document.querySelector('#JFTAPlaylistsSyncTaskInterval').value;
config.TAJFPlaylistsSyncTaskInterval = document.querySelector('#TAJFPlaylistsSyncTaskInterval').value;
+27 -10
View File
@@ -162,21 +162,28 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
return;
}
if (Instance!.Configuration.JFTAProgressSync && eventArgs.Users.Any(u => Instance!.Configuration.JFUsernameFrom.Equals(u.Username, StringComparison.Ordinal)))
var topParent = eventArgs.Item.GetTopParent();
if (
Instance!.Configuration.JFTAProgressSync &&
eventArgs.Users.Any(u => Instance!.Configuration.JFUsernameFrom.Equals(u.Username, StringComparison.Ordinal)) &&
eventArgs.PlaybackPositionTicks.HasValue &&
string.Equals(topParent?.Name, Instance?.Configuration.CollectionTitle, StringComparison.OrdinalIgnoreCase)
)
{
BaseItem? season = LibraryManager.GetItemById(eventArgs.Item.ParentId);
BaseItem? channel = LibraryManager.GetItemById(season!.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);
try
{
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.LogCritical("{Message}", $"POST /video/{videoId}/progress returned {statusCode} for video {eventArgs.Item.Name} with progress {progress} seconds");
}
}
catch (Exception ex)
{
Logger.LogCritical("An exception occurred while calling POST /video/{VideoId}/progress for for video {VideoName} with progress {Progress} seconds: {ExceptionMessage}", videoId, eventArgs.Item.Name, progress, ex.Message);
}
}
}
@@ -188,16 +195,26 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
return;
}
var topParent = eventArgs.Item.GetTopParent();
var user = _userManager.GetUserById(eventArgs.UserId);
if (user == null)
if (
Configuration.JFTAProgressSync
&& user == null
&& string.Equals(topParent?.Name, Instance?.Configuration.CollectionTitle, StringComparison.OrdinalIgnoreCase)
)
{
Logger.LogError("OnWatchedStatusChange callback called without user id for item {ItemName}", eventArgs.Item.Name);
return;
}
var userItemData = _userDataManager.GetUserData(user, eventArgs.Item);
if (Configuration.JFTAProgressSync && user != null && Configuration.GetJFUsernamesToArray().Contains(user!.Username))
if (
Configuration.JFTAProgressSync
&& user != null
&& string.Equals(Configuration.JFUsernameFrom, user!.Username, StringComparison.Ordinal)
&& string.Equals(topParent?.Name, Instance?.Configuration.CollectionTitle, StringComparison.OrdinalIgnoreCase)
)
{
var userItemData = _userDataManager.GetUserData(user, eventArgs.Item);
var isPlayed = eventArgs.Item.IsPlayed(user, userItemData);
Logger.LogDebug("User {UserId} changed watched status to {Status} for the item {ItemName}", eventArgs.UserId, isPlayed, eventArgs.Item.Name);
string itemYTId;
@@ -67,6 +67,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
});
result.HasMetadata = true;
result.Item = video.ToEpisode();
result.Item.Path = info.Path;
result.Provider = Name;
result.People = peopleInfo;
}
@@ -153,13 +153,13 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Tasks
foreach (Episode video in videos)
{
var videoYTId = Utils.GetVideoNameFromPath(video.Path);
_logger.LogDebug("{VideoYtId}", videoYTId);
_logger.LogDebug("Current video extracted YouTube id: {VideoYtId}", videoYTId);
HttpStatusCode statusCode;
var userItemData = _userDataManager.GetUserData(user, channel);
var channelItemData = _userDataManager.GetUserData(user, channel);
if (!isChannelCheckedForWatched && channel.IsPlayed(user, userItemData))
if (!isChannelCheckedForWatched && channel.IsPlayed(user, channelItemData))
{
var isChannelPlayed = channel.IsPlayed(user, userItemData);
var isChannelPlayed = channel.IsPlayed(user, channelItemData);
statusCode = await taApi.SetWatchedStatus(channelYTId, isChannelPlayed).ConfigureAwait(true);
if (statusCode != System.Net.HttpStatusCode.OK)
{
@@ -173,13 +173,26 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Tasks
isChannelCheckedForWatched = true;
}
var videoItemData = _userDataManager.GetUserData(user, video);
if (!isChannelWatched)
{
var isVideoPlayed = video.IsPlayed(user, userItemData);
statusCode = await taApi.SetWatchedStatus(videoYTId, isVideoPlayed).ConfigureAwait(true);
if (statusCode != System.Net.HttpStatusCode.OK)
var isVideoPlayed = video.IsPlayed(user, videoItemData);
var taVideo = await taApi.GetVideo(videoYTId).ConfigureAwait(true);
if (taVideo != null)
{
_logger.LogCritical("{Message}", $"POST /watched returned {statusCode} for video {video.Name} ({videoYTId}) with wacthed status {isVideoPlayed}");
var isTAVideoPlayed = taVideo?.Player.IsWatched ?? false;
if (isTAVideoPlayed != isVideoPlayed)
{
statusCode = await taApi.SetWatchedStatus(videoYTId, isVideoPlayed).ConfigureAwait(true);
if (statusCode != System.Net.HttpStatusCode.OK)
{
_logger.LogCritical("{Message}", $"POST /watched returned {statusCode} for video {video.Name} ({videoYTId}) with wacthed status {isVideoPlayed}");
}
else
{
_logger.LogInformation("Video {VideoId} watch status marked as {Status} in TubeArchivist", videoYTId, isVideoPlayed);
}
}
}
_logger.LogDebug("{Message}", isVideoPlayed);
@@ -188,10 +201,17 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Tasks
var playbackProgress = _userDataManager.GetUserData(user, video)?.PlaybackPositionTicks / TimeSpan.TicksPerSecond;
if (playbackProgress != null)
{
statusCode = await taApi.SetProgress(videoYTId, playbackProgress.Value).ConfigureAwait(true);
if (statusCode != System.Net.HttpStatusCode.OK)
try
{
_logger.LogCritical("{Message}", $"POST /video/{videoYTId}/progress returned {statusCode} for video {video.Name} with progress {progress} seconds");
statusCode = await taApi.SetProgress(videoYTId, playbackProgress.Value).ConfigureAwait(true);
if (statusCode != System.Net.HttpStatusCode.OK)
{
_logger.LogCritical("{Message}", $"POST /video/{videoYTId}/progress returned {statusCode} for video {video.Name} with progress {progress} seconds");
}
}
catch (Exception ex)
{
_logger.LogCritical("An exception occurred while calling POST /video/{VideoId}/progress for for video {VideoName} with progress {Progress} seconds: {ExceptionMessage}", videoYTId, videoYTId, playbackProgress.Value, ex.Message);
}
}
}
@@ -170,7 +170,15 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Tasks
}
processedVideosCount += currentPlaylistVideos;
progress.Report(processedVideosCount * 100 / totalVideosCount);
if (totalVideosCount == 0)
{
progress.Report(100);
}
else
{
progress.Report(processedVideosCount * 100 / totalVideosCount);
}
}
}
}
@@ -0,0 +1,99 @@
using System.Collections.ObjectModel;
using Newtonsoft.Json;
namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
{
/// <summary>
/// A class representing pagination information from the TubeArchivist API.
/// </summary>
public class PaginationInfo
{
/// <summary>
/// Initializes a new instance of the <see cref="PaginationInfo"/> class.
/// </summary>
/// <param name="pageSize">The size of the page.</param>
/// <param name="pageFrom">The starting page number.</param>
/// <param name="prevPages">The collection of previous page numbers.</param>
/// <param name="currentPage">The current page number.</param>
/// <param name="maxHits">A value indicating whether the max hits have been reached.</param>
/// <param name="parameters">The parameters used for pagination.</param>
/// <param name="lastPage">The last page number.</param>
/// <param name="nextPages">The collection of next page numbers.</param>
/// <param name="totalHits">The total number of hits.</param>
public PaginationInfo(
int pageSize,
int pageFrom,
Collection<int> prevPages,
int currentPage,
bool maxHits,
string parameters,
int lastPage,
Collection<int> nextPages,
int totalHits)
{
this.PageSize = pageSize;
this.PageFrom = pageFrom;
this.PrevPages = prevPages;
this.CurrentPage = currentPage;
this.MaxHits = maxHits;
this.Parameters = parameters;
this.LastPage = lastPage;
this.NextPages = nextPages;
this.TotalHits = totalHits;
}
/// <summary>
/// Gets the page size.
/// </summary>
[JsonProperty(PropertyName = "page_size")]
public int PageSize { get; }
/// <summary>
/// Gets the page from.
/// </summary>
[JsonProperty(PropertyName = "page_from")]
public int PageFrom { get; }
/// <summary>
/// Gets the previous pages.
/// </summary>
[JsonProperty(PropertyName = "prev_pages")]
public Collection<int> PrevPages { get; }
/// <summary>
/// Gets the current page.
/// </summary>
[JsonProperty(PropertyName = "current_page")]
public int CurrentPage { get; }
/// <summary>
/// Gets a value indicating whether the max hits have been reached.
/// </summary>
[JsonProperty(PropertyName = "max_hits")]
public bool MaxHits { get; }
/// <summary>
/// Gets the parameters.
/// </summary>
[JsonProperty(PropertyName = "params")]
public string Parameters { get; }
/// <summary>
/// Gets the last page.
/// </summary>
[JsonProperty(PropertyName = "last_page")]
public int LastPage { get; }
/// <summary>
/// Gets the next pages.
/// </summary>
[JsonProperty(PropertyName = "next_pages")]
public Collection<int> NextPages { get; }
/// <summary>
/// Gets the total hits.
/// </summary>
[JsonProperty(PropertyName = "total_hits")]
public int TotalHits { get; }
}
}
@@ -112,5 +112,16 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
/// <value>One of the <see cref="PlaylistType"/> values indicating the playlist's type.</value>
[JsonProperty(PropertyName = "playlist_type")]
public PlaylistType Type { get; set; }
/// <summary>
/// Returns a string of the playlist's key fields for logging.
/// </summary>
/// <returns>A string containing the playlist id, name, and entries count.</returns>
public override string ToString()
{
return "PlaylistId: " + this.Id +
", Name: " + this.Name +
", EntriesCount: " + this.Entries.Count;
}
}
}
@@ -10,5 +10,10 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
/// Gets or sets the contained data object.
/// </summary>
public T? Data { get; set; }
/// <summary>
/// Gets or sets the pagination info object.
/// </summary>
public PaginationInfo? Paginate { get; set; }
}
}
@@ -219,7 +219,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
{
url = response.Headers.Location;
_logger.LogInformation("{Message}", "Received redirect to: " + url);
response = await client.GetAsync(url).ConfigureAwait(true);
response = await client.GetAsync(Utils.SanitizeUrl(Plugin.Instance?.Configuration.TubeArchivistUrl + url)).ConfigureAwait(true);
}
_logger.LogInformation("{Message}", url + ": " + response.StatusCode);
@@ -228,6 +228,50 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
{
string rawData = await response.Content.ReadAsStringAsync().ConfigureAwait(true);
playlists = JsonConvert.DeserializeObject<ResponseContainer<ISet<Playlist>?>>(rawData);
if (playlists?.Paginate != null)
{
var lastPage = playlists.Paginate.LastPage;
_logger.LogInformation("Pagination info: Current page {CurrentPage} / Last page {LastPage}, Total hits: {TotalHits}", playlists.Paginate.CurrentPage, playlists.Paginate.LastPage, playlists.Paginate.TotalHits);
while (playlists.Paginate.CurrentPage < lastPage)
{
var nextPage = playlists.Paginate.CurrentPage + 1;
var pagedUrl = new Uri(Utils.SanitizeUrl(Plugin.Instance?.Configuration.TubeArchivistUrl + playlistsEndpoint + "?page=" + nextPage));
response = await client.GetAsync(pagedUrl).ConfigureAwait(true);
while (response.StatusCode == HttpStatusCode.Moved)
{
url = response.Headers.Location;
_logger.LogInformation("{Message}", "Received redirect to: " + url);
response = await client.GetAsync(Utils.SanitizeUrl(Plugin.Instance?.Configuration.TubeArchivistUrl + url)).ConfigureAwait(true);
}
_logger.LogInformation("{Message}", pagedUrl + ": " + response.StatusCode);
if (response.IsSuccessStatusCode)
{
rawData = await response.Content.ReadAsStringAsync().ConfigureAwait(true);
var nextPagePlaylists = JsonConvert.DeserializeObject<ResponseContainer<ISet<Playlist>?>>(rawData);
if (nextPagePlaylists?.Data != null)
{
foreach (var playlist in nextPagePlaylists.Data)
{
playlists.Data?.Add(playlist);
}
}
if (nextPagePlaylists?.Paginate != null)
{
playlists.Paginate = nextPagePlaylists.Paginate;
_logger.LogInformation("Pagination info: Current page {CurrentPage} / Last page {LastPage}, Total hits: {TotalHits}", playlists.Paginate.CurrentPage, playlists.Paginate.LastPage, playlists.Paginate.TotalHits);
}
}
else
{
_logger.LogCritical("Failed to retrieve page {PageNumber} of playlists during pagination.", nextPage);
break;
}
}
}
}
return playlists?.Data;
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using Jellyfin.Plugin.TubeArchivistMetadata.Configuration;
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
@@ -126,6 +127,11 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
Overview = Utils.FormatDescription(Description),
SeasonName = Published.Year.ToString(CultureInfo.CurrentCulture),
ParentIndexNumber = Published.Year,
IndexNumber = Plugin.Instance?.Configuration?.EpisodeNumberingScheme switch
{
NumberingScheme.YYYYMMDD => (Published.Year * 10000) + (Published.Month * 100) + Published.Day,
_ => null
},
SeriesName = Channel.Name,
ProductionYear = Published.Year,
PremiereDate = Published,
@@ -1,4 +1,4 @@
using System.IO;
using System;
using System.Linq;
using System.Text.RegularExpressions;
@@ -20,20 +20,59 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Utilities
/// <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?://)");
if (string.IsNullOrWhiteSpace(inputUrl))
{
return string.Empty;
}
// Remove double slashes and spaces from the remaining part of the URL
string cleanedPath = Regex.Replace(inputUrl.Substring(schemaMatch.Length), @"[/\s]+", "/");
// Extract the schema part (http:// or https://)
Match schemaMatch = Regex.Match(inputUrl, @"^(?<schema>https?://)", RegexOptions.IgnoreCase);
// If no schema found, treat whole string as the rest
int schemaLength = schemaMatch.Success ? schemaMatch.Length : 0;
// Separate the main part from query (?) and fragment (#)
string rest = inputUrl.Substring(schemaLength);
string pathPart = rest;
string queryAndFragment = string.Empty;
int qIndex = rest.IndexOf('?', StringComparison.Ordinal);
int fIndex = rest.IndexOf('#', StringComparison.Ordinal);
int splitIndex = -1;
if (qIndex >= 0 && fIndex >= 0)
{
splitIndex = Math.Min(qIndex, fIndex);
}
else if (qIndex >= 0)
{
splitIndex = qIndex;
}
else if (fIndex >= 0)
{
splitIndex = fIndex;
}
if (splitIndex >= 0)
{
pathPart = rest.Substring(0, splitIndex);
queryAndFragment = rest.Substring(splitIndex);
}
// Remove double slashes and spaces from the path part
string cleanedPath = Regex.Replace(pathPart, @"[/\s]+", "/");
// Remove slashes at the start
cleanedPath = cleanedPath.TrimStart('/');
// Add a trailing slash if not already present
cleanedPath = cleanedPath.TrimEnd('/') + "/";
// Add a trailing slash only when there are no query or fragment parts
if (string.IsNullOrEmpty(queryAndFragment))
{
cleanedPath = cleanedPath.TrimEnd('/') + "/";
}
// Combine the schema and cleaned path
string cleanedUrl = schemaMatch.Groups["schema"].Value + cleanedPath;
// Combine the schema and cleaned path and re-append query/fragment
string cleanedUrl = (schemaMatch.Success ? schemaMatch.Groups["schema"].Value : string.Empty) + cleanedPath + queryAndFragment;
return cleanedUrl;
}
@@ -45,6 +84,11 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Utilities
/// <returns>A string with \n replaced by br tags.</returns>
public static string FormatDescription(string description)
{
if (description == null)
{
return string.Empty;
}
var maxLength = 500;
if (Plugin.Instance != null)
{
@@ -54,9 +98,10 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Utilities
if (description.Length > maxLength)
{
description = description.Substring(0, maxLength);
description = description.Replace("\n", "<br>", System.StringComparison.CurrentCulture);
}
description = description.Replace("\n", "<br>", System.StringComparison.CurrentCulture);
return description;
}
+40 -11
View File
@@ -77,24 +77,53 @@ _NOTE: If you are using Docker containers, it is important to mount the TubeArch
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
## Playback synchronization
<p>Starting from v1.3.1 this plugin offers playback progress and watched status bidirectional synchronization, but you can choose to enable only a one way synchronization (Jellyfin->TubeArchivist or TubeArchivist->Jellyfin) too.</p>
## Synchronization
This plugin has different bidirectional sycnhronization features, that can be configured in the specific section in the plugin configuration page:
![Synchronization settings](https://github.com/user-attachments/assets/b0bb556b-fce3-4a3e-bc6c-b0a2b482cedc)
### Jellyfin->TubeArchivist synchronization
### Playback synchronization
<p>Starting from v1.3.1 this plugin offers playback progress and watched status bidirectional synchronization, but you can choose to enable only a one way synchronization (Jellyfin -> TubeArchivist or TubeArchivist -> Jellyfin) too.</p>
#### Jellyfin -> TubeArchivist playback synchronization
<p>This kind of synchronization is done listening for progress and watched status changes while playing the videos for the specified users.<br>Furthermore, there is a task that runs at Jellyfin startup to synchronize the whole library.</p>
<p>In the plugin configuration you will find these settings:</p>
![JF->TA playback synchronization settings](https://github.com/user-attachments/assets/dc6be82f-e685-4896-a502-317681c47fc7)
<p>In the text field you can specify one Jellyfin username to synchronize data of to TubeArchivist.</p>
### TubeArchivist->Jellyfin synchronization
#### TubeArchivist -> Jellyfin playback synchronization
<p>This kind of synchronization is done using a Jellyfin scheduled task that regularly synchronizes data from TubeArchivist API to Jellyfin.</p>
<p>In the plugin configuration you will find these settings:</p>
<p>In the text field you can specify one or more Jellyfin usernames to update data for.</p>
![TA->JF playback synchronization settings](https://github.com/user-attachments/assets/1b4c33af-834f-45b3-9057-71830e7c8b4f)
<p>In the first text field you can specify one or more Jellyfin usernames to update data for.<br>
In the second field you can specify the interval in seconds the task should run at, so that you can choose according to your system requirements. The lower is the interval the higher will be the resources consuption on your system.</p>
### Playlists synchronization
<p>Starting from v.1.4.1 this plugin offers playlists bidirectional synchronization, but you can choose to enable only a one way synchronization (Jellyfin -> TubeArchivist or TubeArchivist -> Jellyfin) too.</p>
#### Jellyfin -> TubeArchivist playlists synchronization
<p>There is a task that retrieves playlists and recreates them on TubeArchivist with the videos in the same order. Please note that playlists can also have videos not beloging from TubeArchivist, they will be simply ignored, so you won't find them on TubeArchivist playlist.</p>
<p>It is present also a setting to automatically delete playlists from TubeArchivist when they are no more available on Jellyfin.</p>
#### TubeArchivist -> Jellyfin playlists synchronization
<p>There is a task that retrieves playlists from TubeArchivist and recreates them on Jellyfin with videos in the same order.</p>
<p>It is present, also in this case, a setting to automatically delete playlists from Jellyfin when they are no more present on TubeArchivist, but beware that the will be deleted also if they contain videos not beloning to TubeArchivist.</p>
> [!CAUTION]
> Pay attention when you enable the automatic deletion options, be sure that is your wanted behavior, especially when playlists contain also other videos not belonging from TubeArchivist, playlists removed won't be available again, there's no undo!
## Tasks intervals
<p>Since many of the feature are implemented as background tasks periodically executing, in the `Tasks intervals` section you will find the settings to adjust this period in seconds.<br>
Keep in mind that Jellyfin lowest accepted period is of 1 minute (60 seconds) and the lower is the interval the higher will be the resources consuption on your system.</p>
<p>Here are the configurable intervals:</p>
![Tasks intervals settings](https://github.com/user-attachments/assets/19db6b83-6715-477d-8ce7-b78526e87ba9)
## Episode numbering
<p>There are different ways to number the episodes as they are configured in Jellyfin.<br>
This changes the number after E in S--E-- (for example S2024E100 for episode number 100 of season 2024).</p>
![Episode numbering scheme options](https://github.com/user-attachments/assets/6d36bc2c-ca9d-4a5c-8021-e15d399316fc)
The options correlate with:
- Default - leave the numbering to what Jellyfin does by default (this is what the plugin has always done)
- YYYYMMDD - numbers the episode by the year, month, day (e.g. 20250804 for a video published on the 4th of August 2025)
## Build
+3 -2
View File
@@ -2,7 +2,7 @@
name: "TubeArchivistMetadata"
guid: "dc97d0c6-28b0-4242-afb4-5833ae1b3715"
imageUrl: https://raw.githubusercontent.com/tubearchivist/tubearchivist-jf-plugin/master/images/logo.png
version: "1.4.1.0"
version: "1.4.4.0"
targetAbi: "10.11.0.0"
framework: "net9.0"
overview: "Metadata for your TubeArchivist library on Jellyfin"
@@ -14,4 +14,5 @@ owner: "DarkFighterLuke"
artifacts:
- "Jellyfin.Plugin.TubeArchivistMetadata.dll"
changelog: >
Introduce bidirectional playlists synchronization
Handle TubeArchivist playlists pagination
Handle prematurely ended response errors
+27 -3
View File
@@ -8,13 +8,37 @@
"overview": "Metadata for your TubeArchivist library on Jellyfin",
"imageUrl": "https://raw.githubusercontent.com/tubearchivist/tubearchivist-jf-plugin/master/images/logo.png",
"versions": [
{
"version": "1.4.3.0",
"changelog": "Introduce episode numbering alternative schema\n",
"targetAbi": "10.11.0.0",
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.4.3/tubearchivistmetadata_1.4.3.0.zip",
"checksum": "297d4f15af1132939f43c905b1ad393e",
"timestamp": "2025-11-13T19:31:49Z"
},
{
"version": "1.4.2.0",
"changelog": "Introduce episode numbering alternative schema\n",
"targetAbi": "10.11.0.0",
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.4.2/tubearchivistmetadata_1.4.2.0.zip",
"checksum": "8df142d2f1f0c0dffa302a567b40ef84",
"timestamp": "2025-10-23T20:27:32Z"
},
{
"version": "1.4.1.0",
"changelog": "Introduce bidirectional playlists synchronization\n",
"targetAbi": "10.11.0.0",
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.4.1/tubearchivistmetadata_1.4.1.0.zip",
"checksum": "2dc0b9140472a4f783f093a7ee425493",
"timestamp": "2025-10-22T07:00:27Z"
},
{
"version": "1.4.0.0",
"changelog": "Align compatibility with Jellyfin 10.11.x\n",
"changelog": "Introduce bidirectional playlists synchronization\n",
"targetAbi": "10.11.0.0",
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.4.0/tubearchivistmetadata_1.4.0.0.zip",
"checksum": "7afb9abd4361ee991c1b3eae2a8d4cec",
"timestamp": "2025-10-21T21:34:51Z"
"checksum": "4b81ab60022b532a64bb5eeb7be67dcc",
"timestamp": "2025-10-22T06:57:53Z"
},
{
"version": "1.3.7.0",