diff --git a/api/downloadApi.js b/api/downloadApi.js index cec4694..553101a 100755 --- a/api/downloadApi.js +++ b/api/downloadApi.js @@ -102,7 +102,6 @@ module.exports = [ }, 1000 * 2)) // 404 else if (!downloader.videoExists(fname)) { - console.log(`dlstatus for ${fname}: ${dlStatus}`) return { statusCode: 404, contentType: "text/html; charset=UTF-8", diff --git a/api/video.js b/api/video.js index a82d507..7611b9d 100755 --- a/api/video.js +++ b/api/video.js @@ -191,7 +191,7 @@ module.exports = [ let largestSavedFormat let qualities = {} // When searching for a specific quality, if the specified one doesn't exist, retrieve the closest match - let videoPath = `/getVideo?v=${id}&q=${q || "360p"}` + let videoPath = `/getVideo?v=${id}&q=${q || startingFormat.qualityLabel}` for (const format of formats) { // apply media fragment to all sources + get largest format that is currently on disk @@ -253,7 +253,6 @@ module.exports = [ // Download base video if (!qSet && willDownload && !largestSavedFormat) { - console.log(`Starting download for ${id} (${startingFormat.qualityLabel})`); dlQueue.enqueue(id, startingFormat.qualityLabel) // Wait for a second to give the default noscript player at least a small portion of bytes to play await new Promise(resolve => setTimeout(resolve, 1000)) diff --git a/eirtubeMods/dl-queue.js b/eirtubeMods/dl-queue.js index a95e35c..9abeaa0 100755 --- a/eirtubeMods/dl-queue.js +++ b/eirtubeMods/dl-queue.js @@ -79,7 +79,9 @@ async function enqueue(videoID, quality) { else sortedQueues = dlQueues.sort((a, b) => (a.hq.length + (2 - a.downloadCount)) - (b.hq.length + (2 - b.downloadCount))) - return await sortedQueues[0].enqueue(videoID, quality) + const out = sortedQueues[0].enqueue(videoID, quality) + // console.log(dlQueues) + return await out } module.exports = { diff --git a/eirtubeMods/downloader.js b/eirtubeMods/downloader.js index 34dec37..386abd5 100755 --- a/eirtubeMods/downloader.js +++ b/eirtubeMods/downloader.js @@ -15,6 +15,7 @@ const qualitySort = require("./quality-sort") const downloadInPartsSize = 9_000_000 // 9 MB const cuda_enabled = childProcess.execSync("ffmpeg -hide_banner -loglevel error -hwaccel cuda -i html/static/images/bow.png bow.png && rm bow.png") == "" +const codec = childProcess.execSync("ffmpeg -hide_banner -loglevel error -decoders").includes("h264_cuvid") ? "h264_cuvid" : "h264"; function downloadStatus(videoID) { let dlData = cacheManager.read("download")[videoID] @@ -270,7 +271,7 @@ async function saveMp4Android(id, quality) { let cmd = [ "ffmpeg", - cuda_enabled ? "-hwaccel cuda -c:v h264_cuvid" : null, + cuda_enabled ? `-hwaccel cuda -c:v ${codec}` : null, `-y -i ${path.join(pathBase, videoPath)}`, `-i ${path.join(pathBase, audioPath)}`, `-c:v copy -c:a copy`, @@ -523,6 +524,7 @@ module.exports = { return videoData }, + /** @returns {Promise} */ sortFormats: async function(video, targetQuality) { // if (video.formatStreams == undefined || video.formatStreams.length == 0) // return [] diff --git a/html/static/js/player/quality.js b/html/static/js/player/quality.js index 28c6bdc..d1c150f 100755 --- a/html/static/js/player/quality.js +++ b/html/static/js/player/quality.js @@ -8,7 +8,7 @@ export default (modules, q, qa) => { let downloading = false if (modules.globals.dlStatus > 0 && modules.globals.dlStatus < 3) { downloading = true - modules.cacheInfo.pingCache(`${modules.globals.data.videoId}-${videoSource.split("&quality=")[1] || "360p"}`, () => { + modules.cacheInfo.pingCache(`${modules.globals.data.videoId}-${videoSource.split("&quality=")[1] || modules.globals.startingFormat.qualityLabel}`, () => { downloading = false self.reloadSource() }, 1000 * 2) @@ -59,7 +59,7 @@ export default (modules, q, qa) => { }) }, qualitySelected: quality => { - quality = quality || "360p" + quality = quality || modules.globals.startingFormat.qualityLabel modules.controls.setQualityButtonActive(quality)