diff --git a/funi.ts b/funi.ts index 728bb032..9fe47a1c 100644 --- a/funi.ts +++ b/funi.ts @@ -585,18 +585,20 @@ async function downloadStreams(epsiode: FunimationMediaDownload){ } - argv.q = argv.q < 1 || argv.q > plMaxLayer ? plMaxLayer : argv.q; - const plSelectedServer = plServerList[argv.x-1]; const plSelectedList = plStreams[plSelectedServer]; - const videoUrl = argv.x < plServerList.length+1 && plSelectedList[argv.q] ? plSelectedList[argv.q] : ''; plLayersStr.sort(); console.log(`[INFO] Servers available:\n\t${plServerList.join('\n\t')}`); console.log(`[INFO] Available qualities:\n\t${plLayersStr.join('\n\t')}`); - + + const selectedQuality = argv.q === 0 || argv.q > Object.keys(plLayersRes).length + ? Object.keys(plLayersRes).pop() as string + : argv.q; + const videoUrl = argv.x < plServerList.length+1 && plSelectedList[selectedQuality] ? plSelectedList[selectedQuality] : ''; + if(videoUrl != ''){ - console.log(`[INFO] Selected layer: ${argv.q} (${plLayersRes[argv.q].width}x${plLayersRes[argv.q].height}) @ ${plSelectedServer}`); + console.log(`[INFO] Selected layer: ${selectedQuality} (${plLayersRes[selectedQuality].width}x${plLayersRes[selectedQuality].height}) @ ${plSelectedServer}`); console.log('[INFO] Stream URL:',videoUrl); fnOutput = parseFileName(argv.fileName, ([ @@ -604,8 +606,8 @@ async function downloadStreams(epsiode: FunimationMediaDownload){ ['title', epsiode.title], ['showTitle', epsiode.showTitle], ['season', season], - ['width', plLayersRes[argv.q].width], - ['height', plLayersRes[argv.q].height], + ['width', plLayersRes[selectedQuality].width], + ['height', plLayersRes[selectedQuality].height], ['service', 'Funimation'] ] as [appYargs.AvailableFilenameVars, string|number][]).map((a): Variable => { return { diff --git a/package-lock.json b/package-lock.json index 9bfd092d..60ba27a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "multi-downloader-nx", - "version": "2.0.13", + "version": "2.0.14", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "multi-downloader-nx", - "version": "2.0.13", + "version": "2.0.14", "license": "MIT", "dependencies": { "cheerio": "^1.0.0-rc.10", diff --git a/package.json b/package.json index 0858e7d1..f34d3507 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "multi-downloader-nx", "short_name": "aniDL", - "version": "2.0.13", + "version": "2.0.14", "description": "Download videos from Funimation or Crunchyroll via cli", "keywords": [ "download",