diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-05-31 18:36:59 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-05-31 18:36:59 +0200 |
commit | 8f4fb65730eba551f3b03d671111d8f458e3cfbc (patch) | |
tree | 7c877c7563050617638faa51000e02dfd90979fa | |
parent | 3bfd422f6f92fed162e14d29fd5cd6142b2b87a5 (diff) |
Activate video option
-rw-r--r-- | downtube.cpp | 7 | ||||
-rw-r--r-- | html/downtube.js | 10 | ||||
-rw-r--r-- | html/index.html | 2 |
3 files changed, 13 insertions, 6 deletions
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); diff --git a/html/downtube.js b/html/downtube.js index abe62b8..f79443e 100644 --- a/html/downtube.js +++ b/html/downtube.js @@ -28,7 +28,7 @@ function on_start() { return; } if (this.status != 200) { - set_status("Server Error while retrieving filename"); + set_status("Server Error while retrieving filename, " + filename + ", status: " + this.status + " " + this.statusText); return; } @@ -68,11 +68,15 @@ function get_file(filename) { // run on data received back xhr.onreadystatechange = function() { + if (this.readyState == 3) { + set_status("Please wait while downloading " + filename + " ..."); + return; + } if (this.readyState != 4) { return; } if (this.status != 200) { - set_status("Server Error while retrieving " + filename); + set_status("Server Error while retrieving " + filename + ", status: " + this.status + " " + this.statusText); return; } @@ -107,6 +111,6 @@ function get_file(filename) { xhr.responseType = 'blob'; xhr.send(xmlDocument); - set_status("Please wait while retrieving " + filename + " ..."); + set_status("Please wait while server prepares " + filename + " ..."); } diff --git a/html/index.html b/html/index.html index 2892e79..05ab9d6 100644 --- a/html/index.html +++ b/html/index.html @@ -22,7 +22,7 @@ Transform to format:<br/> <input type="radio" id="mp3" name="format" value="mp3" checked> <label for="mp3">MP3 (Audio)</label><br> - <input type="radio" id="mp4" name="format" value="mp4" disabled> + <input type="radio" id="mp4" name="format" value="mp4"> <label for="mp4">MP4 (Video)</label><br> </p> |