From ad7eac534323d60aa83bb298a0329e0c36de5994 Mon Sep 17 00:00:00 2001 From: "Leon Etienne (ubuntu wsl)" Date: Wed, 30 Sep 2020 18:09:09 +0200 Subject: [PATCH] Made the download entries work with the jsons --- Tubio/DownloadManager.cpp | 7 +- Tubio/RestQueryHandler.cpp | 1 + .../leonetienne/JasonPP/JasonPP.cpp | 39 ++++++++- .../leonetienne/JasonPP/JasonPP.hpp | 2 +- .../components/DownloadBox.vue | 48 ++++++----- .../components/DownloadEntry.vue | 81 ++++++++++--------- .../static/rest-dummies/cache.json | 66 +++++++++++++++ 7 files changed, 184 insertions(+), 60 deletions(-) create mode 100644 tubio-frontend-nuxt-app/static/rest-dummies/cache.json diff --git a/Tubio/DownloadManager.cpp b/Tubio/DownloadManager.cpp index 596c176..9f50d68 100644 --- a/Tubio/DownloadManager.cpp +++ b/Tubio/DownloadManager.cpp @@ -152,7 +152,8 @@ void DownloadManager::DownloadNext() std::string ytdl_call_video_base = "youtube-dl --newline --no-call-home --no-playlist --no-part --no-warnings --limit-rate $$DL_RATE" " --no-mtime --no-cache-dir --recode-video mp4 --format \"bestvideo[ext=mp4]+bestaudio/best[ext=mp4]/best\"" - " --merge-output-format mp4 -o \"$$DL_FILE\" $$DL_URL > \"$$DL_PROG_BUF_FILE\""; + " --merge-output-format mp4 -o \"$$DL_FILE\" \"$$DL_URL\" > \"$$DL_PROG_BUF_FILE\""; + ytdl_call_video_base = Internal::StringHelpers::Replace(ytdl_call_video_base, "$$DL_RATE", XGConfig::downloader.max_dlrate_per_thread); ytdl_call_video_base = Internal::StringHelpers::Replace(ytdl_call_video_base, "$$DL_FILE", XGConfig::downloader.cachedir + "/download/" + entry->tubio_id + ".%(ext)s"); @@ -167,7 +168,7 @@ void DownloadManager::DownloadNext() std::string ytdl_call_audio_base = "youtube-dl --newline --no-call-home --no-playlist --no-part --no-warnings --limit-rate $$DL_RATE" " --no-mtime --no-cache-dir --audio-format mp3 --audio-quality 0 --extract-audio -o \"$$DL_FILE\"" - " $$DL_URL > \"$$DL_PROG_BUF_FILE\""; + " \"$$DL_URL\" > \"$$DL_PROG_BUF_FILE\""; ytdl_call_audio_base = Internal::StringHelpers::Replace(ytdl_call_audio_base, "$$DL_RATE", XGConfig::downloader.max_dlrate_per_thread); ytdl_call_audio_base = Internal::StringHelpers::Replace(ytdl_call_audio_base, "$$DL_FILE", XGConfig::downloader.cachedir + "/download/" + entry->tubio_id + ".%(ext)s"); @@ -572,7 +573,7 @@ std::vector DownloadManager::ParseJsonArrayToEntries(const JasonP void DownloadManager::FetchInformation(std::string url, std::string tubId) { std::stringstream ss; - ss << "youtube-dl.exe --skip-download --dump-json " << url << " > \"" << XGConfig::downloader.cachedir << "/metadata/" << tubId << ".json" << "\"" << std::endl; + ss << "youtube-dl.exe --skip-download --dump-json \"" << url << "\" > \"" << XGConfig::downloader.cachedir << "/metadata/" << tubId << ".json" << "\"" << std::endl; system(ss.str().c_str()); return; } diff --git a/Tubio/RestQueryHandler.cpp b/Tubio/RestQueryHandler.cpp index ec61e40..7a5e107 100644 --- a/Tubio/RestQueryHandler.cpp +++ b/Tubio/RestQueryHandler.cpp @@ -145,6 +145,7 @@ bool RestQueryHandler::FetchAlltimeCache(const JsonBlock& request, JsonBlock& re JsonArray cache = DownloadManager::GetAlltimeCacheAsJson(-1, -1); // Get ALL the data responseBody.Set("cache_size") = (long long int)cache.Size(); responseBody.Set("cache") = cache; + return true; } diff --git a/Tubio/external_dependencies/leonetienne/JasonPP/JasonPP.cpp b/Tubio/external_dependencies/leonetienne/JasonPP/JasonPP.cpp index 6b649c4..b9f558c 100644 --- a/Tubio/external_dependencies/leonetienne/JasonPP/JasonPP.cpp +++ b/Tubio/external_dependencies/leonetienne/JasonPP/JasonPP.cpp @@ -1133,7 +1133,6 @@ std::string StringHelpers::Replace(const std::string str, const std::string find return ss.str(); } - std::string StringHelpers::Escape(const std::string str) { std::stringstream ss; @@ -1161,7 +1160,43 @@ std::string StringHelpers::Escape(const std::string str) ss << "\\\""; break; case '\\': - ss << "\\\\"; + // All of this bullshit basically means: + // If we find an escaped utf-16 sequence, it was most likely ignored behind by the utf-8 parser (because it can only escape utf-8, duh), so we will not escape it. + + // If we found a \u and the string is long enought that it could be a utf sequence + if ((str.length() > i + 5) && (str[i + 1] == 'u')) + { + // Check that the found so-called utf sequence is followed by a valid 16-bit hex string + std::string wouldbeHex = str.substr(i + 2, 4); + bool isValidHex = true; + for (std::size_t j = 0; j < wouldbeHex.size(); j++) + { + // Make any capitcal hex digit lowercase + if ((wouldbeHex[j] >= 'A') && (wouldbeHex[j] <= 'F')) wouldbeHex[j] += 32; + + // Check that it is indeed a hex literal + if (!(((wouldbeHex[j] >= '0') && (wouldbeHex[j] <= '9')) || + ((wouldbeHex[j] >= 'a') && (wouldbeHex[j] <= 'f')))) + { + isValidHex = false; + } + } + // Check that it is a UTF-16 escape sequence (because these are left unparsed) + if ((isValidHex) && (wouldbeHex.substr(0, 2) != "00")) + { + ss << str[i]; + } + // If it is not an unescaped utf-16 sequence, just escape it + else + { + ss << "\\\\"; + } + } + // If it is not an unescaped utf-16 sequence, just escape it + else + { + ss << "\\\\"; + } break; default: if (str[i] < 0) ss << EscapeUTF8(str[i]); diff --git a/Tubio/external_dependencies/leonetienne/JasonPP/JasonPP.hpp b/Tubio/external_dependencies/leonetienne/JasonPP/JasonPP.hpp index 4d60869..1a334ab 100644 --- a/Tubio/external_dependencies/leonetienne/JasonPP/JasonPP.hpp +++ b/Tubio/external_dependencies/leonetienne/JasonPP/JasonPP.hpp @@ -2148,7 +2148,7 @@ namespace JasonPP }; } -#define JASONPP_VERSION (1.0216) +#define JASONPP_VERSION (1.022) namespace JasonPP { diff --git a/tubio-frontend-nuxt-app/components/DownloadBox.vue b/tubio-frontend-nuxt-app/components/DownloadBox.vue index 78844de..69ee201 100644 --- a/tubio-frontend-nuxt-app/components/DownloadBox.vue +++ b/tubio-frontend-nuxt-app/components/DownloadBox.vue @@ -2,32 +2,44 @@

No downloads yet...

- - - - - - - - - - - - - - - - - + +
@@ -122,13 +130,14 @@ export default { } & .thumbnail { - background-image: url("https://i.ytimg.com/vi/wgfNsek8xkc/hqdefault.jpg?sqp=-oaymwEZCNACELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLBrNQptU-Ni4VWrrsCm689gPnm2ww"); + background-image: var(--thumbnail); background-size: cover; background-position: center; + background-repeat: no-repeat; width: 150px; height: calc(150px * (9 / 16)); position: relative; - transition: transform 0.2s; + transition: transform 0.2s, background-image 1s ease-in-out; cursor: pointer; scrollbar-width: none; @@ -138,7 +147,7 @@ export default { } &:hover { - transform: scale(1.05); + // transform: scale(1.05); /* shit causes flickering */ } &__vignette { @@ -152,27 +161,24 @@ export default { &__duration { position: absolute; - bottom: 3px; - right: 3px; + bottom: 0; + right: 0; + padding: 0 3px 3px 0; text-align: right; font-size: 12pt; color: theme("colors.text-gray-1"); + background-color: #000a; } } & .title { color: theme("colors.text-gray-1"); font-size: 22pt; - max-height: 1.05em; + max-height: 1.3em; + overflow-y: hidden; overflow-x: hidden; text-overflow: ellipsis; white-space: nowrap; - transition: transform 20s; - - &:hover { - overflow: visible; - transform: translateX(-200%); - } } & .description { @@ -198,6 +204,7 @@ export default { height: 40px; border-top: 2px solid theme("colors.gray-1"); border-left: 2px solid theme("colors.gray-1"); + pointer-events: none; } &--right { @@ -207,6 +214,7 @@ export default { height: 40px; border-bottom: 2px solid theme("colors.gray-1"); border-right: 2px solid theme("colors.gray-1"); + pointer-events: none; } } } @@ -218,7 +226,8 @@ export default { &__good { background-color: #0b0; - width: 50%; // Download progress + width: var(--download-progress); // Download progress + transition: width 1s; } &__text { diff --git a/tubio-frontend-nuxt-app/static/rest-dummies/cache.json b/tubio-frontend-nuxt-app/static/rest-dummies/cache.json new file mode 100644 index 0000000..2f8973f --- /dev/null +++ b/tubio-frontend-nuxt-app/static/rest-dummies/cache.json @@ -0,0 +1,66 @@ +{ + "cache": [ + { + "description": "Download Eminem's 'MMLP2' Album on iTunes now:http://smarturl.it/MMLP2\n\nCredits below\nVideo Director: Rich Lee\nVideo Producer: Justin Diener\nVideo Producer: Kathy Angstadt\n\nPlaylist Best of Eminem: https://goo.gl/AquNpo\nSubscribe for more: https://goo.gl/DxCrDV\n\n#Eminem #RapGod #Vevo", + "download_progress": 0, + "download_url": "/download/1KnEwh", + "downloaded_filename": "", + "duration": 369, + "mode": "video", + "queued_timestamp": 1601481597, + "status": "queued", + "thumbnail_url": "https://i.ytimg.com/vi/XbGs_qK2PQA/hqdefault.jpg?sqp=-oaymwEZCNACELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLCNO4b_zqnDZVdwf7GpJ1i0TEEvJA", + "title": "Eminem - Rap God (Explicit) [Official Video]", + "tubio_id": "1KnEwh", + "uploader": "EminemVEVO", + "webpage_url": "https://www.youtube.com/watch?v=XbGs_qK2PQA" + }, + { + "description": "Check out my SoundCloud Channel for more music: https://soundcloud.com/user-411907790\n\u266c \u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u266c \nA big thank you to everyone who voluntarily financially supports my work and thus makes it possible:\n\u26abPaypal: https://www.paypal.me/KarlSternau\n\u26abPatreon: https://www.patreon.com/karlsternau\n\u266c \u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012 \u266c", + "download_progress": 98, + "download_url": "/download/1KnEwb", + "downloaded_filename": "dlcache/download/1KnEwb.mp4", + "duration": 413, + "mode": "video", + "queued_timestamp": 1601481591, + "status": "downloading", + "thumbnail_url": "https://i.ytimg.com/vi/c3wRzxiQ8Zk/hqdefault.jpg?sqp=-oaymwEZCNACELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLC4MWTAc7sY5uF6hFzNk2D0tawTSA", + "title": "Sing with Karl - Des Morgens Um Halb Viere [Old soldier and student way][All Stanzas]", + "tubio_id": "1KnEwb", + "uploader": "Karl Sternau", + "webpage_url": "https://www.youtube.com/watch?v=c3wRzxiQ8Zk" + }, + { + "description": "Latest video off of Lil Dicky's debut album \"Professional Rapper.\" Download the album here: http://smarturl.it/LilDickyiTunes \n\nWatch Lil Dicky create the most epic rap video, all while he $aves Dat Money! Click here for the documentary: https://www.youtube.com/watch?v=zkXpb20b-NQ\n\nDirector\nTony Yacenda\nwww.TonyYacenda.com\n\nProducer\nJim Cummings\n\nCinematographer\nAlan Gwizdowski\n\nMusic Video Editor\nBrian Vannucci\n\nDocumentary Editor\nBrad Allen Wilde\n\nPost Supervisor\nRyan Ross\n\nColorist\nSean Wells\n\nSound Mixers\nDi Le\nDarrell Tung\n\nSecond Unit DPs\nAdam Lee\nJeff Kulig\nLuc Delamare\n\nBoat Girls\nMelissa Soria\nSuzanne Quast\nJulia Misaki\n\nSpecial Thanks\n\"The Study\u201d Hollywood\nAvilaVIP\nMrs. \u201cK\u201d\nThe Noho Diner\nFrosty Treats/Amp Entertainment\n\nWeedmaps\nMaster and Dynamic\nRGF Productions\nJash\nMeUndies (www.meundies.com)\n\nand\n\nSarah Silverman\nKevin Durant\nDillon Francis\nHannibal Buress\nAbbi Jacobson\nIlana Glazer\nMark Cuban\nTom Petty\n\nSong produced by Money Alwayz\nSong Mixed by Rob Kinelski at The Fortress of Amplitude\nAssistant Engineer: David Baker", + "download_progress": 100, + "download_url": "/download/1KnEw2", + "downloaded_filename": "dlcache/download/1KnEw2.mp4", + "duration": 528, + "mode": "video", + "queued_timestamp": 1601481583, + "status": "finished", + "thumbnail_url": "https://i.ytimg.com/vi/yvHYWD29ZNY/hqdefault.jpg?sqp=-oaymwEZCNACELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLAEDvLcxoI0aEQ_gYmFwJJN_4Zpyg", + "title": "Lil Dicky - $ave Dat Money feat. Fetty Wap and Rich Homie Quan (Official Music Video)", + "tubio_id": "1KnEw2", + "uploader": "Lil Dicky", + "webpage_url": "https://www.youtube.com/watch?v=yvHYWD29ZNY" + }, + { + "description": "Get the new album \"Wintersaga\" here: https://smarturl.it/Wintersaga-NPR\n\nWind Rose states:\n\u201cMining is one of the most important activities for a Dwarf, naturally Wind Rose needed a theme song for this great honor of collecting these jewels from the soil, so sing with us with pride!!\u201c \n\n\"Diggy Diggy Hole\" originally written by Yogscast\n\nMixed and Mastered by Lasse Lammert", + "download_progress": 9, + "download_url": "/download/1KnEvV", + "downloaded_filename": "dlcache/download/1KnEvV.mp4", + "duration": 341, + "mode": "video", + "queued_timestamp": 1601481574, + "status": "failed", + "thumbnail_url": "https://i.ytimg.com/vi/34CZjsEI1yU/hqdefault.jpg?sqp=-oaymwEZCNACELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLBW5B03ohHsKIrdYgJRvSAQNyRNqQ", + "title": "WIND ROSE - Diggy Diggy Hole (Official Video) | Napalm Records", + "tubio_id": "1KnEvV", + "uploader": "Napalm Records", + "webpage_url": "https://www.youtube.com/watch?v=34CZjsEI1yU" + } + ], + "cache_size": 4, + "status": "OK" +} \ No newline at end of file