From 8f4fb65730eba551f3b03d671111d8f458e3cfbc Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 31 May 2020 18:36:59 +0200 Subject: Activate video option --- downtube.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'downtube.cpp') diff --git a/downtube.cpp b/downtube.cpp index b3ed581..6e45764 100644 --- a/downtube.cpp +++ b/downtube.cpp @@ -147,7 +147,7 @@ int main(void) FCGX_PutS("Content-Type: application/octet-stream\r\n", request.out); FCGX_FPrintF(request.out, "Content-Length: %d\r\n\r\n", filedata.size()); FCGX_PutStr(filedata.c_str(), filedata.size(), request.out); - } else if (false && format == "mp4") { // disabled for now + } else if (format == "mp4") { //std::string cmd{"youtube-dl --no-warnings --no-call-home --no-progress --recode-video mp4 -o video.mp4 --restrict-filenames "s + url}; // Recoding to MP4 is too slow currently. So keep original format for now std::string cmd{"youtube-dl --no-warnings --no-call-home --no-progress -o video.mp4 --restrict-filenames "s + url}; @@ -158,7 +158,7 @@ int main(void) fs::directory_iterator di{fs::current_path()}; fs::path filename; for (const auto& i: di) { - if (i.path().stem().string() == "video"s) { + if (boost::algorithm::starts_with(i.path().filename().string(), "video."s)) { filename = i.path().filename().string(); break; } @@ -170,6 +170,9 @@ int main(void) std::string filedata {File::getFile(filename)}; // may throw + if (filedata.size() > 300000000) + throw std::runtime_error("File too big"); + FCGX_PutS("Content-Type: application/octet-stream\r\n", request.out); FCGX_FPrintF(request.out, "Content-Length: %d\r\n\r\n", filedata.size()); FCGX_PutStr(filedata.c_str(), filedata.size(), request.out); -- cgit v1.2.3