Skip to content

Commit 6b521f0

Browse files
committed
v2.16.0
1 parent bd648a5 commit 6b521f0

17 files changed

Lines changed: 1070 additions & 442 deletions

ytdlp-interface/forms/form_formats.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ void GUI::fm_formats()
286286
auto item {lbq.at(lbq.selected().front())};
287287
auto it {std::find_if(vidinfo["formats"].begin(), vidinfo["formats"].end(), [&](const auto &el)
288288
{
289-
return el["format"].get<std::string>().rfind(nana::to_utf8(strfmt)) != -1;
289+
return el["format_id"].get<std::string>() == nana::to_utf8(strfmt);
290290
})};
291291
std::string fsize {"---"}, fmt_note, ext, fmtid;
292292
if(it != vidinfo["formats"].end())
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#include "../gui.hpp"
2+
3+
4+
std::pair<bool, std::string> GUI::input_box(nana::window owner, std::string caption, std::string prompt)
5+
{
6+
using widgets::theme;
7+
using namespace nana;
8+
std::pair<bool, std::string> ret;
9+
10+
themed_form fm {nullptr, owner, {}, appear::decorate{}};
11+
fm.center(400, 165);
12+
fm.caption(caption);
13+
fm.snap(conf.cbsnap);
14+
15+
fm.div(R"(vert margin=20
16+
<l_prompt weight=30> <weight=15>
17+
<weight=25 <tb>> <weight=20>
18+
<<><btn_ok weight=90> <weight=20> <btn_cancel weight=90> <>>
19+
)");
20+
21+
::widgets::Label l_prompt {fm, prompt};
22+
l_prompt.text_align(align::center, align_v::center);
23+
24+
::widgets::Textbox tb {fm};
25+
tb.multi_lines(false);
26+
tb.padding(0, 5, 0, 5);
27+
tb.events().key_press([&](const arg_keyboard &arg)
28+
{
29+
if(arg.key == keyboard::enter)
30+
{
31+
ret = {true, tb.caption()};
32+
fm.close();
33+
}
34+
});
35+
36+
::widgets::Button btn_ok {fm, "OK"}, btn_cancel {fm, "Cancel"};
37+
btn_ok.events().click([&] { ret = {true, tb.caption()}; fm.close(); });
38+
btn_cancel.events().click([&] { ret = {false, ""}; fm.close(); });
39+
40+
fm["l_prompt"] << l_prompt;
41+
fm["tb"] << tb;
42+
fm["btn_ok"] << btn_ok;
43+
fm["btn_cancel"] << btn_cancel;
44+
45+
fm.theme_callback([&](bool dark)
46+
{
47+
fm.bgcolor(theme::fmbg.blend(dark ? colors::white : colors::grey, .04));
48+
fm.refresh_widgets();
49+
return false;
50+
});
51+
52+
if(conf.cbtheme == 2)
53+
fm.system_theme(true);
54+
else fm.dark_theme(conf.cbtheme == 0);
55+
56+
tb.focus();
57+
fm.collocate();
58+
fm.activate();
59+
fm.show();
60+
fm.modality();
61+
return ret;
62+
}

ytdlp-interface/forms/form_playlist.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,13 @@ void GUI::fm_playlist()
113113
durstr += ':' + ss.str();
114114
}
115115

116-
string title {entry["title"]};
116+
string title {"title not available"};
117+
if(entry.contains("title"))
118+
title = entry["title"].get<std::string>();
119+
else if(entry.contains("id"))
120+
title = entry["id"].get<std::string>();
121+
else if(entry.contains("url"))
122+
title = entry["url"].get<std::string>();
117123
if(!is_utf8(title))
118124
{
119125
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> u16conv;

0 commit comments

Comments
 (0)