More changes to add Torrents automatically; Modified cache to 8 days; Modified season finale lookups for edge case

This commit is contained in:
2026-10-24 14:37:51 -04:00
parent 32aca8b197
commit dcadf31192
5 changed files with 164 additions and 4 deletions
@@ -0,0 +1,35 @@
using System.Text.RegularExpressions;
namespace AnimeAnnouncer.Torrents
{
public static class TorrentDirectoryNamer
{
/// <summary>
/// Turns a release title into a dotted directory name, stripping the episode number
/// (keeping the resolution) and any trailing parenthesised suffix.
/// e.g. "Show Name S01E05 1080p WEB (Group)" -> "Show.Name.S01.1080p.WEB"
/// </summary>
public static String FromTitle(String title)
{
String name = title.Trim();
name = Regex.Replace(name, @"E\d{2,3}.*?(\d{3,4}p)", " $1");
name = Regex.Replace(name, @"\s\(.*?\)$", "");
return name.Replace(" ", ".");
}
public static String PrepareForURI(String title)
{
var titlePart = Regex.Replace(title, @"[^\w\s]+", String.Empty);
titlePart = Regex.Replace(titlePart, @"\s+", "+");
return titlePart;
}
/// <summary>
/// Builds the full save path for a release title under <paramref name="destinationFolder"/>.
/// </summary>
public static String FromTitle(String title, String destinationFolder)
{
return destinationFolder + (destinationFolder.EndsWith("/") ? String.Empty : "/") + FromTitle(title);
}
}
}