Skip to content

Commit

Permalink
Merge master into kick-support (#880)
Browse files Browse the repository at this point in the history
* Triple click template problem (#786)

* Revert "Remove triple click from URL mass downloader text box (#783)"

This reverts commit 559e5d9.

* remove template override?

* Revert "remove template override?"

This reverts commit 499c88d.

* kinda

* better?

* some layout stuff

* cleanup; w/s + center button

* cleanup

* format

* review comments: remove redundant

* visual order

* review feedback: remove template setter on other windows/pages

* review feedback: space between elements

* Account for alternate video highlight url format (#788)

* Account for alternate video highlight url format, increase maintainability of video/clip id regex matching

* Reuse code

* Remove working directory override in CLI (#793)

Fixes an issue with relative paths in MacOS

* Fix WPF crash due to system theme watcher related COMExceptions (#796)

* Catch potential ExternalExceptions when starting WindowsThemeService

* Rename locale key TaskError to TaskErrorButton

* Decorate some windows only functions with SupportedOSPlatformAttribute

* Fix comment

* Do not render sub/highlight backgrounds in transparent renders (#799)

* Compile PayingForward & ChannelPointHighlight colors as SKColors instead of using SKColor.Parse at runtime.

* Do not draw subscribe/misc highlight background if the message background is not opaque enough.

* Fix boolean logic

* WPF Chat Updater Fatal Error Fixes  (#803)

* Do not enable chatupdater buttons until chat json is fully loaded & catch deserialization exceptions.
Fixes a crash when loading large chats

* Catch potential exceptions when setting up chatupdater video/clip info & fix potential for thumbnail image to not update between chats

* Fix potential false positive success from TryGetThumb

* Document exceptions from ChatJson.DeserializeAsync

* Videodownload 99% stop fix (#792)

* Delay ThrottledStream stopwatch creation to first read

* Fix incorrect step for Finalizing Video

* Use CancellationTokenSource timers to cancel DownloadFileAsync after a minimum amount of time

* Bump timeout from 30 seconds to 60

* Add comment explaining CTS trickery

* Increase maxRestartedThreads

* Fix CLI FFmpeg download percentage

* Cleanup GetThirdPartyEmotes

* Change signatures of GetServiceEmoteData & add CancellationTokens

* Add Nullable annotation to Core & WPF

* Rename GetServiceEmoteData -> GetServiceEmotesMetadata

* Whoops, forgot to stage

* Disable nullable ref types for now

* A little bit of cleanup & fix potential url list crash

* Spelling fixes (#814)

* Add support for dark title bars on Windows 10 1809-2004  (#815)

* Support dark title bar on Windows 10 versions between 1809 and 2004 (20H1)

* Decided I prefer having it in this file

* Fix incorrect message.bits_spent for chats between v5 shutdown and 1.51.2 (#817)

* Cleanup

* Include VOD description in video metadata if present (#822)

* Add video description to fetch query

* Serialize video description if applicable

* Sanitize line feeds

* Add video description to chat json files

* Increase "old" directory threshold to 7 days

* Fix some theme related crashes (#831)

* Fix crash when app themes fail to extract

* More appropriate name

* Catch potential FormatExceptions when converting theme color strings to brushes

* Nuget upgrade (#804)

* Bump SkiaSharp to 2.88.5

* Bump HarfBuzzSharp to 2.8.2.5

* Bump Autoupdater.NET to 1.8.4

* Experiment with removing dedicated AlpineLinux SkiaSharp package

* Bump SkiaSharp to 2.88.6 & HarfBuzzSharp to 7.3.0

* Fix duplicate newlines and double spaces in video descriptions

* Quality of life GUI improvements (#833)

* Use URIs so thumbnails are actually cached for reuse

* Add design time DataContext to PageQueue and WindowMassDownload

* Add loading animation to WindowMassDownload

* Fix wrong border color on bandwidth throttle checkbox

* Combine CheckThrottleEnabled Checked functions

* Tabs -> spaces

* Apparently this wasn't entirely necessary

* Increase code readability

* Use ThumbnailService in WindowUrlList & add more video metadata

* Start cleaning up WindowQueueOptions

* Use Nullable.GetValueOrDefault everywhere & general cleanup

* Refactor WindowQueueOptions to be a little bit easier to follow

* Add videos per page selector to mass downloaders (#837)

* Add "videos per page" selector to mass downloader windows

* Update translations

* Remove unused imports

* Update Strings.tr.resx (#836)

Co-authored-by: Scrub <[email protected]>

* update spanish translation (#801)

* Update Strings.es.resx

* Create Readme_es.md

* Rename Readme_es.md to README_es.md

* Update README.md

* Update Strings.es.resx

* Add some NotNullWhen attributes

* Remove explicit copyright year

* Better FFmpeg download progress reporting (#840)

* Add FFmpeg download progress reporting to WPF

* Update translations

* Move expensive console writing off of FFmpeg download thread.

* Bump version

* Fix oversight
I need to enable nullable ref types :/

* Spanish translation update (#842)

* Bump version

* Fix old chats with stringified streamer ids being undeserializable (#843)

* Simplify ChatRootVersion

* Fix chats enqueued by the mass downloaders incorrectly having `.json` file extension

* I promise this is the last time I touch the dark title bar code

* Reuse the theme switcher brush converter

* Fix crash due to negative caret index when computing text box triple click.
Fixes #854

* minor translation additions (#853)

* Update Strings.tr.resx

* Create README_tr.md

* Update README.md

* Update build instructions

* Support highlighting new bit badge notifications (#869)

* Simplify icon generation

* Cleanup

* Add support for bit badge tier notifications

* More simplification

* Even more simplification

* Add Ukrainian Translation (#870)

* Ukrainian Translation

* fix comma

* Fix chat jsons and mp4 metadata lacking any chapters for VODs with 1 chapter and clips (#875)

* Create GetOrGenerateVideoChapters and update GetVideoInfo query

* Make ChatDownloader & VideoDownloader use GetOrGenerateVideoChapters

* Use the same Game object for Video & Clip info responses

* Generate a bogus chapter for clips

* Add context menu to video/clip search mass downloaders (#876)

* Add context menu to mass downloaders

* Update TaskData

* Update translations

* Deserialize chat json files without relying on the file extension (#858)

* Deserialize chat json files without relying on the file extension
This fixes a huge issue with the chat updater that somehow went unnoticed
This also enables deserializing UTF16 BOM and UTF32 BOM files

* Thanks Rider

* Many chat updater fixes (#859)

* Fix incorrect percentages in chat updater

* Make crop lock object not static

* Update video info if possible when updating chats

* Compress chat crop updater temp files with gzip

* Fix ArgumentOutOfRangeException when loading information from chat files with less than 2 comments

* Add functionality to deserialize only the first and last comments

* Fix chapter updating

* Clean curl buffer before returning

* Clean all the buffers, reduce ProgressCopyToAsync overhead, reduce maximum space used when downloading Kick clips

* Change all FileShare.None to FileShare.Read
Could help for debugging lockups

* Fix memory leak

* Forgot to stage

* This is handled by SetHandleAsInvalid

* Fix

---------

Co-authored-by: Christopher Stelma <[email protected]>
Co-authored-by: Matthew Davis <[email protected]>
Co-authored-by: Mahmut Sözen <[email protected]>
Co-authored-by: DeciBelioS <[email protected]>
Co-authored-by: Eugene <[email protected]>
  • Loading branch information
6 people authored Nov 15, 2023
1 parent 55d5ba6 commit 7a5711b
Show file tree
Hide file tree
Showing 106 changed files with 3,188 additions and 1,421 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2019 lay295
Copyright (c) lay295

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
</p>
</p>

[**Readme in Spanish**](README_es.md)
[**Readme in Spanish**](README_es.md)
[**Readme in Turkish**](README_tr.md)

## Chat Render Example

Expand Down Expand Up @@ -159,6 +160,7 @@ cd TwitchDownloader
```
dotnet restore
```
- Non-Windows devices may need to explicitly specify a project to restore, i.e. `dotnet restore TwitchDownloaderCLI`
4. a) Build the GUI:
```
dotnet publish TwitchDownloaderWPF -p:PublishProfile=Windows -p:DebugType=None -p:DebugSymbols=false
Expand Down
198 changes: 198 additions & 0 deletions README_tr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
<p align="center">
<a href="https://github.com/lay295/TwitchDownloader">
<img src="TwitchDownloaderWPF/Images/Logo.png" alt="Logo" width="80" height="80">
</a>

<h3 align="center">Twitch İndirici</h3>

<p align="center">
Twitch VOD/Clip/Chat İndirici ve Chat Oynatıcı
<br />
<br />
<a href="https://github.com/lay295/TwitchDownloader/issues">Hata Bildir</a>
</p>
</p>

[**İspanyolca'da Oku**](README_es.md)
[**İngilizce'de Oku**](README.md)

## Chat Oynatma Örneği

https://user-images.githubusercontent.com/1060681/197653099-c3fd12c2-f03a-4580-84e4-63ce3f36be8d.mp4

## Neler Yapabilir?

- Twitch VOD'larını İndir
- Twitch Kliplerini İndir
- VOD'lar ve Klipler için sohbeti, ya [tüm orijinal bilgileri içeren bir JSON olarak](https://pastebin.com/raw/YDgRe6X4), bir tarayıcı HTML dosyası olarak ya da [düz metin dosyası olarak](https://pastebin.com/raw/016azeQX) indirin.
- Daha önce oluşturulmuş bir JSON sohbet dosyasının içeriğini güncelleyin ve başka bir biçimde kaydetme seçeneğiyle kaydedin.
- Daha önce oluşturulmuş bir JSON sohbet dosyasını kullanarak sohbeti Twitter Twemoji veya Google Noto Color emojileri ve BTTV, FFZ, 7TV statik ve animasyonlu emojilerle oynatmak için kullanın.

# GUI

## Windows WPF

![](https://i.imgur.com/bLegxGX.gif)

### [Full WPF belgelerini buradan görüntüleyin](TwitchDownloaderWPF/README.md).

### İşlevsellik

Windows WPF GUI, programın tüm ana işlevlerini ve bazı ek yaşam kalitesi işlevlerini uygular:
- Aynı anda çalıştırılacak birden fazla indirme/oynatma işini sıraya alın.
- VOD/Klip bağlantıları listesinden indirme işlerinin bir listesini oluşturun.
- Uygulamayı terk etmeden herhangi bir yayıcıdan birden fazla VOD/klip arayın ve indirin.

### Çoklu Dil Desteği

Windows WPF GUI, topluluk çevirileri sayesinde birçok dilde kullanılabilir. Daha fazla ayrıntı için [WPF README](TwitchDownloaderWPF/README.md)'nin [Yerelleştirme bölümüne](TwitchDownloaderWPF/README.md#localization) bakın.

### Temalar

Windows WPF GUI, hem açık hem de karanlık temalar ile gelir ve mevcut Windows temasına göre canlı olarak güncelleme seçeneği sunar. Ayrıca kullanıcı tarafından oluşturulan temaları destekler! Daha fazla ayrıntı için [WPF README](TwitchDownloaderWPF/README.md)'nin [Tema bölümüne](TwitchDownloaderWPF/README.md#theming) bakın.

### Video Gösterimi

https://www.youtube.com/watch?v=0W3MhfhnYjk
(eski sürüm, aynı konsept)

## Linux?

***Nasıl cevireceğimi bilemedim terminal versionu var [githubda](https://github.com/mohad12211/twitch-downloader-gui) gidin ona bakın diyor kısaca birde [AUR'da](https://aur.archlinux.org/packages/twitch-downloader-gui) terminalin biraz süslü gui hali var ona bakabilirsniiz diyor.

## MacOS?

Malesef MacOS için henüz bir GUI mevcut değil :(

# CLI

### [Tüm CLI belgelerini buradan inceleyin](TwitchDownloaderCLI/README.md).

CLI, ana program işlevlerini uygulayan ve Windows, Linux ve MacOS<sup>*</sup> üzerinde çalışan çapraz platformlu bir araçtır.

<sup>*Sadece Intel Mac'ler test edilmiştir</sup>

CLI ile, harici komut dosyalarını kullanarak video işleme işlemini otomatikleştirmek mümkündür. Örneğin, Windows'ta bir `.bat` dosyasına aşağıdaki kodu kopyalayarak bir VOD'u ve onun sohbetini indirebilir ve ardından sohbeti renderlayabilirsiniz.
```bat
@echo off
set /p vodid="VOD Kimliğini Girin: "
TwitchDownloaderCLI.exe videodownload --id %vodid% --ffmpeg-path "ffmpeg.exe" -o %vodid%.mp4
TwitchDownloaderCLI.exe chatdownload --id %vodid% -o %vodid%_chat.json -E
TwitchDownloaderCLI.exe chatrender -i %vodid%_chat.json -h 1080 -w 422 --framerate 30 --update-rate 0 --font-size 18 -o %vodid%_chat.mp4
```

## Windows - Başlangıç

1. [Releases-Sürümler](https://github.com/lay295/TwitchDownloader/releases/) sayfasına gidin ve en son Windows sürümünü indirin veya [kaynaktan derleyin.](#building-from-source).
2. `TwitchDownloaderCLI.exe`'yi çıkartın.
3. Dosyayı çıkardığınız yerde terminal açın.
4. FFmpeg'e sahip değilseniz,[Chocolatey package manager](https://community.chocolatey.org/) aracılığı ile indirebilir veya bağımsız bir dosya olarak [ffmpeg.org](https://ffmpeg.org/download.html) adresinden alabilir veya TwitchDownloaderCLI kullanarak alabilirsiniz. Şu komutu kullanarak indirebilirsiniz:
```
TwitchDownloaderCLI.exe ffmpeg --download
```
5. Artık indirme işlemine başlayabilirsiniz, örneğin:
```
TwitchDownloaderCLI.exe videodownload --id <vod-id-here> -o out.mp4
```

## Linux – Başlangıç

1. Bazı dağıtımlar, Linux Alpine gibi, bazı diller için (Arapça, Farsça, Tayca vb.) yazı tiplerini eksik bulabilir. Bu durum sizin için geçerliyse, [Noto](https://fonts.google.com/noto/specimen/Noto+Sans) gibi ek yazı tipleri ailesi yükleyin veya dağıtımınızın yazı tipleri hakkındaki wiki sayfasını kontrol edin, çünkü bu özel senaryo için bir kurulum komutuna sahip olabilir, örneğin [Linux Alpine](https://wiki.alpinelinux.org/wiki/Fonts) yazı tipi sayfası gibi.
2. `fontconfig` ve `libfontconfig1`'in yüklü olduğundan emin olun. Ubuntu'da `apt-get install fontconfig libfontconfig1` kullanabilirsiniz.
3. [Sürümler](https://github.com/lay295/TwitchDownloader/releases/) sayfasına gidin ve Linux için en son ikili sürümü indirin, Arch Linux için [AUR Paketi](https://aur.archlinux.org/packages/twitch-downloader-bin/)ni alın veya [kaynaktan derleyin](#building-from-source).
4. `TwitchDownloaderCLI`'yi çıkarın.
5. Dosyayı çıkardığınız yere gidin ve terminalde çalıştırılabilir izinleri verin:
```
sudo chmod +x TwitchDownloaderCLI
```
6. a) Eğer FFmpeg'e sahip değilseniz, bunu dağıtım paket yöneticiniz aracılığıyla kurmalısınız. Ayrıca, [ffmpeg.org](https://ffmpeg.org/download.html) adresinden bağımsız bir dosya olarak veya TwitchDownloaderCLI kullanarak da edinebilirsiniz.
```
./TwitchDownloaderCLI ffmpeg --download
```
6. b) Bağımsız bir dosya olarak indirildiyse, ona çalıştırılabilir izinler vermelisiniz:
```
sudo chmod +x ffmpeg
```
7. Şimdi indiriciyi kullanmaya başlayabilirsiniz, örneğin:
```
./TwitchDownloaderCLI videodownload --id <vod-id-here> -o out.mp4
```
## MacOS – Başlangıç
1. [Releases](https://github.com/lay295/TwitchDownloader/releases/) sayfasına gidin ve MacOS için en son sürümü indirin veya kaynaktan derleyin.
2. `TwitchDownloaderCLI` dosyasını çıkarın.
3. Dosyayı çıkardığınız yere terminalde çalıştırılabilir izinler verin.
```
chmod +x TwitchDownloaderCLI
```
4. a) Eğer FFmpeg'e sahip değilseniz, [Homebrew paket yöneticisi](https://brew.sh/) aracılığıyla kurabilirsiniz veya bağımsız bir dosya olarak [ffmpeg.org](https://ffmpeg.org/download.html) adresinden veya TwitchDownloaderCLI kullanarak edinebilirsiniz.
```
./TwitchDownloaderCLI ffmpeg --download
```
4. b) Bağımsız bir dosya olarak indirildiyse, ona çalıştırılabilir izinler vermelisiniz.
```
chmod +x ffmpeg
```
5. Şimdi indiriciyi kullanmaya başlayabilirsiniz, örneğin:
```
./TwitchDownloaderCLI videodownload --id <vod-id-here> -o out.mp4
```

# Kaynaktan derleme

## Gereksinimler

- [.NET 6.0.x SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)

## Derleme Talimatları

1. Depoyu klonlayın:
```
git clone https://github.com/lay295/TwitchDownloader.git
```
2. Çözüm klasörüne gidin:
```
cd TwitchDownloader
```
3. Çözümü geri yükleyin:
```
dotnet restore
```
4. a) GUI'yi oluşturun:
```
dotnet publish TwitchDownloaderWPF -p:PublishProfile=Windows -p:DebugType=None -p:DebugSymbols=false
```
4. b) CLI'yi oluşturun:
```
dotnet publish TwitchDownloaderCLI -p:PublishProfile=<Profile> -p:DebugType=None -p:DebugSymbols=false
```
- Uygulanabilir Profiller: `Windows`, `Linux`, `LinuxAlpine`, `LinuxArm`, `LinuxArm64`, `MacOS`
5. a) GUI derleme klasörüne gidin:
```
cd TwitchDownloaderWPF/bin/Release/net6.0-windows/publish/win-x64
```
5. b) CLI derleme klasörüne gidin:
```
cd TwitchDownloaderCLI/bin/Release/net6.0/publish
```

# Lisans

[MIT](./LICENSE.txt)

# Üçüncü Taraf Kredileri

Sohbet Görüntülemeleri, [SkiaSharp ve HarfBuzzSharp](https://github.com/mono/SkiaSharp) tarafından oluşturulmuştur © Microsoft Corporation.

Sohbet Görüntülemeleri işlenmesi ve Video İndirmeleri [FFmpeg](https://ffmpeg.org/) ile sonlandırılır © FFmpeg geliştiricileri.

Sohbet Görüntülemeleri, [Noto Renkli Emoji](https://github.com/googlefonts/noto-emoji) tarafından kullanılabilir © Google ve katkıda bulunanlar.

Sohbet Görüntülemeleri, [Twemoji](https://github.com/twitter/twemoji) tarafından kullanılabilir © Twitter ve katkıda bulunanlar.

Paketlenmiş FFmpeg ikili dosyaları [gyan.dev](https://www.gyan.dev/ffmpeg/) adresinden alınmıştır © Gyan Doshi.

Alınan FFmpeg ikili dosyaları çalışma zamanında [Xabe.FFmpeg.Downloader](https://github.com/tomaszzmuda/Xabe.FFmpeg) kullanılarak indirilir © Xabe.

Sohbet HTML dışa aktarmaları, [Google Fonts API](https://fonts.google.com/) tarafından barındırılan _Inter_ yazı tipini kullanır © Google.

Kullanılan tüm harici kütüphanelerin tam listesi için [THIRD-PARTY-LICENSES.txt](./TwitchDownloaderCore/Resources/THIRD-PARTY-LICENSES.txt) dosyasına bakınız.
1 change: 0 additions & 1 deletion TwitchDownloaderCLI/Modes/Arguments/CacheArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace TwitchDownloaderCLI.Modes.Arguments
{

[Verb("cache", HelpText = "Manage the working cache")]
public class CacheArgs : ITwitchDownloaderArgs
{
Expand Down
8 changes: 4 additions & 4 deletions TwitchDownloaderCLI/Modes/Arguments/ChatDownloadArgs.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using CommandLine;
using TwitchDownloaderCore.Chat;
using TwitchDownloaderCore.Tools;

namespace TwitchDownloaderCLI.Modes.Arguments
{

[Verb("chatdownload", HelpText = "Downloads the chat from a VOD or clip")]
public class ChatDownloadArgs : ITwitchDownloaderArgs
{
Expand All @@ -21,16 +21,16 @@ public class ChatDownloadArgs : ITwitchDownloaderArgs

[Option('e', "ending", HelpText = "Time in seconds to crop ending.")]
public double CropEndingTime { get; set; }

[Option('E', "embed-images", Default = false, HelpText = "Embed first party emotes, badges, and cheermotes into the chat download for offline rendering.")]
public bool EmbedData { get; set; }

[Option("bttv", Default = true, HelpText = "Enable BTTV embedding in chat download. Requires -E / --embed-images!")]
public bool? BttvEmotes { get; set; }

[Option("ffz", Default = true, HelpText = "Enable FFZ embedding in chat download. Requires -E / --embed-images!")]
public bool? FfzEmotes { get; set; }

[Option("stv", Default = true, HelpText = "Enable 7TV embedding in chat download. Requires -E / --embed-images!")]
public bool? StvEmotes { get; set; }

Expand Down
1 change: 0 additions & 1 deletion TwitchDownloaderCLI/Modes/Arguments/ChatRenderArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace TwitchDownloaderCLI.Modes.Arguments
{

[Verb("chatrender", HelpText = "Renders a chat JSON as a video")]
public class ChatRenderArgs : ITwitchDownloaderArgs
{
Expand Down
3 changes: 1 addition & 2 deletions TwitchDownloaderCLI/Modes/Arguments/ChatUpdateArgs.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using CommandLine;
using TwitchDownloaderCore.Chat;
using TwitchDownloaderCore.Tools;

namespace TwitchDownloaderCLI.Modes.Arguments
{

[Verb("chatupdate", HelpText = "Updates the embedded emotes, badges, bits, and crops of a chat download and/or converts a JSON chat to another format.")]
public class ChatUpdateArgs : ITwitchDownloaderArgs
{
Expand Down
1 change: 0 additions & 1 deletion TwitchDownloaderCLI/Modes/Arguments/ClipDownloadArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace TwitchDownloaderCLI.Modes.Arguments
{

[Verb("clipdownload", HelpText = "Downloads a clip from Twitch")]
public class ClipDownloadArgs : ITwitchDownloaderArgs
{
Expand Down
1 change: 0 additions & 1 deletion TwitchDownloaderCLI/Modes/Arguments/FfmpegArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace TwitchDownloaderCLI.Modes.Arguments
{

[Verb("ffmpeg", HelpText = "Manage standalone ffmpeg")]
public class FfmpegArgs : ITwitchDownloaderArgs
{
Expand Down
1 change: 0 additions & 1 deletion TwitchDownloaderCLI/Modes/Arguments/VideoDownloadArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace TwitchDownloaderCLI.Modes.Arguments
{

[Verb("videodownload", HelpText = "Downloads a stream VOD from Twitch")]
public class VideoDownloadArgs : ITwitchDownloaderArgs
{
Expand Down
12 changes: 5 additions & 7 deletions TwitchDownloaderCLI/Modes/DownloadChat.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using System;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using TwitchDownloaderCLI.Modes.Arguments;
using TwitchDownloaderCLI.Tools;
using TwitchDownloaderCore;
using TwitchDownloaderCore.Chat;
using TwitchDownloaderCore.Options;
using TwitchDownloaderCore.Tools;
using TwitchDownloaderCore.VideoPlatforms.Interfaces;
using TwitchDownloaderCore.VideoPlatforms.Twitch.Downloaders;

namespace TwitchDownloaderCLI.Modes
{
Expand All @@ -32,9 +30,7 @@ private static ChatDownloadOptions GetDownloadOptions(ChatDownloadArgs inputOpti
Environment.Exit(1);
}

var vodClipIdRegex = new Regex(@"(?<=^|(?:clips\.)?twitch\.tv\/(?:videos|\S+\/clip)?\/?)[\w-]+?(?=$|\?)");
var vodClipIdMatch = vodClipIdRegex.Match(inputOptions.Id);
if (!vodClipIdMatch.Success)
if (!UrlParse.TryParseVideoOrClipId(inputOptions.Id, out var videoPlatform, out var videoType, out var videoId))
{
Console.WriteLine("[ERROR] - Unable to parse Vod/Clip ID/URL.");
Environment.Exit(1);
Expand All @@ -51,7 +47,9 @@ private static ChatDownloadOptions GetDownloadOptions(ChatDownloadArgs inputOpti
".txt" or ".text" or "" => ChatFormat.Text,
_ => throw new NotSupportedException($"{fileExtension} is not a valid chat file extension.")
},
Id = vodClipIdMatch.Value,
Id = videoId,
VideoPlatform = videoPlatform,
VideoType = videoType,
CropBeginning = inputOptions.CropBeginningTime > 0.0,
CropBeginningTime = inputOptions.CropBeginningTime,
CropEnding = inputOptions.CropEndingTime > 0.0,
Expand Down
4 changes: 1 addition & 3 deletions TwitchDownloaderCLI/Modes/DownloadClip.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using TwitchDownloaderCLI.Modes.Arguments;
using TwitchDownloaderCLI.Tools;
Expand Down Expand Up @@ -38,8 +37,7 @@ private static ClipDownloadOptions GetDownloadOptions(ClipDownloadArgs inputOpti
Environment.Exit(1);
}

bool success = UrlParse.TryParseClip(inputOptions.Id, out VideoPlatform videoPlatform, out string videoId);
if (!success)
if (!UrlParse.TryParseClip(inputOptions.Id, out var videoPlatform, out var videoId))
{
Console.WriteLine("[ERROR] - Unable to parse Clip ID/URL.");
Environment.Exit(1);
Expand Down
10 changes: 4 additions & 6 deletions TwitchDownloaderCLI/Modes/DownloadVideo.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using System;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using TwitchDownloaderCLI.Modes.Arguments;
using TwitchDownloaderCLI.Tools;
using TwitchDownloaderCore;
using TwitchDownloaderCore.Options;
using TwitchDownloaderCore.Tools;
using TwitchDownloaderCore.VideoPlatforms.Interfaces;
using TwitchDownloaderCore.VideoPlatforms.Twitch.Downloaders;

namespace TwitchDownloaderCLI.Modes
{
Expand All @@ -34,9 +33,7 @@ private static VideoDownloadOptions GetDownloadOptions(VideoDownloadArgs inputOp
Environment.Exit(1);
}

var vodIdRegex = new Regex(@"(?<=^|twitch\.tv\/videos\/)\d+(?=$|\?)");
var vodIdMatch = vodIdRegex.Match(inputOptions.Id);
if (!vodIdMatch.Success)
if (UrlParse.TryParseVod(inputOptions.Id, out var videoPlatform, out var videoId))
{
Console.WriteLine("[ERROR] - Unable to parse Vod ID/URL.");
Environment.Exit(1);
Expand All @@ -46,7 +43,8 @@ private static VideoDownloadOptions GetDownloadOptions(VideoDownloadArgs inputOp
{
DownloadThreads = inputOptions.DownloadThreads,
ThrottleKib = inputOptions.ThrottleKib,
Id = vodIdMatch.ValueSpan.ToString(),
Id = videoId,
VideoPlatform = videoPlatform,
Oauth = inputOptions.Oauth,
Filename = inputOptions.OutputFile,
Quality = inputOptions.Quality,
Expand Down
Loading

0 comments on commit 7a5711b

Please sign in to comment.