From 0d4cae99db57e16035fdf609d22344a44a2009a1 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Mon, 2 Aug 2021 18:56:27 +0200 Subject: small fixes --- dl.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dl.js b/dl.js index ac546df..4126137 100755 --- a/dl.js +++ b/dl.js @@ -21,10 +21,13 @@ function getDLURLs(streaminfo, baseURL) { var time = 0; urls.push(toDownload.$.initialization.replace("$RepresentationID$", highestQuality.id)); toDownload.SegmentTimeline[0].S.forEach(segment => { - urls.push(toDownload.$.media - .replace("$RepresentationID$", highestQuality.id) - .replace("$Time$", time)); - time += Number(segment.$.d); + var repeat = segment.$.r || 1; + for(let i = 0; i < repeat; i++) { + urls.push(toDownload.$.media + .replace("$RepresentationID$", highestQuality.id) + .replace("$Time$", time)); + time += Number(segment.$.d); + } }); urls = urls.map(url => baseURL + '/' + url); @@ -78,6 +81,7 @@ async function dlURLs(urls, filename) { var streaminfo = await axios.get(`https://start-player.npo.nl/video/${video.id}/streams?` + streaminfoURL.toString()); var filename = video.title.toString().replace(/\s+/g, "-") + "_" + + video.id.replace(/\s+/g, '-').toLowerCase() + "_" + "s" + video.seasonNumber.toString().padStart(2, '0') + "e" + video.episodeNumber.toString().padStart(2, '0'); @@ -93,7 +97,7 @@ async function dlURLs(urls, filename) { var audioStream = xml.MPD.Period[0].AdaptationSet.find(s => s.$.contentType == 'audio'); await dlURLs(getDLURLs(audioStream, baseURL), filename + '.mp4a'); - cp.execSync(`ffmpeg -i ${filename}.mp4v -i ${filename}.mp4a -map 0:0 -map 1:0 -c copy ${filename}.mp4`); + cp.execSync(`ffmpeg -i ${filename}.mp4v -i ${filename}.mp4a -map 0:0 -map 1:0 ${filename}.mp4`); fs.rmSync(filename + '.mp4v'); fs.rmSync(filename + '.mp4a'); -- cgit v1.2.3