Skip to content

Commit

Permalink
[server] allow specifying proxy for yt-dlp
Browse files Browse the repository at this point in the history
  • Loading branch information
redstonekasi committed Jul 2, 2024
1 parent a7593da commit 3eabd0d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions UwuRadio.Server/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public static Constants
/// </summary>
public string YtDlpPath { get; set; } = null!;

/// <summary>
/// Proxy that yt-dlp should use, empty for none
/// </summary>
public string YtDlpProxy { get; set; } = null!;

/// <summary>
/// Downloaded files are saved here and removed on app exit
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion UwuRadio.Server/Services/DownloadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private async void StartDownloading()
private static async Task<SongFileInfo> DownloadSong(string url)
{
var args
= $"\"{url}\" -O after_move:filepath --quiet --print-json -f bestaudio --extract-audio --audio-quality 0";
= $"--proxy \"{Constants.C.YtDlpProxy}\" \"{url}\" -O after_move:filepath --quiet --print-json -f bestaudio --extract-audio --audio-quality 0";

var (rawPath, durationStr) = await InvokeYtDlp(args);

Expand Down
1 change: 1 addition & 0 deletions UwuRadio.Server/constants.debug.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"PreloadTime": 30,
"ServerDlUrl": "http://localhost:5002/api/file/",
"YtDlpPath": "/usr/bin/yt-dlp",
"YtDlpProxy": "",
"CacheFolder": "DL_CACHE",
"IngestFolder": "../ingest",
"AudioFormat": "mp3",
Expand Down
3 changes: 2 additions & 1 deletion UwuRadio.Server/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"PreloadTime": 30,
"ServerDlUrl": "https://radio.k6.tf/api/file/",
"YtDlpPath": "yt-dlp",
"CacheFolder": "DL_CACHE",
"YtDlpProxy": "a.k6.tf:59414",
"CacheFolder": "../DL_CACHE",
"IngestFolder": "ingest",
"AudioFormat": "mp3",
"AudioQScale": "4",
Expand Down

0 comments on commit 3eabd0d

Please sign in to comment.