From 7c058642fd7bac09d687e488da4c605f7ae90b03 Mon Sep 17 00:00:00 2001 From: AniDL Date: Wed, 3 Jun 2020 13:19:16 +0300 Subject: [PATCH] 4.6.0 --- .github/workflows/release-win64.yml | 44 ++++++++++++++++++++++++++++ docs/CHANGELOG.md | 14 +++++++-- funi.js | 40 ++++++++++++++++++------- modules/build.js | 2 +- cmd-here.bat => modules/cmd-here.bat | 0 package.json | 20 +++++++------ 6 files changed, 97 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/release-win64.yml rename cmd-here.bat => modules/cmd-here.bat (100%) diff --git a/.github/workflows/release-win64.yml b/.github/workflows/release-win64.yml new file mode 100644 index 0000000..0a68cae --- /dev/null +++ b/.github/workflows/release-win64.yml @@ -0,0 +1,44 @@ +name: Release Build Win64 + +on: + release: + types: [ created ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v1.4.2 + with: + node-version: 12.15.0 + + - name: Install Node modules + run: npm install + + - name: Make build + run: npm run build-win64 + + - name: Get name from package.json + run: | + test -n "$(node -p -e "require('./package.json').name")" && + echo "::set-env name=PACKAGE_NAME::$(node -p -e "require('./package.json').name")" || exit 1 + + - name: Get version from package.json + run: | + test -n "$(node -p -e "require('./package.json').version")" && + echo "::set-env name=PACKAGE_VERSION::$(node -p -e "require('./package.json').version")" || exit 1 + + - name: Upload release + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_name: ${{ env.PACKAGE_NAME }}-${{ env.PACKAGE_VERSION }}-win64.7z + asset_path: ./_builds/${{ env.PACKAGE_NAME }}-${{ env.PACKAGE_VERSION }}-win64.7z + asset_content_type: application/x-7z-compressed + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 198fe87..684cac3 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,13 +1,23 @@ ## Change Log +### 4.6.0 (2020/06/03) +- Bug fixes and improvements + +#### Known issues: +- Proxy not supported + ### 4.5.1 (2020/03/10) - Better binary files handling - Binary build for windows -- Known bug: Proxy not working + +#### Known issues: +- Proxy not supported ### 4.5.0 (2020/01/21) - Resume downloading -- Known bug: Proxy not working + +#### Known issues: +- Proxy not supported ### 4.4.2 (2019/07/21) - Better proxy handling for stream download diff --git a/funi.js b/funi.js index fbda3b5..7e3dfd1 100644 --- a/funi.js +++ b/funi.js @@ -13,9 +13,7 @@ console.log(`\n=== Funimation Downloader NX ${packageJson.version} ===\n`); const api_host = 'https://prod-api-funimationnow.dadcdigital.com/api'; // request -const got = require('got').extend({ - headers: { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:70.0) Gecko/20100101 Firefox/70.0' }, -}); +const got = require('got'); // modules extra const yaml = require('yaml'); @@ -492,7 +490,7 @@ async function downloadStreams(){ plMaxLayer = plMaxLayer < plLayerId ? plLayerId : plMaxLayer; // set urls and servers let plUrlDl = s.uri; - let plServer = plUrlDl.split('/')[2]; + let plServer = new URL(plUrlDl).host; if(!plServerList.includes(plServer)){ plServerList.push(plServer); } @@ -522,12 +520,16 @@ async function downloadStreams(){ for(let s of mainServersList){ if(plServerList.includes(s)){ - plServerList.splice(plServerList.indexOf(s),1); + plServerList.splice(plServerList.indexOf(s), 1); plServerList.unshift(s); break; } } + if(typeof argv.q == 'object' && argv.q.length > 1){ + argv.q = argv.q[argv.q.length-1]; + } + argv.q = argv.q < 1 || argv.q > plMaxLayer ? plMaxLayer : argv.q; let plSelectedServer = plServerList[argv.x-1]; @@ -571,7 +573,7 @@ async function downloadStreams(){ if (argv.proxy && !argv.ssp) { try { proxyHLS = {}; - proxyHLS.url = buildProxyUrl(argv.proxy,argv['proxy-auth']); + proxyHLS.url = buildProxyUrl(argv.proxy, argv['proxy-auth']); } catch(e){ console.log(`\n[WARN] Not valid proxy URL${e.input?' ('+e.input+')':''}!`); @@ -629,7 +631,10 @@ async function downloadStreams(){ return; } - if(!fs.statSync(`${path.join(cfg.dir.content, fnOutput)}.ts`).isFile()){ + let muxTrg = path.join(cfg.dir.content, fnOutput); + let tshTrg = path.join(cfg.dir.trash, fnOutput); + + if(!fs.existsSync(`${muxTrg}.ts`) || !fs.statSync(`${muxTrg}.ts`).isFile()){ console.log('\n[INFO] TS file not found, skip muxing video...\n'); return; } @@ -660,9 +665,6 @@ async function downloadStreams(){ argv.ftag = argv.ftag ? argv.ftag : argv.a; argv.ftag = shlp.cleanupFilename(argv.ftag); - let muxTrg = path.join(cfg.dir.content, fnOutput); - let tshTrg = path.join(cfg.dir.trash, fnOutput); - // select muxer if(!argv.mp4 && usableMKVmerge){ // mux to mkv @@ -721,7 +723,12 @@ async function downloadStreams(){ // get data from url async function getData(options){ - let gOptions = { url: options.url, headers: {} }; + let gOptions = { + url: options.url, + headers: { + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:70.0) Gecko/20100101 Firefox/70.0', + } + }; if(options.baseUrl){ gOptions.prefixUrl = options.baseUrl; gOptions.url = gOptions.url.replace(/^\//,''); @@ -741,6 +748,17 @@ async function getData(options){ if(options.dinstid){ gOptions.headers.devicetype = 'Android Phone'; } + // debug + gOptions.hooks = { + beforeRequest: [ + (options) => { + if(argv.debug){ + console.log('[DEBUG] GOT OPTIONS:'); + console.log(options); + } + } + ] + }; if(options.useProxy && argv.proxy){ try{ const ProxyAgent = require('proxy-agent'); diff --git a/modules/build.js b/modules/build.js index 410052c..6ebb514 100644 --- a/modules/build.js +++ b/modules/build.js @@ -57,7 +57,7 @@ const nodeVer = '-12.15.0'; fs.copySync('./config/bin-path.yml', `${buildDir}/config/bin-path.yml`); fs.copySync('./config/cli-defaults.yml', `${buildDir}/config/cli-defaults.yml`); fs.copySync('./config/dir-path.yml', `${buildDir}/config/dir-path.yml`); - fs.copySync('./cmd-here.bat', `${buildDir}/cmd-here.bat`); + fs.copySync('./modules/cmd-here.bat', `${buildDir}/cmd-here.bat`); fs.copySync('./docs/', `${buildDir}/docs/`); fs.copySync('./LICENSE.md', `${buildDir}/docs/LICENSE.md`); if(fs.existsSync(`${buildsDir}/${buildFull}.7z`)){ diff --git a/cmd-here.bat b/modules/cmd-here.bat similarity index 100% rename from cmd-here.bat rename to modules/cmd-here.bat diff --git a/package.json b/package.json index 0429eea..8060e4e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "funimation-downloader-nx", "short_name": "funi", - "version": "4.5.1", + "version": "4.6.0", "description": "Download videos from Funimation via cli.", "keywords": [ "download", @@ -25,18 +25,18 @@ "main": "funi.js", "dependencies": { "form-data": "^3.0.0", - "got": "^10.6.0", - "hls-download": "^2.3.2", - "lookpath": "^1.0.5", - "m3u8-parsed": "^1.2.0", + "got": "^11.2.0", + "hls-download": "^2.4.1", + "lookpath": "^1.0.6", + "m3u8-parsed": "^1.3.0", "proxy-agent": "^3.1.1", "sei-helper": "^3.3.0", - "ttml2srt": "^1.1.0", - "yaml": "^1.8.0", - "yargs": "^15.3.0" + "ttml2srt": "^1.2.0", + "yaml": "^1.10.0", + "yargs": "^15.3.1" }, "devDependencies": { - "fs-extra": "^8.1.0", + "fs-extra": "^9.0.0", "nexe": "^3.3.2", "removeNPMAbsolutePaths": "^2.0.0" }, @@ -44,6 +44,8 @@ "build-win64": "node modules/build win64", "build-linux64": "node modules/build linux64", "build-macos64": "node modules/build macos64", + "eslint": "eslint *.js modules", + "eslint-fix": "eslint *.js modules --fix", "test": "echo \"Error: no test specified\" && exit 1" } }