* fix yml formatting * test build action * move ci workflow * fix unit tests from dotnet test command * add release workflow * try another matrix syntax * fix path to csproj * fix target framework * more release fixes * port fixes for running outside of docker * more search fixes * improve fallback metadata parsing, add tests * fix odd behavior when searching collections * more fallback metadata fixes * refresh "other" metadata on startup
31 lines
988 B
C#
31 lines
988 B
C#
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
using ErsatzTV.Core.Domain;
|
|
|
|
namespace ErsatzTV.Core.Metadata
|
|
{
|
|
public static class FallbackMetadataProvider
|
|
{
|
|
public static MediaMetadata GetFallbackMetadata(string path)
|
|
{
|
|
string fileName = Path.GetFileName(path);
|
|
var metadata = new MediaMetadata { Title = fileName ?? path };
|
|
|
|
if (fileName != null)
|
|
{
|
|
const string PATTERN = @"^(.*?)[.\s-]+[sS](\d+)[eE](\d+).*\.\w+$";
|
|
Match match = Regex.Match(fileName, PATTERN);
|
|
if (match.Success)
|
|
{
|
|
metadata.MediaType = MediaType.TvShow;
|
|
metadata.Title = match.Groups[1].Value;
|
|
metadata.SeasonNumber = int.Parse(match.Groups[2].Value);
|
|
metadata.EpisodeNumber = int.Parse(match.Groups[3].Value);
|
|
}
|
|
}
|
|
|
|
return metadata;
|
|
}
|
|
}
|
|
}
|