Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build ytdlp-interface

on:
push:
branches: [ feat/github-token-auth ]
workflow_dispatch:

jobs:
build:
runs-on: windows-2022

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Extract dependencies
shell: pwsh
run: |
$deps = "ytdlp-interface dependencies.7z"
if (Test-Path $deps) {
7z x $deps -o. -y
Write-Host "Dependencies extracted successfully"
Get-ChildItem -Directory | ForEach-Object { Write-Host $_.Name }
} else {
Write-Error "Dependencies archive not found: $deps"
exit 1
}

- name: Add MSVC to PATH
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

- name: Build Release x64
shell: pwsh
run: |
cd ytdlp-interface
msbuild ytdlp-interface.vcxproj `
/p:Configuration=Release `
/p:Platform=x64 `
/p:PlatformToolset=v143 `
/p:WindowsTargetPlatformVersion=10.0 `
/m

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ytdlp-interface-x64
path: ytdlp-interface/Release/x64/ytdlp-interface.exe
if-no-files-found: error
18 changes: 9 additions & 9 deletions ytdlp-interface/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1876,7 +1876,7 @@ void GUI::get_releases(nana::window parent_for_msgbox)
thr_releases = std::thread {[parent_for_msgbox, this]
{
using json = nlohmann::json;
auto jtext {util::get_inet_res("https://api.github.com/repos/ErrorFlynn/ytdlp-interface/releases", &inet_error)};
auto jtext {util::get_inet_res("https://api.github.com/repos/ErrorFlynn/ytdlp-interface/releases", &inet_error, false, conf.github_token)};
if(!jtext.empty())
{
try { releases = json::parse(jtext); }
Expand Down Expand Up @@ -1956,8 +1956,8 @@ void GUI::get_latest_ffmpeg(nana::window parent_for_msgbox)
{
std::string jtext;
if(win7)
jtext = util::get_inet_res("https://api.github.com/repos/kusaanko/FFmpeg-Auto-Build/releases/latest", &inet_error);
else jtext = util::get_inet_res("https://api.github.com/repos/yt-dlp/FFmpeg-Builds/releases/latest", &inet_error);
jtext = util::get_inet_res("https://api.github.com/repos/kusaanko/FFmpeg-Auto-Build/releases/latest", &inet_error, false, conf.github_token);
else jtext = util::get_inet_res("https://api.github.com/repos/yt-dlp/FFmpeg-Builds/releases/latest", &inet_error, false, conf.github_token);
if(!jtext.empty())
{
json json_ffmpeg;
Expand Down Expand Up @@ -2016,16 +2016,16 @@ void GUI::get_latest_ytdlp(nana::window parent_for_msgbox)
if(fname.empty())
fname = ytdlp_fname;
if(fname == "ytdl-patched-red.exe")
jtext = util::get_inet_res("https://api.github.com/repos/ytdl-patched/ytdl-patched/releases/latest", &inet_error);
else
jtext = util::get_inet_res("https://api.github.com/repos/ytdl-patched/ytdl-patched/releases/latest", &inet_error, false, conf.github_token);
else
{
if(win7)
jtext = util::get_inet_res("https://api.github.com/repos/nicolaasjan/yt-dlp/releases/latest", &inet_error);
jtext = util::get_inet_res("https://api.github.com/repos/nicolaasjan/yt-dlp/releases/latest", &inet_error, false, conf.github_token);
else
{
if(conf.ytdlp_nightly)
jtext = util::get_inet_res("https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest", &inet_error);
else jtext = util::get_inet_res("https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest", &inet_error);
jtext = util::get_inet_res("https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest", &inet_error, false, conf.github_token);
else jtext = util::get_inet_res("https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest", &inet_error, false, conf.github_token);
}
}
if(!jtext.empty() && thr_releases_ytdlp.joinable())
Expand Down Expand Up @@ -2078,7 +2078,7 @@ void GUI::get_latest_deno(nana::window parent_for_msgbox)
thr_releases_deno = std::thread {[parent_for_msgbox, this]
{
using json = nlohmann::json;
auto jtext {util::get_inet_res("https://api.github.com/repos/denoland/deno/releases/latest", &inet_error)};
auto jtext {util::get_inet_res("https://api.github.com/repos/denoland/deno/releases/latest", &inet_error, false, conf.github_token)};
if(!jtext.empty())
{
json jrel;
Expand Down
5 changes: 5 additions & 0 deletions ytdlp-interface/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ void settings_t::to_json(nlohmann::json &j) const
j["cb_display_custom_filenames"] = cb_display_custom_filenames;
j["cb_cookies"] = cb_cookies;
j["cookies_path"] = cookies_path;
j["github_token"] = github_token;
}


Expand Down Expand Up @@ -988,4 +989,8 @@ void settings_t::from_json(const nlohmann::json &j)
cb_cookies = j["cb_cookies"];
cookies_path = j["cookies_path"].get<std::string>();
}
if(j.contains("github_token")) // v2.20
{
github_token = j["github_token"].get<std::string>();
}
}
2 changes: 1 addition & 1 deletion ytdlp-interface/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ struct settings_t
output_template_default_bandcamp {L"%(artist)s - %(album)s - %(track_number)02d - %(track)s.%(ext)s"};
std::wstring fmt1, fmt2, output_template {output_template_default}, playlist_indexing {playlist_indexing_default},
output_template_bandcamp {output_template_default_bandcamp}, proxy;
std::string argset, cookie_options, aria_options {"-x 6"}, sub_langs, sub_format;
std::string argset, cookie_options, aria_options {"-x 6"}, sub_langs, sub_format, github_token;
std::vector<std::string> argsets;
std::vector<std::pair<std::string, std::vector<std::string>>> unfinished_queue_items;
std::unordered_set<std::wstring> outpaths;
Expand Down
10 changes: 8 additions & 2 deletions ytdlp-interface/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ std::wstring util::get_sys_folder(REFKNOWNFOLDERID rfid)
}


std::string util::get_inet_res(std::string res, std::string *error, bool truncate)
std::string util::get_inet_res(std::string res, std::string *error, bool truncate, std::string token)
{
std::string ret;
if(error) error->clear();
Expand All @@ -471,7 +471,13 @@ std::string util::get_inet_res(std::string res, std::string *error, bool truncat
auto hinet {InternetOpenA(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0)};
if(hinet)
{
auto hfile {InternetOpenUrlA(hinet, res.data(), NULL, 0, 0, 0)};
std::string auth_header;
if(!token.empty() && res.find("github.com") != std::string::npos)
auth_header = "Authorization: token " + token + "\r\n";

auto hfile {InternetOpenUrlA(hinet, res.data(), NULL, 0,
auth_header.empty() ? NULL : auth_header.c_str(),
auth_header.empty() ? 0 : -1L)};
if(hfile)
{
DWORD read {1};
Expand Down
2 changes: 1 addition & 1 deletion ytdlp-interface/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace util
DWORD other_instance(std::wstring path = L"");
unsigned close_children(bool report_only = false);
std::wstring get_sys_folder(REFKNOWNFOLDERID rfid);
std::string get_inet_res(std::string res, std::string *error = nullptr, bool truncate = false);
std::string get_inet_res(std::string res, std::string *error = nullptr, bool truncate = false, std::string token = "");
std::string dl_inet_res(std::string res, fs::path fname, bool *working = nullptr, std::function<void(unsigned)> cb = nullptr);
std::string extract_7z(fs::path arc_path, fs::path out_path, unsigned ffmpeg = 0, bool ytdlp_interface = false);
std::wstring get_clipboard_text();
Expand Down