Browse Source

allow per-episode folders in local show libraries (#462)

* allow per-episode folders in local show libraries

* fix subfolder etag generation
pull/463/head
Jason Dove 5 years ago committed by GitHub
parent
commit
bda4117655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      CHANGELOG.md
  2. 27
      ErsatzTV.Core/Metadata/FolderEtag.cs
  3. 12
      ErsatzTV.Core/Metadata/TelevisionFolderScanner.cs
  4. 1
      docs/user-guide/local-libraries.md

6
CHANGELOG.md

@ -13,7 +13,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- When streaming is attempted during an unscheduled gap, the resulting video will be determined using the following priority: - When streaming is attempted during an unscheduled gap, the resulting video will be determined using the following priority:
- Channel fallback filler - Channel fallback filler
- Global fallback filler - Global fallback filler
- Generated `Channel Is Offline` error message video - Generated `Channel Is Offline` error message video
### Changed
- Allow per-episode folders for local show libraries
- e.g. `Show Name\Season #\Episode #\Show Name - s#e#.mkv`
## [0.2.1-alpha] - 2021-10-24 ## [0.2.1-alpha] - 2021-10-24
### Fixed ### Fixed

27
ErsatzTV.Core/Metadata/FolderEtag.cs

@ -31,5 +31,32 @@ namespace ErsatzTV.Core.Metadata
return hash.ToString(); return hash.ToString();
} }
public static string CalculateWithSubfolders(string folder, ILocalFileSystem localFileSystem)
{
IEnumerable<string> allFiles = localFileSystem.ListFiles(folder);
var sb = new StringBuilder();
foreach (string file in allFiles.OrderBy(identity))
{
sb.Append(file);
sb.Append(localFileSystem.GetLastWriteTime(file).Ticks);
}
foreach (string subfolder in localFileSystem.ListSubdirectories(folder).OrderBy(identity))
{
sb.Append(subfolder);
sb.Append(Calculate(subfolder, localFileSystem));
}
var hash = new StringBuilder();
byte[] bytes = Crypto.ComputeHash(Encoding.UTF8.GetBytes(sb.ToString()));
foreach (byte t in bytes)
{
hash.Append(t.ToString("x2"));
}
return hash.ToString();
}
} }
} }

12
ErsatzTV.Core/Metadata/TelevisionFolderScanner.cs

@ -159,7 +159,7 @@ namespace ErsatzTV.Core.Metadata
foreach (string seasonFolder in _localFileSystem.ListSubdirectories(showFolder).Filter(ShouldIncludeFolder) foreach (string seasonFolder in _localFileSystem.ListSubdirectories(showFolder).Filter(ShouldIncludeFolder)
.OrderBy(identity)) .OrderBy(identity))
{ {
string etag = FolderEtag.Calculate(seasonFolder, _localFileSystem); string etag = FolderEtag.CalculateWithSubfolders(seasonFolder, _localFileSystem);
Option<LibraryFolder> knownFolder = libraryPath.LibraryFolders Option<LibraryFolder> knownFolder = libraryPath.LibraryFolders
.Filter(f => f.Path == seasonFolder) .Filter(f => f.Path == seasonFolder)
.HeadOrNone(); .HeadOrNone();
@ -208,10 +208,16 @@ namespace ErsatzTV.Core.Metadata
Season season, Season season,
string seasonPath) string seasonPath)
{ {
foreach (string file in _localFileSystem.ListFiles(seasonPath) var allSeasonFiles = _localFileSystem.ListSubdirectories(seasonPath)
.Map(_localFileSystem.ListFiles)
.Flatten()
.Append(_localFileSystem.ListFiles(seasonPath))
.Filter(f => VideoFileExtensions.Contains(Path.GetExtension(f))) .Filter(f => VideoFileExtensions.Contains(Path.GetExtension(f)))
.Filter(f => !Path.GetFileName(f).StartsWith("._")) .Filter(f => !Path.GetFileName(f).StartsWith("._"))
.OrderBy(identity)) .OrderBy(identity)
.ToList();
foreach (string file in allSeasonFiles)
{ {
// TODO: figure out how to rebuild playlists // TODO: figure out how to rebuild playlists
Either<BaseError, Episode> maybeEpisode = await _televisionRepository Either<BaseError, Episode> maybeEpisode = await _televisionRepository

1
docs/user-guide/local-libraries.md

@ -34,6 +34,7 @@ The `Shows` library requires show and season subfolders. The following is a (non
- `Show (1999)\Season 01\Show - S01E01.mp4` - `Show (1999)\Season 01\Show - S01E01.mp4`
- `Show\Season 1\Show - s1e1.mp4` - `Show\Season 1\Show - s1e1.mp4`
- `Show\Season 1\Episode 1\Show - s1e1.mp4`
### Show NFO Metadata ### Show NFO Metadata

Loading…
Cancel
Save