Skip to content

Commit 5b66254

Browse files
committed
Go from youtube-dl to yt-dlp (with a fixed known working version)
1 parent 80f5cd7 commit 5b66254

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

Application.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ namespace TwitchClipper
1111
public class Application
1212
{
1313
private readonly ITwitchAPIService _twitchService;
14-
private readonly IYouTubeDLService _youtubeDlService;
14+
private readonly IDownloaderService _downloaderService;
1515
private readonly IHostService _hostService;
1616
private readonly IGitHubUpdater _updater;
1717
private readonly IArchivingService _archivingService;
1818

19-
public Application(ITwitchAPIService twitchService, IYouTubeDLService youtubeDlService, IHostService hostService, IGitHubUpdater updater, IArchivingService archivingService)
19+
public Application(ITwitchAPIService twitchService, IDownloaderService downloaderService, IHostService hostService, IGitHubUpdater updater, IArchivingService archivingService)
2020
{
2121
_twitchService = twitchService;
22-
_youtubeDlService = youtubeDlService;
22+
_downloaderService = downloaderService;
2323
_hostService = hostService;
2424
_updater = updater;
2525
_archivingService = archivingService;
@@ -38,7 +38,7 @@ public async Task Run(Options options)
3838
//yes, placing this here is really bad. Please don't blame me
3939
await TestCustomPathExpression();
4040

41-
await _youtubeDlService.CheckYouTubeDLExists();
41+
await _downloaderService.CheckExecutableExists();
4242

4343
await _twitchService.EnsureAuthTokenSet();
4444

@@ -54,7 +54,7 @@ public async Task Run(Options options)
5454
await ErrorHelper.LogAndExit("No clips found in the given period.");
5555
}
5656

57-
await _youtubeDlService.DownloadClips(clips);
57+
await _downloaderService.DownloadClips(clips);
5858
}
5959

6060
private async Task TestCustomPathExpression()

Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private static IServiceCollection ConfigureServices()
126126
services.AddTransient<ITwitchAPIService, TwitchAPIService>();
127127
services.AddScoped<IConfigurationService, ConfigurationService>();
128128
services.AddScoped<ITwitchConfigurationService, TwitchConfigurationService>();
129-
services.AddTransient<IYouTubeDLService, YouTubeDLService>();
129+
services.AddTransient<IDownloaderService, DownloaderService>();
130130
services.AddScoped<IHostService, HostService>();
131131
services.AddSingleton<IFilteringService, FilteringService>();
132132
services.AddTransient<IGitHubUpdater, GitHubUpdater>();

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<hr>
77

8-
TwitchClipper is a .NET 5.0 cross platform compatible application, made to download https://twitch.tv clips. Downloading is done via [youtube-dl](https://yt-dl.org/), which will automatically be downloaded and saved in the project's folder.
8+
TwitchClipper is a .NET 5.0 cross platform compatible application, made to download https://twitch.tv clips. Downloading is done via [yt-dlp](https://github.com/yt-dlp/yt-dlp), which will automatically be downloaded and saved in the project's folder.
99

1010
```
1111
$ ./twitchclipper --username Asmongold --from 2021-05-01 --to 2021-06-01
@@ -59,7 +59,7 @@ There's a section called `TwitchConfiguration` you need to modify:
5959

6060
Replace `CLIENT_ID_GOES_HERE` and `CLIENT_SECRET_GOES_HERE` with your newly found values.
6161

62-
`DownloadThreads` spawns x amount of youtube-dl instances. The higher the number, the faster your download will be. I do not recommend going over 10, as you might get throttled by Twitch.
62+
`DownloadThreads` spawns x amount of yt-dlp instances. The higher the number, the faster your download will be. I do not recommend going over 10, as you might get throttled by Twitch.
6363

6464
Optionally you can also modify the `Download` section, if you want to customize where your clips are saved:
6565

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,33 @@
1212

1313
namespace TwitchClipper.Services
1414
{
15-
public interface IYouTubeDLService
15+
public interface IDownloaderService
1616
{
17-
Task CheckYouTubeDLExists();
17+
Task CheckExecutableExists();
1818
Task DownloadClips(List<TwitchClipModel> clips);
1919
}
2020

21-
public class YouTubeDLService : IYouTubeDLService
21+
public class DownloaderService : IDownloaderService
2222
{
2323
private readonly IHostService _hostService;
2424
private readonly ITwitchConfigurationService _twitchConfigurationService;
2525
private readonly IArchivingService _archivingService;
2626

27-
public YouTubeDLService(IHostService hostService, ITwitchConfigurationService twitchConfigurationService, IArchivingService archivingService)
27+
public DownloaderService(IHostService hostService, ITwitchConfigurationService twitchConfigurationService, IArchivingService archivingService)
2828
{
2929
_hostService = hostService;
3030
_twitchConfigurationService = twitchConfigurationService;
3131
_archivingService = archivingService;
3232
}
3333

34-
public async Task CheckYouTubeDLExists()
34+
public async Task CheckExecutableExists()
3535
{
36-
if (!File.Exists(await _hostService.GetYouTubeDlExecutablePath()))
36+
if (!File.Exists(await _hostService.GetDownloaderExecutablePath()))
3737
{
3838
ConsoleKey response;
3939
do
4040
{
41-
await LogHelper.Log("Seems like youtube-dl has not been found. Would you like me to download it for you? [y/n]");
41+
await LogHelper.Log("Seems like yt-dlp has not been found. Would you like me to download it for you? [y/n]");
4242
response = Console.ReadKey(false).Key;
4343

4444
if (response != ConsoleKey.Enter)
@@ -49,23 +49,23 @@ public async Task CheckYouTubeDLExists()
4949

5050
if (response == ConsoleKey.N)
5151
{
52-
await ErrorHelper.LogAndExit("You decided not to download youtube-dl, therefore the application must exit. youtube-dl is a requirement.");
52+
await ErrorHelper.LogAndExit("You decided not to download yt-dlp, therefore the application must exit. yt-dlp is a requirement.");
5353
}
5454
else if (response == ConsoleKey.Y)
5555
{
5656
await LogHelper.Log("Download starting");
5757

5858
using (var httpClient = new HttpClient())
59-
using (var httpResponse = await httpClient.GetAsync(await _hostService.GetYouTubeDlDownloadUrl()))
59+
using (var httpResponse = await httpClient.GetAsync(await _hostService.GetDownloaderDownloadUrl()))
6060
{
6161
if (httpResponse.IsSuccessStatusCode)
6262
{
63-
await File.WriteAllBytesAsync(await _hostService.GetYouTubeDlExecutablePath(), await httpResponse.Content.ReadAsByteArrayAsync());
63+
await File.WriteAllBytesAsync(await _hostService.GetDownloaderExecutablePath(), await httpResponse.Content.ReadAsByteArrayAsync());
6464

6565
//set magic executable permission on Linux and OSX.. very ugly
6666
if (!(await _hostService.GetOSPlatform() == OSPlatform.Windows))
6767
{
68-
await ProcessEx.RunAsync("/bin/bash", $"-c \"chmod +x {await _hostService.GetYouTubeDlExecutablePath()}\"");
68+
await ProcessEx.RunAsync("/bin/bash", $"-c \"chmod +x {await _hostService.GetDownloaderExecutablePath()}\"");
6969
}
7070
}
7171
}
@@ -95,7 +95,7 @@ await ParallelExtensions.ParallelForEachAsync(clips, async clip =>
9595
if (!File.Exists(path))
9696
{
9797
counter++;
98-
await ProcessEx.RunAsync(await _hostService.GetYouTubeDlExecutablePath(), $"{clip.Url} -o \"{path}\"");
98+
await ProcessEx.RunAsync(await _hostService.GetDownloaderExecutablePath(), $"{clip.Url} -o \"{path}\"");
9999
await LogHelper.Log($"Downloading clip {counter}/{nonExistingClips.Count} using {await _twitchConfigurationService.GetDownloadThreads()} download threads", asyncLock);
100100
}
101101
}, await _twitchConfigurationService.GetDownloadThreads());

Services/HostService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace TwitchClipper.Services
1212
{
1313
public interface IHostService
1414
{
15-
Task<string> GetYouTubeDlExecutablePath();
16-
Task<string> GetYouTubeDlDownloadUrl();
15+
Task<string> GetDownloaderExecutablePath();
16+
Task<string> GetDownloaderDownloadUrl();
1717
Task<OSPlatform> GetOSPlatform();
1818
Task CreateDirectoryIfNotExists(string path);
1919
Task<string> ConvertCustomPathExpressionToSavePath(TwitchClipModel model);
@@ -28,18 +28,18 @@ public HostService(IConfigurationService configService)
2828
_configService = configService;
2929
}
3030

31-
public async Task<string> GetYouTubeDlExecutablePath()
31+
public async Task<string> GetDownloaderExecutablePath()
3232
{
3333
var os = await GetOSPlatform();
3434

35-
return Path.Combine(Directory.GetCurrentDirectory(), await _configService.GetConfigurationValue<string>($"YouTubeDL:{os}:FileName"));
35+
return Path.Combine(Directory.GetCurrentDirectory(), await _configService.GetConfigurationValue<string>($"Downloader:{os}:FileName"));
3636
}
3737

38-
public async Task<string> GetYouTubeDlDownloadUrl()
38+
public async Task<string> GetDownloaderDownloadUrl()
3939
{
4040
var os = await GetOSPlatform();
4141

42-
return await Task.Run(() => _configService.GetConfigurationValue<string>($"YouTubeDL:{os}:Download"));
42+
return await Task.Run(() => _configService.GetConfigurationValue<string>($"Downloader:{os}:Download"));
4343
}
4444

4545
public async Task<OSPlatform> GetOSPlatform()

TwitchClipper.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Authors>mortenmoulder</Authors>
1212
<PackageProjectUrl>https://github.com/mortenmoulder/TwitchClipper</PackageProjectUrl>
1313
<RepositoryUrl>https://github.com/mortenmoulder/TwitchClipper</RepositoryUrl>
14-
<Version>1.0.7</Version>
14+
<Version>1.0.8</Version>
1515
</PropertyGroup>
1616

1717
<ItemGroup>

0 commit comments

Comments
 (0)