mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-24 16:40:25 +01:00
change chapter image location and cleanup dead files
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.MediaInfo;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
@@ -22,12 +21,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
/// </summary>
|
||||
public class AudioImageProvider : BaseMetadataProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the image cache.
|
||||
/// </summary>
|
||||
/// <value>The image cache.</value>
|
||||
public FileSystemRepository ImageCache { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The _locks
|
||||
/// </summary>
|
||||
@@ -48,8 +41,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
_mediaEncoder = mediaEncoder;
|
||||
|
||||
ImageCache = new FileSystemRepository(Kernel.Instance.FFMpegManager.AudioImagesDataPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -113,7 +104,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
return ItemUpdateType.ImageUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
||||
/// </summary>
|
||||
@@ -154,13 +145,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var album = item.Parent as MusicAlbum;
|
||||
|
||||
var filename = item.Album ?? string.Empty;
|
||||
filename += item.Artists.FirstOrDefault() ?? string.Empty;
|
||||
filename += album == null ? item.Id.ToString("N") + item.DateModified.Ticks : album.Id.ToString("N") + album.DateModified.Ticks;
|
||||
|
||||
var path = ImageCache.GetResourcePath(filename + "_primary", ".jpg");
|
||||
var path = GetAudioImagePath(item);
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
@@ -195,6 +180,38 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
item.PrimaryImagePath = path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the audio image path.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
private string GetAudioImagePath(Audio item)
|
||||
{
|
||||
var album = item.Parent as MusicAlbum;
|
||||
|
||||
var filename = item.Album ?? string.Empty;
|
||||
filename += item.Artists.FirstOrDefault() ?? string.Empty;
|
||||
filename += album == null ? item.Id.ToString("N") + item.DateModified.Ticks : album.Id.ToString("N") + album.DateModified.Ticks + "_primary";
|
||||
|
||||
filename = filename.GetMD5() + ".jpg";
|
||||
|
||||
var prefix = filename.Substring(0, 1);
|
||||
|
||||
return Path.Combine(AudioImagesPath, prefix, filename);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the audio images data path.
|
||||
/// </summary>
|
||||
/// <value>The audio images data path.</value>
|
||||
public string AudioImagesPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(ConfigurationManager.ApplicationPaths.DataPath, "extracted-audio-images");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lock.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.MediaInfo;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@@ -12,7 +11,6 @@ using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -20,12 +18,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
{
|
||||
class VideoImageProvider : BaseMetadataProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the image cache.
|
||||
/// </summary>
|
||||
/// <value>The image cache.</value>
|
||||
public FileSystemRepository ImageCache { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The _locks
|
||||
/// </summary>
|
||||
@@ -42,8 +34,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
{
|
||||
_mediaEncoder = mediaEncoder;
|
||||
_isoManager = isoManager;
|
||||
|
||||
ImageCache = new FileSystemRepository(Kernel.Instance.FFMpegManager.VideoImagesDataPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -206,9 +196,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var filename = item.Path + "_" + item.DateModified.Ticks + "_primary";
|
||||
|
||||
var path = ImageCache.GetResourcePath(filename, ".jpg");
|
||||
var path = GetVideoImagePath(item);
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
@@ -310,5 +298,33 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
{
|
||||
return _locks.GetOrAdd(filename, key => new SemaphoreSlim(1, 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the video images data path.
|
||||
/// </summary>
|
||||
/// <value>The video images data path.</value>
|
||||
public string VideoImagesPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(ConfigurationManager.ApplicationPaths.DataPath, "extracted-video-images");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the audio image path.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
private string GetVideoImagePath(Video item)
|
||||
{
|
||||
var filename = item.Path + "_" + item.DateModified.Ticks + "_primary";
|
||||
|
||||
filename = filename.GetMD5() + ".jpg";
|
||||
|
||||
var prefix = filename.Substring(0, 1);
|
||||
|
||||
return Path.Combine(VideoImagesPath, prefix, filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user