Made the download entries work with the jsons

This commit is contained in:
Leon Etienne (ubuntu wsl) 2020-09-30 18:09:09 +02:00
parent 5d04df3422
commit ad7eac5343
7 changed files with 184 additions and 60 deletions

View File

@ -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<DownloadEntry> 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;
}

View File

@ -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;
}

View File

@ -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]);

View File

@ -2148,7 +2148,7 @@ namespace JasonPP
};
}
#define JASONPP_VERSION (1.0216)
#define JASONPP_VERSION (1.022)
namespace JasonPP
{

View File

@ -2,32 +2,44 @@
<div class="download-box">
<h2 v-if="false" class="no-dls-yet mt-2">No downloads yet...</h2>
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry />
<DownloadEntry v-for="(nObj, nIdx) in downloads_c" :downloadEntry="nObj" :key="nIdx" />
</div>
</template>
<script>
import DownloadEntry from "~/components/DownloadEntry";
import axios from "axios";
export default {
components: {
components: {
DownloadEntry,
},
computed: {
downloads_c: function() {
return this.downloads;
}
},
data() {
return {
downloads: {type: Array}
};
},
mounted() {
const that = this;
axios.get("/rest-dummies/cache.json", {
responseType: 'text'
}).then(function(response){
if (response.data.status === "OK") {
console.log(response.data);
that.downloads = response.data.cache;
}
});
return;
}
}

View File

@ -7,11 +7,11 @@
<div class="flex flex-col">
<div class="icon--mode">
<IconFilm v-if="false" />
<IconFilm v-if="downloadEntry.mode === 'video'" />
<IconMusic v-else />
</div>
<div class="timestamp">
20.09.2020
{{getQueuedDateString(downloadEntry.queued_timestamp)}}
</div>
</div>
@ -23,25 +23,25 @@
<div class="flex flex-col-reverse md:flex-row w-full mt-2">
<div class="flex flex-col">
<a href="www.youtube.de" title="To the original source">
<div class="thumbnail flex-shrink-0">
<a :href="downloadEntry.webpage_url" target="_blank" title="To the original source">
<div class="thumbnail flex-shrink-0" :style="'--thumbnail: url(\'' + downloadEntry.thumbnail_url + '\')'">
<div class="thumbnail__vignette" />
<div class="thumbnail__duration">29:30</div>
<div class="thumbnail__duration">{{getDurationString(downloadEntry.duration)}}</div>
</div>
</a>
<!-- Progressbar -->
<div v-if="false">
<div v-if="downloadEntry.status === 'downloading'">
<div class="status--progressbar flex w-full mt-3">
<div class="status--progressbar__good items-stretch"></div>
<div class="status--progressbar__good items-stretch" :style="'--download-progress: ' + downloadEntry.download_progress + '%;'"></div>
</div>
<div class="status--progressbar__text">
69%
{{downloadEntry.download_progress}}%
</div>
</div>
<!-- Ready -->
<a v-if="true" href="" title="download">
<a v-else-if="downloadEntry.status === 'finished'" :href="downloadEntry.download_url" title="download">
<div class="status--ready mt-3 button flex justify-center w-full">
<div>
<IconDownload />
@ -50,14 +50,14 @@
</a>
<!-- Queued -->
<div v-if="false">
<div v-else-if="downloadEntry.status === 'queued'">
<div class="status--queued mt-3">
Queued
</div>
</div>
<!-- Failed -->
<div v-if="false">
<div v-else-if="downloadEntry.status === 'failed'">
<div class="status--failed mt-3">
Failed!
</div>
@ -65,20 +65,12 @@
</div>
<div class="flex flex-col md:ml-4 overflow-x-hidden">
<h1 class="title">Versengold - Thekenmädchen (Offizielles Video) Versengold - Thekenmädchen (Offizielles Video) Versengold - Thekenmädchen (Offizielles Video)</h1>
<div class="flex flex-col md:ml-4 overflow-x-hidden overflow-y-visible">
<h1 class="title">{{downloadEntry.title}}</h1>
<div class="relative my-4">
<p class="description p-2">
Thekenmädchen - Die zweite Single aus dem neuen Album "NORDLICHT". Album-Release: 28.06.2019
Hier das Album vorbestellen: https://Versengold.lnk.to/Nordlicht
Hier gehts zur Fanbox: https://Versengold.lnk.to/Nordlicht_Box
Hol dir den Song "Thekenmädchen" jetzt hier: https://Versengold.lnk.to/Thekenmaedchen
Mehr Informationen unter:
Webseite: http://www.versengold.com/
Facebook: https://www.facebook.com/Versengold
{{downloadEntry.description}}
</p>
<div class="description__decobox description__decobox--left" />
<div class="description__decobox description__decobox--right" />
@ -107,6 +99,22 @@ export default {
props: {
downloadEntry: {type: Object},
},
methods: {
getQueuedDateString: function(unixTime) {
const date = new Date(unixTime * 1000);
const day = ("0" + date.getDay()).slice(-2);
const month = ("0" + date.getMonth()).slice(-2);
return day + "." + month + "." + date.getFullYear();
},
getDurationString: function(unixTime) {
const time = new Date(unixTime * 1000);
const hours = ("0" + (time.getHours() - 1)).slice(-2);
const minutes = ("0" + (time.getMinutes())).slice(-2);
const seconds = ("0" + (time.getSeconds())).slice(-2);
return ((hours !== "0") ? hours : "") + ":" + minutes + ":" + seconds;
},
},
}
</script>
@ -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 {

View File

@ -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"
}