Smallest working version
This commit is contained in:
parent
baf07c7cbe
commit
9048ae86a3
3 changed files with 37 additions and 11 deletions
5
funi.js
5
funi.js
|
|
@ -22,7 +22,6 @@ const got = require('got');
|
||||||
// extra
|
// extra
|
||||||
const appYargs = require('./modules/module.app-args');
|
const appYargs = require('./modules/module.app-args');
|
||||||
const getYamlCfg = require('./modules/module.cfg-loader');
|
const getYamlCfg = require('./modules/module.cfg-loader');
|
||||||
const getData = require('./modules/module.getdata.js');
|
|
||||||
const vttConvert = require('./modules/module.vttconvert');
|
const vttConvert = require('./modules/module.vttconvert');
|
||||||
// new-cfg
|
// new-cfg
|
||||||
const workingDir = process.pkg ? path.dirname(process.execPath) : __dirname;
|
const workingDir = process.pkg ? path.dirname(process.execPath) : __dirname;
|
||||||
|
|
@ -86,8 +85,8 @@ module.exports = {
|
||||||
cfg
|
cfg
|
||||||
};
|
};
|
||||||
|
|
||||||
// Import merger after argv has been exported
|
// Import modules after argv has been exported
|
||||||
|
const getData = require('./modules/module.getdata.js');
|
||||||
const merger = require('./modules/merger');
|
const merger = require('./modules/merger');
|
||||||
|
|
||||||
// check page
|
// check page
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,36 @@
|
||||||
const FormData = require('form-data');
|
|
||||||
const got = require('got');
|
const got = require('got');
|
||||||
|
|
||||||
|
const argv = require('../funi').argv
|
||||||
|
|
||||||
|
const lang = {
|
||||||
|
'ptBR': {
|
||||||
|
langCode: 'pt-BR',
|
||||||
|
regionCode: 'BR'
|
||||||
|
},
|
||||||
|
'esLA': {
|
||||||
|
langCode: 'es-LA',
|
||||||
|
regionCode: 'MX'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// do req
|
// do req
|
||||||
const getData = async (options) => {
|
const getData = async (options) => {
|
||||||
|
let regionHeaders = ((argv.region !== undefined) && false) ? {
|
||||||
|
"Accept-Language": lang[argv.region].langCode,
|
||||||
|
} : {}
|
||||||
|
|
||||||
|
|
||||||
let gOptions = {
|
let gOptions = {
|
||||||
url: options.url,
|
url: options.url,
|
||||||
headers: {
|
headers: {
|
||||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:70.0) Gecko/20100101 Firefox/70.0',
|
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:70.0) Gecko/20100101 Firefox/70.0',
|
||||||
|
"devicetype": "Android Phone",
|
||||||
|
"Accept-Encoding": "gzip",
|
||||||
|
...regionHeaders
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if(options.responseType) {
|
if(options.responseType) {
|
||||||
gOptions.responseType = options.responseType;
|
gOptions.responseType = options.responseType
|
||||||
}
|
}
|
||||||
if(options.baseUrl){
|
if(options.baseUrl){
|
||||||
gOptions.prefixUrl = options.baseUrl;
|
gOptions.prefixUrl = options.baseUrl;
|
||||||
|
|
@ -21,9 +41,16 @@ const getData = async (options) => {
|
||||||
}
|
}
|
||||||
if(options.auth){
|
if(options.auth){
|
||||||
gOptions.method = 'POST';
|
gOptions.method = 'POST';
|
||||||
gOptions.body = new FormData();
|
gOptions.headers["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8"
|
||||||
gOptions.body.append('username', options.auth.user);
|
gOptions.headers["Origin"] = "https://www.funimation.com"
|
||||||
gOptions.body.append('password', options.auth.pass);
|
gOptions.headers["Accept"] = "application/json, text/javascript, */*; q=0.01"
|
||||||
|
gOptions.headers["Accept-Encoding"] = "gzip, deflate, br"
|
||||||
|
gOptions.headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
|
||||||
|
gOptions.body = `username=${encodeURIComponent(options.auth.user)}&password=${encodeURIComponent(options.auth.pass)}`
|
||||||
|
// if (argv.region !== undefined) {
|
||||||
|
// gOptions.headers["Territory"] = lang[argv.region].regionCode
|
||||||
|
// gOptions.headers["Accept-Language"] = `${lang[argv.region].langCode},en;q=0.5`
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
if(options.useToken && options.token){
|
if(options.useToken && options.token){
|
||||||
gOptions.headers.Authorization = `Token ${options.token}`;
|
gOptions.headers.Authorization = `Token ${options.token}`;
|
||||||
|
|
@ -71,6 +98,6 @@ const getData = async (options) => {
|
||||||
error,
|
error,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = getData;
|
module.exports = getData;
|
||||||
|
|
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "funimation-downloader-nx",
|
"name": "funimation-downloader-nx",
|
||||||
"version": "4.9.1",
|
"version": "4.9.4",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "4.9.1",
|
"version": "4.9.4",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"form-data": "^3.0.0",
|
"form-data": "^3.0.0",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue