lay295 / TwitchDownloader

Twitch VOD/Clip Downloader - Chat Download/Render/Replay
MIT License
2.64k stars 260 forks source link

Fixes #848 add CLI mode to manually concatenate ts parts #888

Closed superbonaci closed 6 months ago

ScrubN commented 9 months ago

When kick-support gets merged, it will bring an M3U8 parser with it (among several other changes).

Either I can refactor this feature (and its documentation) after that is merged, or I can merge this now and a temporary disclaimer is added that explains that there may be breaking changes in the next version (1.53.6). Which would you prefer?

superbonaci commented 9 months ago

Merge it if you can, I think you can refactor later everything you need even add more features.

ScrubN commented 8 months ago

I decided to backport the M3U8 parser since kick-support still has some kinks to be ironed out. It should be pretty straight forward to use that instead of looping through a generic input file (and update the docs to reflect the change), however I am writing some extension methods right now to make it even easier for you.

superbonaci commented 8 months ago

Thanks for the merge. I can't confirm wether the CopyToAsync method does always perform a raw concatenation or not, I'll have to ask people with deeper knowledge than me. All the recent tests I did recently do it.

ScrubN commented 8 months ago

917 has been merged, so you should be able to replace:

string InputList = downloadOptions.InputList;
List<string> videoPartsList = System.IO.File.ReadLines(InputList).ToList();

with:

await using var fs = File.Open(downloadOptions.InputList, FileMode.Open, FileAccess.Read, FileShare.Read);
var m3u8 = M3U8.Parse(fs, Encoding.UTF8);

You may refer to VideoDownloader.cs on how to modify the other functions. Don't forget to mention the user should input .m3u/.m3u8 files in the documentation. Also, consider renaming downloadOptions to better reflect what type of options it is.

ScrubN commented 7 months ago

I decided to make some of the changes myself, I hope you don't mind.

I also realized that limiting the user to M3U/M3U8 files was dumb, as it just requires the user to do more research before using the tool.

ScrubN commented 6 months ago

Sorry this took so long to merge.