Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 4, 2024
2 parents e4c7655 + 1dd3792 commit fa474e6
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 19 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@
- [jaina heartles](https://github.com/heartles)
- [oxixes](https://github.com/oxixes)
- [elfalem](https://github.com/elfalem)
- [benedikt257](https://github.com/benedikt257)
- [revam](https://github.com/revam)

# Emby Contributors

Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="8.0.1" />
<PackageVersion Include="TagLibSharp" Version="2.3.0" />
<PackageVersion Include="z440.atl.core" Version="6.6.0" />
<PackageVersion Include="z440.atl.core" Version="6.7.0" />
<PackageVersion Include="TMDbLib" Version="2.2.0" />
<PackageVersion Include="UTF.Unknown" Version="2.5.1" />
<PackageVersion Include="Xunit.Priority" Version="1.1.6" />
Expand Down
8 changes: 8 additions & 0 deletions Emby.Naming/Common/NamingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,14 @@ public NamingOptions()
{
IsNamed = true
},

// Anime style expression
// "[Group][Series Name][21][1080p][FLAC][HASH]"
// "[Group] Series Name [04][BDRIP]"
new EpisodeExpression(@"(?:\[(?:[^\]]+)\]\s*)?(?<seriesname>\[[^\]]+\]|[^[\]]+)\s*\[(?<epnumber>[0-9]+)\]")
{
IsNamed = true
},
};

VideoExtraRules = new[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ protected async Task<ItemUpdateType> FetchToFileInternal(
}

await ProviderManager.SaveImage(item, outputPath, mimeType, imageType, null, false, cancellationToken).ConfigureAwait(false);
File.Delete(outputPath);

return ItemUpdateType.ImageUpdate;
}
Expand Down
10 changes: 5 additions & 5 deletions Emby.Server.Implementations/Localization/Core/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"LabelIpAddressValue": "Ip כתובת: {0}",
"LabelRunningTimeValue": "משך צפייה: {0}",
"Latest": "אחרון",
"MessageApplicationUpdated": "שרת הJellyfin עודכן",
"MessageApplicationUpdatedTo": "שרת ה־Jellyfin עודכן לגרסה {0}",
"MessageApplicationUpdated": "שרת ג'ליפין עודכן",
"MessageApplicationUpdatedTo": "שרת ג'ליפין עודכן לגרסה {0}",
"MessageNamedServerConfigurationUpdatedWithValue": "סעיף הגדרת השרת {0} עודכן",
"MessageServerConfigurationUpdated": "תצורת השרת עודכנה",
"MixedContent": "תוכן מעורב",
Expand All @@ -43,7 +43,7 @@
"NameInstallFailed": "התקנת {0} נכשלה",
"NameSeasonNumber": "עונה {0}",
"NameSeasonUnknown": "עונה לא ידועה",
"NewVersionIsAvailable": "גרסה חדשה של שרת Jellyfin זמינה להורדה.",
"NewVersionIsAvailable": "גרסה חדשה של שרת ג'ליפין זמינה להורדה.",
"NotificationOptionApplicationUpdateAvailable": "קיים עדכון זמין ליישום",
"NotificationOptionApplicationUpdateInstalled": "עדכון ליישום הותקן",
"NotificationOptionAudioPlayback": "ניגון שמע החל",
Expand Down Expand Up @@ -72,7 +72,7 @@
"ServerNameNeedsToBeRestarted": "{0} דורש הפעלה מחדש",
"Shows": "סדרות",
"Songs": "שירים",
"StartupEmbyServerIsLoading": "שרת Jellyfin בהליכי טעינה. נא לנסות שנית בהקדם.",
"StartupEmbyServerIsLoading": "שרת ג'ליפין טוען. נא לנסות שוב בקרוב.",
"SubtitleDownloadFailureForItem": "Subtitles failed to download for {0}",
"SubtitleDownloadFailureFromForItem": "הורדת כתוביות מ־{0} עבור {1} נכשלה",
"Sync": "סנכרון",
Expand Down Expand Up @@ -136,5 +136,5 @@
"TaskMoveTrickplayImages": "העברת מיקום התמונות",
"TaskExtractMediaSegments": "סריקת מדיה",
"TaskExtractMediaSegmentsDescription": "מחלץ חלקי מדיה מתוספים המאפשרים זאת.",
"TaskMoveTrickplayImagesDescription": "הזזת קבצי trickplay קיימים בהתאם להגדרות הספרייה."
"TaskMoveTrickplayImagesDescription": "הזזת קבצי טריקפליי קיימים בהתאם להגדרות הספרייה."
}
6 changes: 5 additions & 1 deletion Emby.Server.Implementations/Session/SessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,11 @@ public IReadOnlyList<SessionInfoDto> GetSessions(
// Don't report acceleration type for non-admin users.
result = result.Select(r =>
{
r.TranscodingInfo.HardwareAccelerationType = HardwareAccelerationType.none;
if (r.TranscodingInfo is not null)
{
r.TranscodingInfo.HardwareAccelerationType = HardwareAccelerationType.none;
}
return r;
});
}
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Server.Implementations/Users/UserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public UserManager(
// This is some regex that matches only on unicode "word" characters, as well as -, _ and @
// In theory this will cut out most if not all 'control' characters which should help minimize any weirdness
// Usernames can contain letters (a-z + whatever else unicode is cool with), numbers (0-9), at-signs (@), dashes (-), underscores (_), apostrophes ('), periods (.) and spaces ( )
[GeneratedRegex(@"^[\w\ \-'._@]+$")]
[GeneratedRegex(@"^[\w\ \-'._@+]+$")]
private static partial Regex ValidUsernameRegex();

/// <inheritdoc/>
Expand Down
3 changes: 2 additions & 1 deletion MediaBrowser.Controller/Providers/IProviderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public interface IProviderManager
Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType type, int? imageIndex, CancellationToken cancellationToken);

/// <summary>
/// Saves the image.
/// Saves the image by giving the image path on filesystem.
/// This method will remove the image on the source path after saving it to the destination.
/// </summary>
/// <param name="item">Image to save.</param>
/// <param name="source">Source of image.</param>
Expand Down
8 changes: 8 additions & 0 deletions MediaBrowser.Model/Dlna/StreamBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ public StreamBuilder(ITranscoderSupport transcoderSupport, ILogger logger)

var longBitrate = Math.Min(transcodingBitrate, playlistItem.AudioBitrate ?? transcodingBitrate);
playlistItem.AudioBitrate = longBitrate > int.MaxValue ? int.MaxValue : Convert.ToInt32(longBitrate);

// Pure audio transcoding does not support comma separated list of transcoding codec at the moment.
// So just use the AudioCodec as is would be safe enough as the _transcoderSupport.CanEncodeToAudioCodec
// would fail so this profile will not even be picked up.
if (playlistItem.AudioCodecs.Count == 0 && !string.IsNullOrWhiteSpace(transcodingProfile.AudioCodec))
{
playlistItem.AudioCodecs = [transcodingProfile.AudioCodec];
}
}

playlistItem.TranscodeReasons = transcodeReasons;
Expand Down
8 changes: 3 additions & 5 deletions MediaBrowser.Providers/Manager/ItemImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ private async Task RefreshFromProvider(
{
var mimeType = MimeTypes.GetMimeType(response.Path);

var stream = AsyncFile.OpenRead(response.Path);

await _providerManager.SaveImage(item, stream, mimeType, imageType, null, cancellationToken).ConfigureAwait(false);
await _providerManager.SaveImage(item, response.Path, mimeType, imageType, null, null, cancellationToken).ConfigureAwait(false);
}
}

Expand Down Expand Up @@ -387,8 +385,8 @@ private void PruneImages(BaseItem item, IReadOnlyList<ItemImageInfo> images)

item.RemoveImages(images);

// Cleanup old metadata directory for episodes if empty
if (item is Episode)
// Cleanup old metadata directory for episodes if empty, as long as it's not a virtual item
if (item is Episode && !item.IsVirtualItem)
{
var oldLocalMetadataDirectory = Path.Combine(item.ContainingFolderPath, "metadata");
if (_fileSystem.DirectoryExists(oldLocalMetadataDirectory) && !_fileSystem.GetFiles(oldLocalMetadataDirectory).Any())
Expand Down
21 changes: 18 additions & 3 deletions MediaBrowser.Providers/Manager/ProviderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Net;
using System.Net.Http;
using System.Net.Mime;
using System.Runtime.ExceptionServices;
using System.Threading;
using System.Threading.Tasks;
using AsyncKeyedLock;
Expand Down Expand Up @@ -251,15 +252,29 @@ public Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType t
}

/// <inheritdoc/>
public Task SaveImage(BaseItem item, string source, string mimeType, ImageType type, int? imageIndex, bool? saveLocallyWithMedia, CancellationToken cancellationToken)
public async Task SaveImage(BaseItem item, string source, string mimeType, ImageType type, int? imageIndex, bool? saveLocallyWithMedia, CancellationToken cancellationToken)
{
if (string.IsNullOrWhiteSpace(source))
{
throw new ArgumentNullException(nameof(source));
}

var fileStream = AsyncFile.OpenRead(source);
return new ImageSaver(_configurationManager, _libraryMonitor, _fileSystem, _logger).SaveImage(item, fileStream, mimeType, type, imageIndex, saveLocallyWithMedia, cancellationToken);
try
{
var fileStream = AsyncFile.OpenRead(source);
await new ImageSaver(_configurationManager, _libraryMonitor, _fileSystem, _logger).SaveImage(item, fileStream, mimeType, type, imageIndex, saveLocallyWithMedia, cancellationToken);
}
finally
{
try
{
File.Delete(source);
}
catch (Exception ex)
{
_logger.LogError(ex, "Source file {Source} not found or in use, skip removing", source);
}
}
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public async Task<MetadataResult<Movie>> GetMetadata(MovieInfo info, Cancellatio
};

movie.SetProviderId(MetadataProvider.Tmdb, tmdbId);
movie.SetProviderId(MetadataProvider.Imdb, movieResult.ImdbId);
movie.TrySetProviderId(MetadataProvider.Imdb, movieResult.ImdbId);
if (movieResult.BelongsToCollection is not null)
{
movie.SetProviderId(MetadataProvider.TmdbCollection, movieResult.BelongsToCollection.Id.ToString(CultureInfo.InvariantCulture));
Expand Down
2 changes: 2 additions & 0 deletions tests/Jellyfin.Naming.Tests/TV/EpisodeNumberTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public class EpisodeNumberTests
[InlineData("Season 3/The Series S3 E9 - The title.avi", 9)]
[InlineData("Season 3/S003 E009.avi", 9)]
[InlineData("Season 3/Season 3 Episode 9.avi", 9)]
[InlineData("[VCB-Studio] Re Zero kara Hajimeru Isekai Seikatsu [21][Ma10p_1080p][x265_flac].mkv", 21)]
[InlineData("[CASO&Sumisora][Oda_Nobuna_no_Yabou][04][BDRIP][1920x1080][x264_AAC][7620E503].mp4", 4)]

// [InlineData("Case Closed (1996-2007)/Case Closed - 317.mkv", 317)] // triple digit episode number
// TODO: [InlineData("Season 2/16 12 Some Title.avi", 16)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ public async Task RefreshImages_EmptyItemPopulatedProviderDynamic_AddsImages(Ima
providerManager.Setup(pm => pm.SaveImage(item, It.IsAny<Stream>(), It.IsAny<string>(), imageType, null, It.IsAny<CancellationToken>()))
.Callback<BaseItem, Stream, string, ImageType, int?, CancellationToken>((callbackItem, _, _, callbackType, _, _) => callbackItem.SetImagePath(callbackType, 0, new FileSystemMetadata()))
.Returns(Task.CompletedTask);
providerManager.Setup(pm => pm.SaveImage(item, It.IsAny<string>(), It.IsAny<string>(), imageType, null, null, It.IsAny<CancellationToken>()))
.Callback<BaseItem, string, string, ImageType, int?, bool?, CancellationToken>((callbackItem, _, _, callbackType, _, _, _) => callbackItem.SetImagePath(callbackType, 0, new FileSystemMetadata()))
.Returns(Task.CompletedTask);
var itemImageProvider = GetItemImageProvider(providerManager.Object, null);
var result = await itemImageProvider.RefreshImages(item, libraryOptions, new List<IImageProvider> { dynamicProvider.Object }, refreshOptions, CancellationToken.None);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class UserManagerTests
[InlineData("this_is_valid")]
[InlineData("this is also valid")]
[InlineData("0@_-' .")]
[InlineData("Aa0@_-' .+")]
[InlineData("[email protected]")]
[InlineData("------@@@--+++----@@--abcdefghijklmn---------@----_-_-___-_ .9foo+")]
public void ThrowIfInvalidUsername_WhenValidUsername_DoesNotThrowArgumentException(string username)
{
var ex = Record.Exception(() => UserManager.ThrowIfInvalidUsername(username));
Expand Down

0 comments on commit fa474e6

Please sign in to comment.