20 Commits
Author SHA1 Message Date
dtourolleandClaude Opus 5 c67005bd8f Add Jellyfin 12.0 build target alongside 10.9
🏗️ Build Plugin / build (push) Successful in 2m9s
🚀 Release Plugin / build-and-release (push) Successful in 1m33s
The plugin now multi-targets net8.0 (Jellyfin 10.9, ABI 10.9.0.0) and net10.0
(Jellyfin 12.0, ABI 12.0.0.0) from one source tree, and each release ships both
packages.

TaskTriggerInfo.Type became a TaskTriggerInfoType enum in 12.0, which is the
only source-level break; it is handled with a NET10_0_OR_GREATER switch. CA1873
is disabled in the ruleset alongside CA1848, which it supersedes.

build.yaml stays the 10.9 config and the 12.0 one is derived from it at build
time, so the two cannot drift apart. Both manifest entries are prepended per
release with the 12.0 one first: Jellyfin keeps entries whose targetAbi is <=
the server version and takes the first of the highest version, so a 12.0 server
picks the 12.0 build while a 10.9 server never sees it.

The builder image now carries the .NET 10 SDK with the .NET 8 SDK alongside it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 18:51:45 +02:00
Gitea Actions 361028574e Update manifest.json for version 1.0.10 2026-01-11 09:06:37 +00:00
dtourolle c81845c338 remove un-need test workflow
🏗️ Build Plugin / build (push) Successful in 1m33s
🚀 Release Plugin / build-and-release (push) Successful in 1m38s
2026-01-11 10:03:25 +01:00
Gitea Actions 0348cb3d09 Update manifest.json for version 1.0.9 2026-01-11 09:02:21 +00:00
dtourolle a3ba704882 ymf
🧪 Test Plugin / test (push) Failing after 3m8s
🏗️ Build Plugin / build (push) Successful in 44s
🚀 Release Plugin / build-and-release (push) Successful in 1m38s
2026-01-11 09:56:44 +01:00
dtourolle 77bbc87a1a ymf
🏗️ Build Plugin / build (push) Successful in 39s
🧪 Test Plugin / test (push) Successful in 1m5s
🚀 Release Plugin / build-and-release (push) Failing after 45s
2026-01-11 09:52:11 +01:00
dtourolle d4842c2361 fixing new build system
🏗️ Build Plugin / build (push) Successful in 48s
🧪 Test Plugin / test (push) Successful in 1m4s
🚀 Release Plugin / build-and-release (push) Failing after 46s
2026-01-11 09:43:51 +01:00
dtourolle 67619a4f56 impoving build system
🏗️ Build Plugin / build (push) Successful in 57s
🧪 Test Plugin / test (push) Successful in 1m12s
🚀 Release Plugin / build-and-release (push) Failing after 39s
2026-01-11 09:40:18 +01:00
dtourolle cdf53c5288 Add docker to simplify build
🧪 Test Plugin / test (push) Successful in 1m10s
🏗️ Build Plugin / build (push) Failing after 20m0s
🚀 Release Plugin / build-and-release (push) Failing after 2m46s
2026-01-10 21:01:28 +01:00
Gitea Actions 6be05158d0 Update manifest.json for version 1.0.4 2026-01-10 18:48:09 +00:00
dtourolle 4f3af0db69 clean up CI job
🧪 Test Plugin / test (push) Successful in 1m2s
🚀 Release Plugin / build-and-release (push) Successful in 2m6s
🏗️ Build Plugin / build (push) Successful in 1m59s
2026-01-10 19:43:41 +01:00
dtourolle 76714eb0c6 erge branch 'master' of gitea.tourolle.paris:dtourolle/jellypod
🧪 Test Plugin / test (push) Successful in 1m2s
🚀 Release Plugin / build-and-release (push) Failing after 1m6s
🏗️ Build Plugin / build (push) Failing after 1m11s
2026-01-09 21:55:10 +01:00
dtourolle f48aa86256 cache podcast images and use them on homepage 2026-01-09 21:54:48 +01:00
Gitea Actions 5a908cbe4d Update manifest.json for version 1.0.2 2025-12-30 15:25:33 +00:00
dtourolle d890c11a9b Add a retention timer for podcast
🏗️ Build Plugin / build (push) Successful in 2m1s
🧪 Test Plugin / test (push) Successful in 1m0s
🚀 Release Plugin / build-and-release (push) Successful in 2m1s
2025-12-30 16:20:26 +01:00
dtourolle c54221fba2 Fix bug where stale cache causes media player to mix up episode names
🏗️ Build Plugin / build (push) Successful in 2m2s
🧪 Test Plugin / test (push) Successful in 58s
2025-12-30 15:53:31 +01:00
Gitea Actions 221a3f634d Update manifest.json for version 1.0.1 2025-12-21 13:07:43 +00:00
dtourolle 9ac32e11b5 Added a post-download hook for applying processing of downloaded audio before adding to library.
🏗️ Build Plugin / build (push) Successful in 2m4s
🧪 Test Plugin / test (push) Successful in 58s
🚀 Release Plugin / build-and-release (push) Successful in 2m1s
2025-12-21 13:59:42 +01:00
Gitea Actions bc24b40bf2 Update manifest.json for version 1.0.0 2025-12-20 13:00:27 +00:00
dtourolle 4537613ed7 Added manifest and pipelines to allow install via web ui.
🏗️ Build Plugin / build (push) Successful in 2m10s
🧪 Test Plugin / test (push) Successful in 1m0s
🚀 Release Plugin / build-and-release (push) Successful in 2m2s
2025-12-20 13:55:06 +01:00
21 changed files with 1034 additions and 132 deletions
+41 -20
View File
@@ -15,15 +15,14 @@ on:
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
container:
image: gitea.tourolle.paris/dtourolle/jellypod-builder:latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Verify .NET installation
run: dotnet --version
- name: Restore dependencies
run: dotnet restore Jellyfin.Plugin.Jellypod.sln
@@ -33,29 +32,51 @@ jobs:
- name: Run tests
run: dotnet test Jellyfin.Plugin.Jellypod.sln --no-build --configuration Release --verbosity normal
- name: Install JPRM
- name: Build plugin for Jellyfin 10.9 (net8.0)
id: jprm_jf109
run: |
python3 -m venv /tmp/jprm-venv
/tmp/jprm-venv/bin/pip install jprm
mkdir -p ./artifacts/jf10.9
jprm --verbosity=debug plugin build . --output ./artifacts/jf10.9
- name: Build Jellyfin Plugin
id: jprm
ARTIFACT=$(find ./artifacts/jf10.9 -name "*.zip" -type f -print -quit)
RENAMED="./artifacts/jf10.9/$(basename "${ARTIFACT}" .zip)_jf10.9.zip"
mv "${ARTIFACT}" "${RENAMED}"
echo "artifact=${RENAMED}" >> $GITHUB_OUTPUT
echo "Found artifact: ${RENAMED}"
- name: Retarget build config at Jellyfin 12.0 (net10.0)
run: |
# Create artifacts directory for JPRM output
mkdir -p artifacts
sed -i \
-e 's/^targetAbi:.*/targetAbi: "12.0.0.0"/' \
-e 's/^framework:.*/framework: "net10.0"/' \
-e 's/^dotnet_framework:.*/dotnet_framework: "net10.0"/' \
build.yaml
cat build.yaml
# Build plugin using JPRM
/tmp/jprm-venv/bin/jprm --verbosity=debug plugin build .
- name: Build plugin for Jellyfin 12.0 (net10.0)
id: jprm_jf12
run: |
mkdir -p ./artifacts/jf12
jprm --verbosity=debug plugin build . --output ./artifacts/jf12
# Find the generated zip file
ARTIFACT=$(find . -name "*.zip" -type f -print -quit)
echo "artifact=${ARTIFACT}" >> $GITHUB_OUTPUT
echo "Found artifact: ${ARTIFACT}"
ARTIFACT=$(find ./artifacts/jf12 -name "*.zip" -type f -print -quit)
RENAMED="./artifacts/jf12/$(basename "${ARTIFACT}" .zip)_jf12.zip"
mv "${ARTIFACT}" "${RENAMED}"
echo "artifact=${RENAMED}" >> $GITHUB_OUTPUT
echo "Found artifact: ${RENAMED}"
- name: Upload build artifact
- name: Upload build artifact (Jellyfin 10.9)
uses: actions/upload-artifact@v3
with:
name: jellypod-plugin
path: ${{ steps.jprm.outputs.artifact }}
name: jellypod-plugin-jf10.9
path: ${{ steps.jprm_jf109.outputs.artifact }}
retention-days: 30
if-no-files-found: error
- name: Upload build artifact (Jellyfin 12.0)
uses: actions/upload-artifact@v3
with:
name: jellypod-plugin-jf12
path: ${{ steps.jprm_jf12.outputs.artifact }}
retention-days: 30
if-no-files-found: error
+101 -42
View File
@@ -13,15 +13,14 @@ on:
jobs:
build-and-release:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
container:
image: gitea.tourolle.paris/dtourolle/jellypod-builder:latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Verify .NET installation
run: dotnet --version
- name: Get version
id: get_version
run: |
@@ -40,6 +39,17 @@ jobs:
sed -i "s/^version:.*/version: \"${VERSION}\"/" build.yaml
cat build.yaml
- name: Generate Jellyfin 12.0 build config
run: |
# build.yaml is the Jellyfin 10.9 (net8.0) config; derive the
# Jellyfin 12.0 (net10.0) one from it so the two cannot drift apart.
sed \
-e 's/^targetAbi:.*/targetAbi: "12.0.0.0"/' \
-e 's/^framework:.*/framework: "net10.0"/' \
-e 's/^dotnet_framework:.*/dotnet_framework: "net10.0"/' \
build.yaml > build.jf12.yaml
cat build.jf12.yaml
- name: Restore dependencies
run: dotnet restore Jellyfin.Plugin.Jellypod.sln
@@ -49,28 +59,42 @@ jobs:
- name: Run tests
run: dotnet test Jellyfin.Plugin.Jellypod.sln --no-build --configuration Release --verbosity normal
- name: Install JPRM
- name: Build plugin for Jellyfin 10.9 (net8.0)
id: jprm_jf109
run: |
python3 -m venv /tmp/jprm-venv
/tmp/jprm-venv/bin/pip install jprm
mkdir -p ./artifacts/jf10.9
jprm --verbosity=debug plugin build . --output ./artifacts/jf10.9
- name: Build Jellyfin Plugin
id: jprm
ARTIFACT=$(find ./artifacts/jf10.9 -name "*.zip" -type f -print -quit)
RENAMED="./artifacts/jf10.9/$(basename "${ARTIFACT}" .zip)_jf10.9.zip"
mv "${ARTIFACT}" "${RENAMED}"
echo "artifact=${RENAMED}" >> $GITHUB_OUTPUT
echo "artifact_name=$(basename "${RENAMED}")" >> $GITHUB_OUTPUT
echo "checksum=$(md5sum "${RENAMED}" | awk '{print $1}')" >> $GITHUB_OUTPUT
echo "Found artifact: ${RENAMED}"
- name: Build plugin for Jellyfin 12.0 (net10.0)
id: jprm_jf12
run: |
# Create artifacts directory for JPRM output
mkdir -p artifacts
# jprm always reads build.yaml, so swap the 12.0 config in for this build.
cp build.yaml build.jf10.9.yaml
cp build.jf12.yaml build.yaml
# Build plugin using JPRM
/tmp/jprm-venv/bin/jprm --verbosity=debug plugin build ./
mkdir -p ./artifacts/jf12
jprm --verbosity=debug plugin build . --output ./artifacts/jf12
# Find the generated zip file
ARTIFACT=$(find . -name "*.zip" -type f -print -quit)
ARTIFACT_NAME=$(basename "${ARTIFACT}")
echo "artifact=${ARTIFACT}" >> $GITHUB_OUTPUT
echo "artifact_name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT
echo "Found artifact: ${ARTIFACT}"
mv build.jf10.9.yaml build.yaml
ARTIFACT=$(find ./artifacts/jf12 -name "*.zip" -type f -print -quit)
RENAMED="./artifacts/jf12/$(basename "${ARTIFACT}" .zip)_jf12.zip"
mv "${ARTIFACT}" "${RENAMED}"
echo "artifact=${RENAMED}" >> $GITHUB_OUTPUT
echo "artifact_name=$(basename "${RENAMED}")" >> $GITHUB_OUTPUT
echo "checksum=$(md5sum "${RENAMED}" | awk '{print $1}')" >> $GITHUB_OUTPUT
echo "Found artifact: ${RENAMED}"
- name: Create Release
id: create_release
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
@@ -79,28 +103,20 @@ jobs:
REPO_NAME="${{ github.event.repository.name }}"
GITEA_URL="${{ github.server_url }}"
# Prepare release body
RELEASE_BODY="Jellypod Jellyfin Plugin ${{ steps.get_version.outputs.version }}\n\nSee attached files for plugin installation."
RELEASE_BODY_JSON=$(echo -n "${RELEASE_BODY}" | jq -Rs .)
# Create release using Gitea API
VERSION="${{ steps.get_version.outputs.version }}"
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
"${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases" \
-d "{
\"tag_name\": \"${{ steps.get_version.outputs.version }}\",
\"name\": \"Release ${{ steps.get_version.outputs.version }}\",
\"body\": ${RELEASE_BODY_JSON},
\"draft\": false,
\"prerelease\": false
}")
-d "$(jq -n --arg tag "$VERSION" --arg name "Release $VERSION" --arg body "Jellypod Jellyfin Plugin. Install the _jf10.9 build on Jellyfin 10.9.x and the _jf12 build on Jellyfin 12.0 or newer." '{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}')")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d')
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
RELEASE_ID=$(echo "$BODY" | jq -r '.id')
echo "release_id=${RELEASE_ID}" >> $GITHUB_OUTPUT
echo "Created release with ID: ${RELEASE_ID}"
else
echo "Failed to create release. HTTP ${HTTP_CODE}"
@@ -108,21 +124,64 @@ jobs:
exit 1
fi
# Upload plugin artifact
echo "Uploading plugin artifact..."
upload_asset() {
echo "Uploading $2 ..."
curl -f -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/zip" \
--data-binary "@${{ steps.jprm.outputs.artifact }}" \
"${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases/${RELEASE_ID}/assets?name=${{ steps.jprm.outputs.artifact_name }}"
-H "Content-Type: $3" \
--data-binary "@$1" \
"${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases/${RELEASE_ID}/assets?name=$2"
}
# Upload build.yaml
echo "Uploading build.yaml..."
curl -f -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/x-yaml" \
--data-binary "@build.yaml" \
"${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases/${RELEASE_ID}/assets?name=build.yaml"
upload_asset "${{ steps.jprm_jf109.outputs.artifact }}" "${{ steps.jprm_jf109.outputs.artifact_name }}" "application/zip"
upload_asset "${{ steps.jprm_jf12.outputs.artifact }}" "${{ steps.jprm_jf12.outputs.artifact_name }}" "application/zip"
upload_asset build.yaml build.yaml "application/x-yaml"
upload_asset build.jf12.yaml build.jf12.yaml "application/x-yaml"
echo "Release created successfully!"
echo "View at: ${GITEA_URL}/${REPO_OWNER}/${REPO_NAME}/releases/tag/${{ steps.get_version.outputs.version }}"
- name: Update manifest.json
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
REPO_OWNER="${{ github.repository_owner }}"
REPO_NAME="${{ github.event.repository.name }}"
GITEA_URL="${{ github.server_url }}"
VERSION="${{ steps.get_version.outputs.version_number }}"
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
RELEASE_URL="${GITEA_URL}/${REPO_OWNER}/${REPO_NAME}/releases/download/${{ steps.get_version.outputs.version }}"
# Configure git
git config user.name "Gitea Actions"
git config user.email "actions@gitea.tourolle.paris"
# Fetch and checkout master branch
git fetch origin master
git checkout master
# Prepend both ABI entries for this version. Jellyfin keeps only the
# entries whose targetAbi is <= the server version and then takes the
# first of the highest version, so the 12.0 entry must come first: a
# 12.0 server sees both and picks it, a 10.9 server never sees it.
jq --arg ver "${VERSION}" \
--arg changelog "Release ${VERSION}" \
--arg abi12 "12.0.0.0" \
--arg url12 "${RELEASE_URL}/${{ steps.jprm_jf12.outputs.artifact_name }}" \
--arg checksum12 "${{ steps.jprm_jf12.outputs.checksum }}" \
--arg abi109 "10.9.0.0" \
--arg url109 "${RELEASE_URL}/${{ steps.jprm_jf109.outputs.artifact_name }}" \
--arg checksum109 "${{ steps.jprm_jf109.outputs.checksum }}" \
--arg ts "${TIMESTAMP}" \
'.[0].versions = [
{version: $ver, changelog: $changelog, targetAbi: $abi12, sourceUrl: $url12, checksum: $checksum12, timestamp: $ts},
{version: $ver, changelog: $changelog, targetAbi: $abi109, sourceUrl: $url109, checksum: $checksum109, timestamp: $ts}
] + .[0].versions' \
manifest.json > manifest.tmp && mv manifest.tmp manifest.json
# Commit and push
git add manifest.json
git commit -m "Update manifest.json for version ${VERSION}"
git push origin master
echo "Manifest updated successfully!"
-44
View File
@@ -1,44 +0,0 @@
name: '🧪 Test Plugin'
on:
push:
branches:
- master
- develop
paths-ignore:
- '**/*.md'
pull_request:
branches:
- master
- develop
paths-ignore:
- '**/*.md'
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Verify .NET installation
run: dotnet --version
- name: Restore dependencies
run: dotnet restore Jellyfin.Plugin.Jellypod.sln
- name: Build solution
run: dotnet build Jellyfin.Plugin.Jellypod.sln --configuration Debug --no-restore --no-self-contained
- name: Run tests
run: dotnet test Jellyfin.Plugin.Jellypod.sln --no-build --configuration Debug --verbosity normal --logger "trx;LogFileName=test-results.trx"
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results
path: '**/test-results.trx'
retention-days: 7
+1
View File
@@ -3,3 +3,4 @@ obj/
.vs/
.idea/
artifacts
build.jf12.yaml
+22
View File
@@ -0,0 +1,22 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0
# Install Python, Node.js, and tools
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
jq \
git \
nodejs \
npm \
&& rm -rf /var/lib/apt/lists/*
# The .NET 10 SDK builds the net10.0 (Jellyfin 12.0) target; the .NET 8 SDK is
# needed alongside it for the net8.0 (Jellyfin 10.9) target.
RUN curl -sSL https://dot.net/v1/dotnet-install.sh -o /tmp/dotnet-install.sh \
&& bash /tmp/dotnet-install.sh --channel 8.0 --install-dir /usr/share/dotnet --no-path \
&& rm /tmp/dotnet-install.sh
# Install JPRM
RUN pip install --break-system-packages jprm
WORKDIR /src
@@ -0,0 +1,189 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Plugin.Jellypod.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace Jellyfin.Plugin.Jellypod.Api;
/// <summary>
/// Controller for serving podcast and episode images.
/// </summary>
[ApiController]
[Route("Jellypod/Image")]
public class ImageController : ControllerBase
{
private readonly ILogger<ImageController> _logger;
private readonly IPodcastStorageService _storageService;
private readonly IHttpClientFactory _httpClientFactory;
/// <summary>
/// Initializes a new instance of the <see cref="ImageController"/> class.
/// </summary>
/// <param name="logger">Logger instance.</param>
/// <param name="storageService">Storage service instance.</param>
/// <param name="httpClientFactory">HTTP client factory.</param>
public ImageController(
ILogger<ImageController> logger,
IPodcastStorageService storageService,
IHttpClientFactory httpClientFactory)
{
_logger = logger;
_storageService = storageService;
_httpClientFactory = httpClientFactory;
}
/// <summary>
/// Gets the image for a podcast.
/// </summary>
/// <param name="podcastId">The podcast ID.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>The image file.</returns>
[HttpGet("podcast/{podcastId}")]
[AllowAnonymous]
[SuppressMessage("Microsoft.Security", "CA3003:ReviewCodeForFilePathInjectionVulnerabilities", Justification = "Path is constructed from validated GUID and sanitized podcast title")]
public async Task<IActionResult> GetPodcastImage(
[FromRoute] Guid podcastId,
CancellationToken cancellationToken)
{
try
{
var podcast = await _storageService.GetPodcastAsync(podcastId).ConfigureAwait(false);
if (podcast == null)
{
return NotFound("Podcast not found");
}
// Try to serve local cached image first
var config = Plugin.Instance?.Configuration;
if (config?.CreatePodcastFolders == true)
{
var basePath = _storageService.GetStoragePath();
var podcastFolder = Path.Combine(basePath, SanitizeFileName(podcast.Title));
var artworkPath = Path.Combine(podcastFolder, "folder.jpg");
if (System.IO.File.Exists(artworkPath))
{
var fileStream = System.IO.File.OpenRead(artworkPath);
return File(fileStream, "image/jpeg");
}
}
// Fall back to proxying the external URL
if (!string.IsNullOrEmpty(podcast.ImageUrl))
{
return await ProxyImageAsync(podcast.ImageUrl, cancellationToken).ConfigureAwait(false);
}
return NotFound("No image available");
}
catch (Exception ex)
{
_logger.LogError(ex, "Error serving podcast image for {PodcastId}", podcastId);
return StatusCode(500, "Failed to serve podcast image");
}
}
/// <summary>
/// Gets the image for an episode.
/// </summary>
/// <param name="podcastId">The podcast ID.</param>
/// <param name="episodeId">The episode ID.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>The image file.</returns>
[HttpGet("episode/{podcastId}/{episodeId}")]
[AllowAnonymous]
[SuppressMessage("Microsoft.Security", "CA3003:ReviewCodeForFilePathInjectionVulnerabilities", Justification = "Path is constructed from validated GUIDs and sanitized podcast title")]
public async Task<IActionResult> GetEpisodeImage(
[FromRoute] Guid podcastId,
[FromRoute] Guid episodeId,
CancellationToken cancellationToken)
{
try
{
var podcast = await _storageService.GetPodcastAsync(podcastId).ConfigureAwait(false);
if (podcast == null)
{
return NotFound("Podcast not found");
}
var episode = podcast.Episodes.FirstOrDefault(e => e.Id == episodeId);
if (episode == null)
{
return NotFound("Episode not found");
}
// Try to serve local cached episode image first
var config = Plugin.Instance?.Configuration;
if (config?.CreatePodcastFolders == true)
{
var basePath = _storageService.GetStoragePath();
var podcastFolder = Path.Combine(basePath, SanitizeFileName(podcast.Title));
var episodeFileName = $"{SanitizeFileName(episode.Id.ToString())}.jpg";
var artworkPath = Path.Combine(podcastFolder, episodeFileName);
if (System.IO.File.Exists(artworkPath))
{
var fileStream = System.IO.File.OpenRead(artworkPath);
return File(fileStream, "image/jpeg");
}
}
// Fall back to episode ImageUrl if available
if (!string.IsNullOrEmpty(episode.ImageUrl))
{
return await ProxyImageAsync(episode.ImageUrl, cancellationToken).ConfigureAwait(false);
}
// Final fallback to podcast image
if (!string.IsNullOrEmpty(podcast.ImageUrl))
{
return await ProxyImageAsync(podcast.ImageUrl, cancellationToken).ConfigureAwait(false);
}
return NotFound("No image available");
}
catch (Exception ex)
{
_logger.LogError(ex, "Error serving episode image for {EpisodeId}", episodeId);
return StatusCode(500, "Failed to serve episode image");
}
}
private async Task<IActionResult> ProxyImageAsync(string imageUrl, CancellationToken cancellationToken)
{
try
{
var client = _httpClientFactory.CreateClient("Jellypod");
var response = await client.GetAsync(imageUrl, cancellationToken).ConfigureAwait(false);
if (!response.IsSuccessStatusCode)
{
_logger.LogWarning("Failed to fetch image: {StatusCode} from {Url}", response.StatusCode, imageUrl);
return StatusCode((int)response.StatusCode);
}
var contentType = response.Content.Headers.ContentType?.MediaType ?? "image/jpeg";
var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
return File(stream, contentType);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error proxying image from {Url}", imageUrl);
return StatusCode(500, "Failed to proxy image");
}
}
private static string SanitizeFileName(string name)
{
var invalidChars = Path.GetInvalidFileNameChars();
return string.Join("_", name.Split(invalidChars, StringSplitOptions.RemoveEmptyEntries)).TrimEnd('.');
}
}
@@ -119,6 +119,12 @@ public class JellypodController : ControllerBase
// Download podcast artwork
await _downloadService.DownloadPodcastArtworkAsync(podcast).ConfigureAwait(false);
// Download episode artwork for all initial episodes
foreach (var episode in podcast.Episodes)
{
await _downloadService.DownloadEpisodeArtworkAsync(podcast, episode).ConfigureAwait(false);
}
_logger.LogInformation("Added podcast: {Title} ({Url})", podcast.Title, podcast.FeedUrl);
return CreatedAtAction(nameof(GetPodcast), new { id = podcast.Id }, podcast);
@@ -180,6 +186,11 @@ public class JellypodController : ControllerBase
podcast.MaxEpisodesToKeep = request.MaxEpisodesToKeep.Value;
}
if (request.MaxEpisodeAgeDays.HasValue)
{
podcast.MaxEpisodeAgeDays = request.MaxEpisodeAgeDays.Value;
}
await _storageService.UpdatePodcastAsync(podcast).ConfigureAwait(false);
return Ok(podcast);
}
@@ -225,6 +236,12 @@ public class JellypodController : ControllerBase
podcast.LastUpdated = DateTime.UtcNow;
await _storageService.UpdatePodcastAsync(podcast).ConfigureAwait(false);
// Download artwork for new episodes
foreach (var episode in newEpisodes)
{
await _downloadService.DownloadEpisodeArtworkAsync(podcast, episode).ConfigureAwait(false);
}
return Ok(podcast);
}
@@ -14,4 +14,9 @@ public class UpdatePodcastRequest
/// Gets or sets the maximum episodes to keep.
/// </summary>
public int? MaxEpisodesToKeep { get; set; }
/// <summary>
/// Gets or sets the maximum age in days for episodes (0 = use global, -1 = unlimited).
/// </summary>
public int? MaxEpisodeAgeDays { get; set; }
}
@@ -189,7 +189,7 @@ public class JellypodChannel : IChannel, IHasCacheKey, IRequiresMediaInfoCallbac
Id = podcast.Id.ToString("N"),
Name = podcast.Title,
Overview = podcast.Description,
ImageUrl = podcast.ImageUrl,
ImageUrl = GetPodcastImageUrl(podcast.Id),
Type = ChannelItemType.Folder,
FolderType = ChannelFolderType.Container,
DateCreated = podcast.DateAdded,
@@ -257,7 +257,7 @@ public class JellypodChannel : IChannel, IHasCacheKey, IRequiresMediaInfoCallbac
Id = episode.Id.ToString("N"),
Name = episodeName,
Overview = overview,
ImageUrl = episode.ImageUrl ?? podcast.ImageUrl,
ImageUrl = GetEpisodeImageUrl(podcast.Id, episode.Id),
Type = ChannelItemType.Media,
ContentType = ChannelMediaContentType.Podcast,
MediaType = ChannelMediaType.Audio,
@@ -387,10 +387,9 @@ public class JellypodChannel : IChannel, IHasCacheKey, IRequiresMediaInfoCallbac
/// <inheritdoc />
public string? GetCacheKey(string? userId)
{
// Use 5-minute time buckets for cache key
var now = DateTime.Now;
var timeBucket = new DateTime(now.Year, now.Month, now.Day, now.Hour, (now.Minute / 5) * 5, 0);
return timeBucket.ToString("yyyy-MM-dd-HH-mm", CultureInfo.InvariantCulture);
// Include database modification time so cache invalidates when podcasts/episodes change
var lastModified = _storageService.LastModified;
return lastModified.ToString("O", CultureInfo.InvariantCulture);
}
/// <inheritdoc />
@@ -498,4 +497,16 @@ public class JellypodChannel : IChannel, IHasCacheKey, IRequiresMediaInfoCallbac
ReadAtNativeFramerate = false
};
}
private string GetPodcastImageUrl(Guid podcastId)
{
var localAddress = _appHost.GetApiUrlForLocalAccess();
return $"{localAddress}/Jellypod/Image/podcast/{podcastId:N}";
}
private string GetEpisodeImageUrl(Guid podcastId, Guid episodeId)
{
var localAddress = _appHost.GetApiUrlForLocalAccess();
return $"{localAddress}/Jellypod/Image/episode/{podcastId:N}/{episodeId:N}";
}
}
@@ -17,8 +17,11 @@ public class PluginConfiguration : BasePluginConfiguration
GlobalAutoDownloadEnabled = true;
MaxConcurrentDownloads = 2;
MaxEpisodesPerPodcast = 50;
MaxEpisodeAgeDays = 0;
CreatePodcastFolders = true;
DownloadNewEpisodesOnly = true;
PostDownloadScriptPath = string.Empty;
PostDownloadScriptTimeout = 60;
}
/// <summary>
@@ -47,6 +50,12 @@ public class PluginConfiguration : BasePluginConfiguration
/// </summary>
public int MaxEpisodesPerPodcast { get; set; }
/// <summary>
/// Gets or sets the maximum age in days for downloaded episodes (0 = unlimited).
/// Episodes older than this will be automatically deleted.
/// </summary>
public int MaxEpisodeAgeDays { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to create subfolders for each podcast.
/// </summary>
@@ -56,4 +65,15 @@ public class PluginConfiguration : BasePluginConfiguration
/// Gets or sets a value indicating whether to only download new episodes after subscription.
/// </summary>
public bool DownloadNewEpisodesOnly { get; set; }
/// <summary>
/// Gets or sets the path to post-download processing script.
/// Script is called with: script input_file output_file.
/// </summary>
public string PostDownloadScriptPath { get; set; }
/// <summary>
/// Gets or sets the timeout in seconds for post-download script execution.
/// </summary>
public int PostDownloadScriptTimeout { get; set; }
}
@@ -164,6 +164,38 @@
Maximum episodes to keep downloaded per podcast (0 = unlimited)
</div>
</div>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="MaxEpisodeAgeDays">
Max Episode Age (days)
</label>
<input id="MaxEpisodeAgeDays" name="MaxEpisodeAgeDays" type="number" is="emby-input" min="0" />
<div class="fieldDescription">
Automatically delete episodes downloaded more than this many days ago (0 = unlimited)
</div>
</div>
</div>
<!-- Post-Download Processing -->
<div class="verticalSection">
<h3 class="sectionTitle">Post-Download Processing</h3>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="PostDownloadScriptPath">
Post-Download Script Path
</label>
<input id="PostDownloadScriptPath" name="PostDownloadScriptPath" type="text" is="emby-input" />
<div class="fieldDescription">
Optional script to process episodes after download. Called as: script input_file output_file
</div>
</div>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="PostDownloadScriptTimeout">
Script Timeout (seconds)
</label>
<input id="PostDownloadScriptTimeout" name="PostDownloadScriptTimeout" type="number" is="emby-input" min="1" max="3600" />
<div class="fieldDescription">
Maximum time to wait for script completion (default: 60 seconds)
</div>
</div>
</div>
<div>
@@ -228,7 +260,10 @@
document.querySelector('#GlobalAutoDownloadEnabled').checked = config.GlobalAutoDownloadEnabled;
document.querySelector('#MaxConcurrentDownloads').value = config.MaxConcurrentDownloads;
document.querySelector('#MaxEpisodesPerPodcast').value = config.MaxEpisodesPerPodcast;
document.querySelector('#MaxEpisodeAgeDays').value = config.MaxEpisodeAgeDays;
document.querySelector('#CreatePodcastFolders').checked = config.CreatePodcastFolders;
document.querySelector('#PostDownloadScriptPath').value = config.PostDownloadScriptPath || '';
document.querySelector('#PostDownloadScriptTimeout').value = config.PostDownloadScriptTimeout || 60;
Dashboard.hideLoadingMsg();
});
}
@@ -407,7 +442,10 @@
config.GlobalAutoDownloadEnabled = document.querySelector('#GlobalAutoDownloadEnabled').checked;
config.MaxConcurrentDownloads = parseInt(document.querySelector('#MaxConcurrentDownloads').value, 10);
config.MaxEpisodesPerPodcast = parseInt(document.querySelector('#MaxEpisodesPerPodcast').value, 10);
config.MaxEpisodeAgeDays = parseInt(document.querySelector('#MaxEpisodeAgeDays').value, 10);
config.CreatePodcastFolders = document.querySelector('#CreatePodcastFolders').checked;
config.PostDownloadScriptPath = document.querySelector('#PostDownloadScriptPath').value;
config.PostDownloadScriptTimeout = parseInt(document.querySelector('#PostDownloadScriptTimeout').value, 10);
ApiClient.updatePluginConfiguration(JellypodConfig.pluginUniqueId, config).then(function (result) {
Dashboard.processPluginConfigurationUpdateResult(result);
});
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<RootNamespace>Jellyfin.Plugin.Jellypod</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -11,7 +11,8 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<!-- Jellyfin 10.9 (net8.0) -->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Jellyfin.Controller" Version="10.9.11">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
@@ -22,6 +23,18 @@
<PackageReference Include="System.ServiceModel.Syndication" Version="8.0.0" />
</ItemGroup>
<!-- Jellyfin 12.0 (net10.0) -->
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Jellyfin.Controller" Version="12.0.0">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Jellyfin.Model" Version="12.0.0">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.11" />
<PackageReference Include="System.ServiceModel.Syndication" Version="10.0.11" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="All" />
@@ -69,6 +69,12 @@ public class Podcast
/// </summary>
public int MaxEpisodesToKeep { get; set; }
/// <summary>
/// Gets or sets the maximum age in days for downloaded episodes.
/// 0 = use global setting, -1 = unlimited, greater than 0 = specific days.
/// </summary>
public int MaxEpisodeAgeDays { get; set; }
/// <summary>
/// Gets or sets the list of episodes.
/// </summary>
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Plugin.Jellypod.Models;
using Jellyfin.Plugin.Jellypod.Services;
using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging;
@@ -117,7 +118,22 @@ public class PodcastUpdateTask : IScheduledTask
}
processedCount++;
progress.Report((double)processedCount / totalPodcasts * 100);
progress.Report((double)processedCount / totalPodcasts * 90 / 100);
}
// Run cleanup for expired episodes
_logger.LogInformation("Starting episode retention cleanup");
foreach (var podcast in podcasts)
{
cancellationToken.ThrowIfCancellationRequested();
try
{
await CleanupExpiredEpisodesAsync(podcast, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to cleanup expired episodes for: {Title}", podcast.Title);
}
}
progress.Report(100);
@@ -134,9 +150,87 @@ public class PodcastUpdateTask : IScheduledTask
{
new TaskTriggerInfo
{
#if NET10_0_OR_GREATER
Type = TaskTriggerInfoType.IntervalTrigger,
#else
Type = TaskTriggerInfo.TriggerInterval,
#endif
IntervalTicks = TimeSpan.FromHours(intervalHours).Ticks
}
};
}
/// <summary>
/// Cleans up episodes that exceed the retention policy.
/// </summary>
/// <param name="podcast">The podcast to clean up.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>A task representing the asynchronous operation.</returns>
private async Task CleanupExpiredEpisodesAsync(Podcast podcast, CancellationToken cancellationToken)
{
var config = Plugin.Instance?.Configuration;
// Determine effective max age for this podcast
int effectiveMaxAgeDays;
if (podcast.MaxEpisodeAgeDays == -1)
{
// Per-podcast override: unlimited
return;
}
else if (podcast.MaxEpisodeAgeDays > 0)
{
// Per-podcast specific value
effectiveMaxAgeDays = podcast.MaxEpisodeAgeDays;
}
else
{
// Use global setting (podcast.MaxEpisodeAgeDays == 0)
effectiveMaxAgeDays = config?.MaxEpisodeAgeDays ?? 0;
}
// 0 means unlimited
if (effectiveMaxAgeDays <= 0)
{
return;
}
var cutoffDate = DateTime.UtcNow.AddDays(-effectiveMaxAgeDays);
var expiredEpisodes = podcast.Episodes
.Where(e => e.Status == EpisodeStatus.Downloaded
&& e.DownloadedDate.HasValue
&& e.DownloadedDate.Value < cutoffDate)
.ToList();
if (expiredEpisodes.Count == 0)
{
return;
}
_logger.LogInformation(
"Found {Count} expired episodes for {Podcast} (older than {Days} days)",
expiredEpisodes.Count,
podcast.Title,
effectiveMaxAgeDays);
foreach (var episode in expiredEpisodes)
{
cancellationToken.ThrowIfCancellationRequested();
try
{
await _downloadService.DeleteEpisodeFileAsync(episode).ConfigureAwait(false);
_logger.LogDebug(
"Deleted expired episode: {Title} (downloaded {Date})",
episode.Title,
episode.DownloadedDate);
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to delete expired episode: {Title}", episode.Title);
}
}
// Save changes to storage
await _storageService.UpdatePodcastAsync(podcast).ConfigureAwait(false);
}
}
@@ -46,4 +46,13 @@ public interface IPodcastDownloadService
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Task representing the download operation.</returns>
Task DownloadPodcastArtworkAsync(Podcast podcast, CancellationToken cancellationToken = default);
/// <summary>
/// Downloads episode artwork.
/// </summary>
/// <param name="podcast">The podcast.</param>
/// <param name="episode">The episode.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Task representing the download operation.</returns>
Task DownloadEpisodeArtworkAsync(Podcast podcast, Episode episode, CancellationToken cancellationToken = default);
}
@@ -10,6 +10,12 @@ namespace Jellyfin.Plugin.Jellypod.Services;
/// </summary>
public interface IPodcastStorageService
{
/// <summary>
/// Gets the cached last modification time (synchronous, for cache key generation).
/// Returns default if database hasn't been loaded yet.
/// </summary>
DateTime LastModified { get; }
/// <summary>
/// Gets all subscribed podcasts.
/// </summary>
@@ -57,4 +63,10 @@ public interface IPodcastStorageService
/// </summary>
/// <returns>The base path for podcast storage.</returns>
string GetStoragePath();
/// <summary>
/// Gets the last time the database was modified.
/// </summary>
/// <returns>The last modification time, or null if unknown.</returns>
Task<DateTime?> GetLastModifiedAsync();
}
@@ -1,8 +1,10 @@
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Plugin.Jellypod.Models;
@@ -63,15 +65,27 @@ public sealed class PodcastDownloadService : IPodcastDownloadService, IDisposabl
IProgress<double>? progress = null,
CancellationToken cancellationToken = default)
{
var filePath = _storageService.GetEpisodeFilePath(podcast, episode);
var directory = Path.GetDirectoryName(filePath);
var finalPath = _storageService.GetEpisodeFilePath(podcast, episode);
var finalDirectory = Path.GetDirectoryName(finalPath);
if (!string.IsNullOrEmpty(directory))
if (!string.IsNullOrEmpty(finalDirectory))
{
Directory.CreateDirectory(directory);
Directory.CreateDirectory(finalDirectory);
}
_logger.LogInformation("Downloading episode: {Title} to {Path}", episode.Title, filePath);
// Determine if we should use temp directory for post-processing
var config = Plugin.Instance?.Configuration;
var usePostProcessing = !string.IsNullOrWhiteSpace(config?.PostDownloadScriptPath);
// Use temp directory if post-processing is enabled, otherwise download directly to final location
var downloadPath = usePostProcessing
? Path.Combine(Path.GetTempPath(), "jellypod-" + Path.GetRandomFileName() + Path.GetExtension(finalPath))
: finalPath;
_logger.LogInformation("Downloading episode: {Title} to {Path}", episode.Title, downloadPath);
string? tempInputFile = null;
string? tempOutputFile = null;
try
{
@@ -91,7 +105,7 @@ public sealed class PodcastDownloadService : IPodcastDownloadService, IDisposabl
long totalRead;
try
{
var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None, 81920, true);
var fileStream = new FileStream(downloadPath, FileMode.Create, FileAccess.Write, FileShare.None, 81920, true);
try
{
var buffer = new byte[81920];
@@ -119,17 +133,51 @@ public sealed class PodcastDownloadService : IPodcastDownloadService, IDisposabl
await contentStream.DisposeAsync().ConfigureAwait(false);
}
episode.LocalFilePath = filePath;
_logger.LogInformation("Downloaded episode: {Title} ({Size} bytes)", episode.Title, totalRead);
// Post-processing if configured
string sourceFile = downloadPath;
if (usePostProcessing)
{
tempInputFile = downloadPath;
tempOutputFile = Path.Combine(
Path.GetTempPath(),
"jellypod-output-" + Path.GetRandomFileName() + Path.GetExtension(finalPath));
var scriptTimeout = config?.PostDownloadScriptTimeout ?? 60;
var processedFile = await ExecutePostDownloadScriptAsync(
tempInputFile,
tempOutputFile,
scriptTimeout,
cancellationToken).ConfigureAwait(false);
if (processedFile != null)
{
_logger.LogInformation("Using processed file from post-download script");
sourceFile = processedFile;
}
else
{
_logger.LogInformation("Using original file (script failed, timed out, or not configured)");
sourceFile = tempInputFile;
}
// Copy the selected file to final destination
File.Copy(sourceFile, finalPath, overwrite: true);
_logger.LogInformation("Copied episode to final location: {Path}", finalPath);
}
// Get final file size
var finalFileInfo = new FileInfo(finalPath);
episode.LocalFilePath = finalPath;
episode.Status = EpisodeStatus.Downloaded;
episode.DownloadedDate = DateTime.UtcNow;
episode.FileSizeBytes = totalRead;
_logger.LogInformation("Downloaded episode: {Title} ({Size} bytes)", episode.Title, totalRead);
episode.FileSizeBytes = finalFileInfo.Length;
// Update the podcast in storage
await _storageService.UpdatePodcastAsync(podcast).ConfigureAwait(false);
return filePath;
return finalPath;
}
catch (Exception ex)
{
@@ -137,6 +185,35 @@ public sealed class PodcastDownloadService : IPodcastDownloadService, IDisposabl
_logger.LogError(ex, "Failed to download episode: {Title}", episode.Title);
throw;
}
finally
{
// Clean up temp files
if (tempInputFile != null && File.Exists(tempInputFile))
{
try
{
File.Delete(tempInputFile);
_logger.LogDebug("Cleaned up temp input file: {Path}", tempInputFile);
}
catch (Exception ex)
{
_logger.LogWarning(ex, "Failed to delete temp input file: {Path}", tempInputFile);
}
}
if (tempOutputFile != null && File.Exists(tempOutputFile))
{
try
{
File.Delete(tempOutputFile);
_logger.LogDebug("Cleaned up temp output file: {Path}", tempOutputFile);
}
catch (Exception ex)
{
_logger.LogWarning(ex, "Failed to delete temp output file: {Path}", tempOutputFile);
}
}
}
}
/// <inheritdoc />
@@ -206,6 +283,46 @@ public sealed class PodcastDownloadService : IPodcastDownloadService, IDisposabl
}
}
/// <inheritdoc />
public async Task DownloadEpisodeArtworkAsync(Podcast podcast, Episode episode, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(episode.ImageUrl))
{
return;
}
var config = Plugin.Instance?.Configuration;
if (config?.CreatePodcastFolders != true)
{
return;
}
var basePath = _storageService.GetStoragePath();
var podcastFolder = Path.Combine(basePath, SanitizeFileName(podcast.Title));
var episodeFileName = $"{SanitizeFileName(episode.Id.ToString())}.jpg";
var artworkPath = Path.Combine(podcastFolder, episodeFileName);
if (File.Exists(artworkPath))
{
return;
}
try
{
Directory.CreateDirectory(podcastFolder);
var httpClient = _httpClientFactory.CreateClient("Jellypod");
var imageBytes = await httpClient.GetByteArrayAsync(episode.ImageUrl, cancellationToken).ConfigureAwait(false);
await File.WriteAllBytesAsync(artworkPath, imageBytes, cancellationToken).ConfigureAwait(false);
_logger.LogDebug("Downloaded artwork for episode: {Title}", episode.Title);
}
catch (Exception ex)
{
_logger.LogDebug(ex, "Failed to download artwork for episode: {Title}", episode.Title);
}
}
private async Task ProcessQueueAsync()
{
try
@@ -240,6 +357,136 @@ public sealed class PodcastDownloadService : IPodcastDownloadService, IDisposabl
return result.Length > 100 ? result.Substring(0, 100).Trim() : result.Trim();
}
/// <summary>
/// Executes the post-download script if configured.
/// </summary>
/// <param name="inputFilePath">Path to the downloaded file.</param>
/// <param name="outputFilePath">Path where the script should write the processed file.</param>
/// <param name="timeoutSeconds">Timeout in seconds.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>The output file path if successful, null if failed/timeout.</returns>
private async Task<string?> ExecutePostDownloadScriptAsync(
string inputFilePath,
string outputFilePath,
int timeoutSeconds,
CancellationToken cancellationToken)
{
var config = Plugin.Instance?.Configuration;
var scriptPath = config?.PostDownloadScriptPath;
if (string.IsNullOrWhiteSpace(scriptPath))
{
return null;
}
if (!File.Exists(scriptPath))
{
_logger.LogError("Post-download script not found at path: {ScriptPath}", scriptPath);
return null;
}
try
{
_logger.LogDebug(
"Executing post-download script: {ScriptPath} {InputFile} {OutputFile}",
scriptPath,
inputFilePath,
outputFilePath);
var processStartInfo = new ProcessStartInfo
{
FileName = scriptPath,
Arguments = $"\"{inputFilePath}\" \"{outputFilePath}\"",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
};
using var process = new Process { StartInfo = processStartInfo };
var stdoutBuilder = new StringBuilder();
var stderrBuilder = new StringBuilder();
process.OutputDataReceived += (sender, e) =>
{
if (e.Data != null)
{
stdoutBuilder.AppendLine(e.Data);
}
};
process.ErrorDataReceived += (sender, e) =>
{
if (e.Data != null)
{
stderrBuilder.AppendLine(e.Data);
}
};
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
// Create a timeout cancellation token
using var timeoutCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
timeoutCts.CancelAfter(TimeSpan.FromSeconds(timeoutSeconds));
try
{
await process.WaitForExitAsync(timeoutCts.Token).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
if (!process.HasExited)
{
_logger.LogWarning(
"Post-download script timed out after {Timeout} seconds, killing process",
timeoutSeconds);
process.Kill(entireProcessTree: true);
}
return null;
}
var stdout = stdoutBuilder.ToString();
var stderr = stderrBuilder.ToString();
if (!string.IsNullOrWhiteSpace(stdout))
{
_logger.LogDebug("Script stdout: {Stdout}", stdout.Trim());
}
if (!string.IsNullOrWhiteSpace(stderr))
{
_logger.LogDebug("Script stderr: {Stderr}", stderr.Trim());
}
if (process.ExitCode != 0)
{
_logger.LogError(
"Post-download script failed with exit code {ExitCode}",
process.ExitCode);
return null;
}
if (!File.Exists(outputFilePath))
{
_logger.LogWarning(
"Post-download script succeeded but output file was not created: {OutputFile}",
outputFilePath);
return null;
}
_logger.LogInformation("Post-download script executed successfully");
return outputFilePath;
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to execute post-download script");
return null;
}
}
/// <inheritdoc />
public void Dispose()
{
@@ -28,6 +28,7 @@ public sealed class PodcastStorageService : IPodcastStorageService, IDisposable
private readonly IApplicationPaths _applicationPaths;
private readonly SemaphoreSlim _dbLock = new(1, 1);
private PodcastDatabase? _cache;
private DateTime _lastModified;
/// <summary>
/// Initializes a new instance of the <see cref="PodcastStorageService"/> class.
@@ -47,6 +48,9 @@ public sealed class PodcastStorageService : IPodcastStorageService, IDisposable
"Jellypod",
"podcasts.json");
/// <inheritdoc />
public DateTime LastModified => _lastModified;
/// <inheritdoc />
public async Task<IReadOnlyList<Podcast>> GetAllPodcastsAsync()
{
@@ -180,6 +184,7 @@ public sealed class PodcastStorageService : IPodcastStorageService, IDisposable
{
_logger.LogWarning("Database file does not exist at {Path}", DatabasePath);
_cache = new PodcastDatabase();
_lastModified = DateTime.UtcNow;
return _cache;
}
@@ -189,6 +194,7 @@ public sealed class PodcastStorageService : IPodcastStorageService, IDisposable
var json = await File.ReadAllTextAsync(DatabasePath).ConfigureAwait(false);
_logger.LogInformation("Read {Length} characters from database file", json.Length);
_cache = JsonSerializer.Deserialize<PodcastDatabase>(json, JsonOptions) ?? new PodcastDatabase();
_lastModified = _cache.LastSaved;
_logger.LogInformation("Loaded {Count} podcasts from database", _cache.Podcasts.Count);
return _cache;
}
@@ -196,6 +202,7 @@ public sealed class PodcastStorageService : IPodcastStorageService, IDisposable
{
_logger.LogError(ex, "Failed to load podcast database, starting fresh");
_cache = new PodcastDatabase();
_lastModified = DateTime.UtcNow;
return _cache;
}
}
@@ -211,6 +218,7 @@ public sealed class PodcastStorageService : IPodcastStorageService, IDisposable
}
db.LastSaved = DateTime.UtcNow;
_lastModified = db.LastSaved;
var json = JsonSerializer.Serialize(db, JsonOptions);
await File.WriteAllTextAsync(DatabasePath, json).ConfigureAwait(false);
_cache = db;
@@ -261,6 +269,13 @@ public sealed class PodcastStorageService : IPodcastStorageService, IDisposable
return ".mp3";
}
/// <inheritdoc />
public async Task<DateTime?> GetLastModifiedAsync()
{
var db = await LoadDatabaseAsync().ConfigureAwait(false);
return db.LastSaved;
}
/// <inheritdoc />
public void Dispose()
{
+108 -4
View File
@@ -2,11 +2,85 @@
A Jellyfin plugin that adds podcast support to your media server.
## Quick Install
Add this repository URL in Jellyfin (Dashboard → Plugins → Repositories):
```
https://gitea.tourolle.paris/dtourolle/jellypod/raw/branch/master/manifest.json
```
## Supported Jellyfin Versions
Jellypod is released as two builds from the same source. The repository manifest
lists both, and Jellyfin picks the right one for your server automatically:
| Jellyfin server | Build | Target framework |
| --------------- | -------------- | ---------------- |
| 10.9.x | `*_jf10.9.zip` | .NET 8 |
| 12.0 and newer | `*_jf12.zip` | .NET 10 |
If you install manually, download the build matching your server — a build
installed on the wrong server will fail to load.
## Features
- Browse and subscribe to podcasts
- Automatic episode downloads
- Integration with Jellyfin's library system
- Post-download script hook for audio processing
## Post-Download Script Hook
Jellypod supports running a custom script on each downloaded episode before it's added to your library. This is useful for:
- Audio normalization (e.g., using ffmpeg-normalize)
- Format conversion
- Metadata enhancement
- Custom processing workflows
### Configuration
In the plugin settings (Dashboard → Plugins → Jellypod):
1. **Post-Download Script Path**: Full path to your script or executable
2. **Script Timeout**: Maximum execution time in seconds (default: 60)
### Script API
Your script will be called with two arguments:
```bash
script <input_file> <output_file>
```
- `input_file`: Path to the downloaded episode (read-only)
- `output_file`: Path where your script should write the processed file
### Example Scripts
**Audio normalization (bash + ffmpeg):**
```bash
#!/bin/bash
INPUT="$1"
OUTPUT="$2"
ffmpeg-normalize "$INPUT" -o "$OUTPUT" -c:a libmp3lame -b:a 128k
```
**Format conversion (bash + ffmpeg):**
```bash
#!/bin/bash
INPUT="$1"
OUTPUT="$2"
ffmpeg -i "$INPUT" -c:a aac -b:a 128k "$OUTPUT"
```
### Behavior
- If the script succeeds (exit code 0) and creates the output file, the processed file is added to your library
- If the script fails, times out, or doesn't create an output file, the original downloaded file is used instead
- All script output (stdout/stderr) is logged for debugging
- Leave the script path empty to disable post-processing
## Screenshots
@@ -18,9 +92,22 @@ A Jellyfin plugin that adds podcast support to your media server.
## Installation
### From Plugin Repository (Recommended)
1. In Jellyfin, go to **Dashboard****Plugins****Repositories**
2. Click the **+** button to add a new repository
3. Enter:
- **Repository Name**: `Jellypod`
- **Repository URL**: `https://gitea.tourolle.paris/dtourolle/jellypod/raw/branch/master/manifest.json`
4. Click **Save**
5. Go to **Catalog** tab and find **Jellypod**
6. Click **Install** and restart Jellyfin
### Manual Installation
1. Download the latest release from [Releases](https://gitea.tourolle.paris/dtourolle/jellypod/releases)
1. Download the latest release from [Releases](https://gitea.tourolle.paris/dtourolle/jellypod/releases),
picking `jellypod_<version>_jf10.9.zip` for Jellyfin 10.9.x or
`jellypod_<version>_jf12.zip` for Jellyfin 12.0 and newer
2. Extract the contents to your Jellyfin plugins directory:
- **Linux**: `~/.local/share/jellyfin/plugins/Jellypod/`
- **Windows**: `%LOCALAPPDATA%\jellyfin\plugins\Jellypod\`
@@ -31,15 +118,32 @@ A Jellyfin plugin that adds podcast support to your media server.
#### Requirements
- [.NET SDK 8.0](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
- [.NET SDK 8.0](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) for the Jellyfin 10.9 build
- [.NET SDK 10.0](https://dotnet.microsoft.com/en-us/download/dotnet/10.0) for the Jellyfin 12.0 build
#### Build
```bash
dotnet build
dotnet build # both targets
dotnet build -f net8.0 # Jellyfin 10.9 only
dotnet build -f net10.0 # Jellyfin 12.0 only
```
The plugin DLL will be in `Jellyfin.Plugin.Jellypod/bin/Debug/net8.0/`.
The plugin DLL will be in `Jellyfin.Plugin.Jellypod/bin/Debug/net8.0/` or
`Jellyfin.Plugin.Jellypod/bin/Debug/net10.0/`.
#### Packaging
`build.yaml` is the [jprm](https://github.com/oddstr13/jellyfin-plugin-repository-manager)
config for the Jellyfin 10.9 build. The Jellyfin 12.0 config is derived from it
at release time, so the two cannot drift apart:
```bash
sed -e 's/^targetAbi:.*/targetAbi: "12.0.0.0"/' \
-e 's/^framework:.*/framework: "net10.0"/' \
-e 's/^dotnet_framework:.*/dotnet_framework: "net10.0"/' \
build.yaml > build.jf12.yaml
```
## Development
+2
View File
@@ -100,6 +100,8 @@
<Rule Id="CA1308" Action="None" />
<!-- disable warning CA1848: Use the LoggerMessage delegates -->
<Rule Id="CA1848" Action="None" />
<!-- disable warning CA1873: Avoid potentially expensive logging -->
<Rule Id="CA1873" Action="None" />
<!-- disable warning CA2101: Specify marshaling for P/Invoke string arguments -->
<Rule Id="CA2101" Action="None" />
<!-- disable warning CA2234: Pass System.Uri objects instead of strings -->
+61
View File
@@ -0,0 +1,61 @@
[
{
"guid": "c713faf4-4e50-4e87-941a-1200178ed605",
"name": "Jellypod",
"description": "Jellypod allows you to subscribe to podcast RSS feeds, automatically download episodes, and manage your podcast library within Jellyfin. Episodes are stored as standard audio files and integrate with Jellyfin's built-in audio player.",
"overview": "Podcast management plugin for Jellyfin",
"owner": "dtourolle",
"category": "General",
"imageUrl": "https://gitea.tourolle.paris/dtourolle/jellypod/raw/branch/master/Jellyfin.Plugin.Jellypod/Images/channel-icon.jpg",
"versions": [
{
"version": "1.0.10",
"changelog": "Release 1.0.10",
"targetAbi": "10.9.0.0",
"sourceUrl": "https://gitea.tourolle.paris/dtourolle/jellypod/releases/download/v1.0.10/jellypod_1.0.10.0.zip",
"checksum": "37509ee316e5731b7dcfef394099ac53",
"timestamp": "2026-01-11T09:06:37Z"
},
{
"version": "1.0.9",
"changelog": "Release 1.0.9",
"targetAbi": "10.9.0.0",
"sourceUrl": "https://gitea.tourolle.paris/dtourolle/jellypod/releases/download/v1.0.9/jellypod_1.0.9.0.zip",
"checksum": "f1f4ade3fc5483118d1171e636b67007",
"timestamp": "2026-01-11T09:02:21Z"
},
{
"version": "1.0.4",
"changelog": "Release 1.0.4",
"targetAbi": "10.9.0.0",
"sourceUrl": "https://gitea.tourolle.paris/dtourolle/jellypod/releases/download/v1.0.4/jellypod_1.0.4.0.zip",
"checksum": "0e0c134e6584581a8498cb17dfda334b",
"timestamp": "2026-01-10T18:48:08Z"
},
{
"version": "1.0.2",
"changelog": "Release 1.0.2",
"targetAbi": "10.9.0.0",
"sourceUrl": "https://gitea.tourolle.paris/dtourolle/jellypod/releases/download/v1.0.2/jellypod_1.0.2.0.zip",
"checksum": "874f6b76c8cf4bac6495fe946224096a",
"timestamp": "2025-12-30T15:25:33Z"
},
{
"version": "1.0.1",
"changelog": "Release 1.0.1",
"targetAbi": "10.9.0.0",
"sourceUrl": "https://gitea.tourolle.paris/dtourolle/jellypod/releases/download/v1.0.1/jellypod_1.0.1.0.zip",
"checksum": "8b8cddefe4e6b5c7128e1626a424519b",
"timestamp": "2025-12-21T13:07:42Z"
},
{
"version": "1.0.0",
"changelog": "Release 1.0.0",
"targetAbi": "10.9.0.0",
"sourceUrl": "https://gitea.tourolle.paris/dtourolle/jellypod/releases/download/v1.0.0/jellypod_1.0.0.0.zip",
"checksum": "3267fa2bee3661f9a85c959497fe20dd",
"timestamp": "2025-12-20T13:00:27Z"
}
]
}
]