Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ScrubN committed Feb 25, 2024
1 parent 719e3e4 commit 98a3771
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 2 additions & 0 deletions TwitchDownloaderCLI/Modes/MergeTs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ internal static class MergeTs
{
internal static void Merge(TsMergeArgs inputOptions)
{
Console.WriteLine("[INFO] The TS merger is experimental and is subject to change without notice in future releases.");

Progress<ProgressReport> progress = new();
progress.ProgressChanged += ProgressHandler.Progress_ProgressChanged;

Expand Down
7 changes: 2 additions & 5 deletions TwitchDownloaderCLI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,5 @@ For Linux users, ensure both `fontconfig` and `libfontconfig1` are installed. `a

Some distros, like Linux Alpine, lack fonts for some languages (Arabic, Persian, Thai, etc.) If this is the case for you, install additional fonts families such as [Noto](https://fonts.google.com/noto/specimen/Noto+Sans) or check your distro's wiki page on fonts as it may have an install command for this specific scenario, such as the [Linux Alpine](https://wiki.alpinelinux.org/wiki/Fonts) font page.

The list file for tsmerge can contain relative or absolute paths, but the path format differs from Windows to Linux/UNIX/MacOS (like volume paths or "/" instead of "\" to separate directories).
The list must be a text file and describe one ts path per line.

The concatenation made by tsmerge is not a raw (binary) concatenation, like `dd`, `cat` or `pv` would do on Linux, or `copy /b` on Windows.
Instead, the streams have to be partially recoded, to keep its structure valid and playable. Using other software may not achieve this result.
The list file for `tsmerge` may contain relative or absolute paths, with one path per line.
Alternatively, the list file may also be an M3U8 playlist file.
16 changes: 11 additions & 5 deletions TwitchDownloaderCore/TsMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,23 @@ public async Task MergeAsync(CancellationToken cancellationToken)
throw new FileNotFoundException("Input file does not exist");
}

var isM3U8 = false;
var fileList = new List<string>();
await using (var fs = File.Open(mergeOptions.InputFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
using var sr = new StreamReader(fs);
while (await sr.ReadLineAsync() is { } line)
{
if (string.IsNullOrWhiteSpace(line))
continue;
if (string.IsNullOrWhiteSpace(line)) continue;

if (line.StartsWith('#'))
continue;
if (isM3U8)
{
if (line.StartsWith('#')) continue;
}
else
{
if (line.StartsWith("#EXTM3U")) isM3U8 = true;
}

fileList.Add(line);
}
Expand Down Expand Up @@ -83,7 +89,7 @@ private async Task VerifyVideoParts(IReadOnlyCollection<string> fileList, Cancel
return;
}

_progress.Report(new ProgressReport(ReportType.Log, $"The following TS files appear to be invalid or corrupted: {string.Join(", ", failedParts)}"));
_progress.Report(new ProgressReport(ReportType.Log, $"The following TS files are invalid or corrupted: {string.Join(", ", failedParts)}"));
}
}

Expand Down

0 comments on commit 98a3771

Please sign in to comment.