Compare commits

..

No commits in common. "master" and "v1.0.2" have entirely different histories.

10 changed files with 97 additions and 330 deletions

View File

@ -15,14 +15,15 @@ on:
jobs:
build:
runs-on: ubuntu-22.04
container:
image: gitea.tourolle.paris/dtourolle/jellypod-builder:latest
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
@ -32,11 +33,19 @@ jobs:
- name: Run tests
run: dotnet test Jellyfin.Plugin.Jellypod.sln --no-build --configuration Release --verbosity normal
- name: Install JPRM
run: |
python3 -m venv /tmp/jprm-venv
/tmp/jprm-venv/bin/pip install jprm
- name: Build Jellyfin Plugin
id: jprm
run: |
# Create artifacts directory for JPRM output
mkdir -p artifacts
jprm --verbosity=debug plugin build .
# Build plugin using JPRM
/tmp/jprm-venv/bin/jprm --verbosity=debug plugin build .
# Find the generated zip file
ARTIFACT=$(find . -name "*.zip" -type f -print -quit)

View File

@ -13,14 +13,15 @@ on:
jobs:
build-and-release:
runs-on: ubuntu-22.04
container:
image: gitea.tourolle.paris/dtourolle/jellypod-builder:latest
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Verify .NET installation
run: dotnet --version
- name: Get version
id: get_version
run: |
@ -48,11 +49,19 @@ jobs:
- name: Run tests
run: dotnet test Jellyfin.Plugin.Jellypod.sln --no-build --configuration Release --verbosity normal
- name: Install JPRM
run: |
python3 -m venv /tmp/jprm-venv
/tmp/jprm-venv/bin/pip install jprm
- name: Build Jellyfin Plugin
id: jprm
run: |
# Create artifacts directory for JPRM output
mkdir -p artifacts
jprm --verbosity=debug plugin build ./
# Build plugin using JPRM
/tmp/jprm-venv/bin/jprm --verbosity=debug plugin build ./
# Find the generated zip file
ARTIFACT=$(find . -name "*.zip" -type f -print -quit)
@ -78,13 +87,22 @@ 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.\n\nTo install, add this repository URL to Jellyfin:\n\`${GITEA_URL}/${REPO_OWNER}/${REPO_NAME}/raw/branch/master/manifest.json\`"
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 "$(jq -n --arg tag "$VERSION" --arg name "Release $VERSION" --arg body "Jellypod Jellyfin Plugin. See attached files for plugin installation." '{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}')")
-d "{
\"tag_name\": \"${{ steps.get_version.outputs.version }}\",
\"name\": \"Release ${{ steps.get_version.outputs.version }}\",
\"body\": ${RELEASE_BODY_JSON},
\"draft\": false,
\"prerelease\": false
}")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d')
@ -139,15 +157,21 @@ jobs:
git fetch origin master
git checkout master
# Create new version entry
NEW_VERSION=$(cat <<EOF
{
"version": "${VERSION}",
"changelog": "Release ${VERSION}",
"targetAbi": "10.9.0.0",
"sourceUrl": "${DOWNLOAD_URL}",
"checksum": "${CHECKSUM}",
"timestamp": "${TIMESTAMP}"
}
EOF
)
# Update manifest.json - prepend new version to versions array
jq --arg ver "${VERSION}" \
--arg changelog "Release ${VERSION}" \
--arg abi "10.9.0.0" \
--arg url "${DOWNLOAD_URL}" \
--arg checksum "${CHECKSUM}" \
--arg ts "${TIMESTAMP}" \
'.[0].versions = [{version: $ver, changelog: $changelog, targetAbi: $abi, sourceUrl: $url, checksum: $checksum, timestamp: $ts}] + .[0].versions' \
manifest.json > manifest.tmp && mv manifest.tmp manifest.json
jq --argjson newver "${NEW_VERSION}" '.[0].versions = [$newver] + .[0].versions' manifest.json > manifest.tmp && mv manifest.tmp manifest.json
# Commit and push
git add manifest.json

View File

@ -0,0 +1,44 @@
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

View File

@ -1,16 +0,0 @@
FROM mcr.microsoft.com/dotnet/sdk:8.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/*
# Install JPRM
RUN pip install --break-system-packages jprm
WORKDIR /src

View File

@ -1,189 +0,0 @@
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('.');
}
}

View File

@ -119,12 +119,6 @@ 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);
@ -236,12 +230,6 @@ 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);
}

View File

@ -189,7 +189,7 @@ public class JellypodChannel : IChannel, IHasCacheKey, IRequiresMediaInfoCallbac
Id = podcast.Id.ToString("N"),
Name = podcast.Title,
Overview = podcast.Description,
ImageUrl = GetPodcastImageUrl(podcast.Id),
ImageUrl = podcast.ImageUrl,
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 = GetEpisodeImageUrl(podcast.Id, episode.Id),
ImageUrl = episode.ImageUrl ?? podcast.ImageUrl,
Type = ChannelItemType.Media,
ContentType = ChannelMediaContentType.Podcast,
MediaType = ChannelMediaType.Audio,
@ -497,16 +497,4 @@ 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}";
}
}

View File

@ -46,13 +46,4 @@ 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);
}

View File

@ -283,46 +283,6 @@ 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

View File

@ -8,38 +8,6 @@
"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",