wip
This commit is contained in:
commit
26f86e7e97
33
.eslintrc.js
Normal file
33
.eslintrc.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
module.exports = {
|
||||||
|
"env": {
|
||||||
|
"es2021": true,
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended"
|
||||||
|
],
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
".eslintrc.{js,cjs}"
|
||||||
|
],
|
||||||
|
"parserOptions": {
|
||||||
|
"sourceType": "script"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
}
|
||||||
|
}
|
175
.gitignore
vendored
Normal file
175
.gitignore
vendored
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
|
||||||
|
logs
|
||||||
|
_.log
|
||||||
|
npm-debug.log_
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# Caches
|
||||||
|
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
|
||||||
|
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
|
||||||
|
pids
|
||||||
|
_.pid
|
||||||
|
_.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# Snowpack dependency directory (https://snowpack.dev/)
|
||||||
|
|
||||||
|
web_modules/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
|
||||||
|
.env
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
|
||||||
|
.next
|
||||||
|
out
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# vuepress v2.x temp and cache directory
|
||||||
|
|
||||||
|
.temp
|
||||||
|
|
||||||
|
# Docusaurus cache and generated files
|
||||||
|
|
||||||
|
.docusaurus
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
# yarn v2
|
||||||
|
|
||||||
|
.yarn/cache
|
||||||
|
.yarn/unplugged
|
||||||
|
.yarn/build-state.yml
|
||||||
|
.yarn/install-state.gz
|
||||||
|
.pnp.*
|
||||||
|
|
||||||
|
# IntelliJ based IDEs
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# Finder (MacOS) folder config
|
||||||
|
.DS_Store
|
11
.prettierrc
Normal file
11
.prettierrc
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 120,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"useTabs": true,
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"jsxBracketSameLine": false,
|
||||||
|
"arrowParens": "avoid"
|
||||||
|
}
|
30
package.json
Normal file
30
package.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "nikokari-downloader-node",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node dist/index.js",
|
||||||
|
"build": "tsc src/index.ts --outDir dist",
|
||||||
|
"dev": "tsx watch src/index.ts",
|
||||||
|
"prettier": "prettier --write \"src/**/*.ts\"",
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^20.14.8",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^7.13.1",
|
||||||
|
"@typescript-eslint/parser": "^7.13.1",
|
||||||
|
"eslint": "^9.5.0",
|
||||||
|
"eslint-config-prettier": "^9.1.0",
|
||||||
|
"prettier": "^3.3.2",
|
||||||
|
"tsx": "^4.15.7"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"dotenv": "^16.4.5",
|
||||||
|
"m3u8-parser": "^7.1.0",
|
||||||
|
"typescript": "^5.5.2"
|
||||||
|
}
|
||||||
|
}
|
1236
pnpm-lock.yaml
generated
Normal file
1236
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
333
src/api.ts
Normal file
333
src/api.ts
Normal file
@ -0,0 +1,333 @@
|
|||||||
|
import { UserAgent, frontendId, frontendVersion } from './constants';
|
||||||
|
import { GenerateHlsSessionResponse, GetVideoInfoResponse } from './types/response';
|
||||||
|
import { objToUrlParams } from './utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param id sm11448603
|
||||||
|
*/
|
||||||
|
export async function getVideoInfo(id: string) {
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"meta": {
|
||||||
|
"status": 200
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"client": {
|
||||||
|
"nicosid": "1719238556.1102796574",
|
||||||
|
"watchId": "sm11448603",
|
||||||
|
"watchTrackId": "YTLfJqsNf4_1719238557065"
|
||||||
|
},
|
||||||
|
"genre": {
|
||||||
|
"key": "music_sound",
|
||||||
|
"label": "音楽・サウンド",
|
||||||
|
"isImmoral": false,
|
||||||
|
"isDisabled": false,
|
||||||
|
"isNotSet": false
|
||||||
|
},
|
||||||
|
"media": {
|
||||||
|
"domand": {
|
||||||
|
"videos": [
|
||||||
|
{
|
||||||
|
"id": "video-h264-720p",
|
||||||
|
"isAvailable": true,
|
||||||
|
"label": "720p",
|
||||||
|
"bitRate": 1471070,
|
||||||
|
"width": 960,
|
||||||
|
"height": 720,
|
||||||
|
"qualityLevel": 3,
|
||||||
|
"recommendedHighestAudioQualityLevel": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "video-h264-480p",
|
||||||
|
"isAvailable": true,
|
||||||
|
"label": "480p",
|
||||||
|
"bitRate": 699517,
|
||||||
|
"width": 640,
|
||||||
|
"height": 480,
|
||||||
|
"qualityLevel": 2,
|
||||||
|
"recommendedHighestAudioQualityLevel": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "video-h264-360p",
|
||||||
|
"isAvailable": true,
|
||||||
|
"label": "360p",
|
||||||
|
"bitRate": 555849,
|
||||||
|
"width": 480,
|
||||||
|
"height": 360,
|
||||||
|
"qualityLevel": 1,
|
||||||
|
"recommendedHighestAudioQualityLevel": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "video-h264-360p-lowest",
|
||||||
|
"isAvailable": true,
|
||||||
|
"label": "低画質",
|
||||||
|
"bitRate": 301851,
|
||||||
|
"width": 480,
|
||||||
|
"height": 360,
|
||||||
|
"qualityLevel": 0,
|
||||||
|
"recommendedHighestAudioQualityLevel": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"audios": [
|
||||||
|
{
|
||||||
|
"id": "audio-aac-192kbps",
|
||||||
|
"isAvailable": true,
|
||||||
|
"bitRate": 178506,
|
||||||
|
"samplingRate": 44100,
|
||||||
|
"integratedLoudness": -7.9000000000000003552713678800500929355621337890625,
|
||||||
|
"truePeak": 0.59999999999999997779553950749686919152736663818359375,
|
||||||
|
"qualityLevel": 1,
|
||||||
|
"loudnessCollection": [
|
||||||
|
{
|
||||||
|
"type": "video",
|
||||||
|
"value": 0.44157044735331252294230353072634898126125335693359375
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "pureAdPreroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "houseAdPreroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "networkAdPreroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "pureAdMidroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "houseAdMidroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "networkAdMidroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "pureAdPostroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "houseAdPostroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "networkAdPostroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "nicoadVideoIntroduce",
|
||||||
|
"value": 0.89125093813374556273032567332847975194454193115234375
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "nicoadBillboard",
|
||||||
|
"value": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "marquee",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "audio-aac-64kbps",
|
||||||
|
"isAvailable": true,
|
||||||
|
"bitRate": 92609,
|
||||||
|
"samplingRate": 44100,
|
||||||
|
"integratedLoudness": -7.9000000000000003552713678800500929355621337890625,
|
||||||
|
"truePeak": 0.59999999999999997779553950749686919152736663818359375,
|
||||||
|
"qualityLevel": 0,
|
||||||
|
"loudnessCollection": [
|
||||||
|
{
|
||||||
|
"type": "video",
|
||||||
|
"value": 0.44157044735331252294230353072634898126125335693359375
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "pureAdPreroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "houseAdPreroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "networkAdPreroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "pureAdMidroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "houseAdMidroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "networkAdMidroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "pureAdPostroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "houseAdPostroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "networkAdPostroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "nicoadVideoIntroduce",
|
||||||
|
"value": 0.89125093813374556273032567332847975194454193115234375
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "nicoadBillboard",
|
||||||
|
"value": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "marquee",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isStoryboardAvailable": false,
|
||||||
|
"accessRightKey": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJqdGkiOiI2Njc5N2Y5ZDE3MjMzIiwiZXhwIjoxNzE5MjM5MTU3LCJ0eXAiOiJBY2Nlc3MtUmlnaHQtS2V5IiwidmlkIjoic20xMTQ0ODYwMyIsInJpZCI6Im5pY292aWRlby1zbTExNDQ4NjAzIiwiZmlkIjo2LCJ1aWQiOiI2LVlUTGZKcXNOZjRfMTcxOTIzODU1NzA2NSIsImQiOjI4OCwidiI6WyJ2aWRlby1oMjY0LTcyMHAiLCJ2aWRlby1oMjY0LTQ4MHAiLCJ2aWRlby1oMjY0LTM2MHAiLCJ2aWRlby1oMjY0LTM2MHAtbG93ZXN0Il0sImEiOlsiYXVkaW8tYWFjLTE5MmticHMiLCJhdWRpby1hYWMtNjRrYnBzIl0sInMiOmZhbHNlLCJzaCI6ZmFsc2V9.lSUYPHzPGs7ChsfBHd0jY3_3zS2yGBLtk8M2qZNIXzfjMZzTPcnDMH02iedO5MagJYIuAmculBlkQI25h4VQzg"
|
||||||
|
},
|
||||||
|
"delivery": null,
|
||||||
|
"deliveryLegacy": null
|
||||||
|
},
|
||||||
|
"tag": {
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"name": "VOCALOID",
|
||||||
|
"isLocked": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "mztm",
|
||||||
|
"isLocked": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "蛍草",
|
||||||
|
"isLocked": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ハロ/ハワユ",
|
||||||
|
"isLocked": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ナノウ",
|
||||||
|
"isLocked": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "初音ミク",
|
||||||
|
"isLocked": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ミクオリジナル曲",
|
||||||
|
"isLocked": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ほえほえP",
|
||||||
|
"isLocked": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "VOCALOID伝説入り",
|
||||||
|
"isLocked": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "DAM&JOY配信中",
|
||||||
|
"isLocked": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "初音ミク名曲リンク",
|
||||||
|
"isLocked": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"video": {
|
||||||
|
"id": "sm11448603",
|
||||||
|
"title": "【初音ミクSoft】 ハロ/ハワユ 【オリジナル】",
|
||||||
|
"description": "詞&曲 : ナノウ (mylist\/9634824)<br \/>絵 : mztm (http:\/\/piapro.jp\/nico0410)<br \/>動画 : 蛍草 (mylist\/18321757)<br \/><br \/><br \/>※ニンテンドー3DS『初音ミク and Future Stars Project mirai』に、この曲が収録されました。<br \/>→ http:\/\/miku.sega.jp\/mirai\/<br \/><br \/>カラオケ → http:\/\/piapro.jp\/nir580<br \/><br \/><br \/>mylist\/34696796",
|
||||||
|
"count": {
|
||||||
|
"view": 3275900,
|
||||||
|
"comment": 43870,
|
||||||
|
"mylist": 72662,
|
||||||
|
"like": 3676
|
||||||
|
},
|
||||||
|
"duration": 288,
|
||||||
|
"thumbnail": {
|
||||||
|
"url": "https:\/\/nicovideo.cdn.nimg.jp\/thumbnails\/11448603\/11448603",
|
||||||
|
"middleUrl": null,
|
||||||
|
"largeUrl": null,
|
||||||
|
"player": "https:\/\/img.cdn.nimg.jp\/s\/nicovideo\/thumbnails\/11448603\/11448603.original\/a960x540l?key=b754efe8996ff38d0d93d7e620d33cefa4a9e0bd495f4356b5d6744f93f11d2a",
|
||||||
|
"ogp": "https:\/\/img.cdn.nimg.jp\/s\/nicovideo\/thumbnails\/11448603\/11448603.original\/r1280x720l?key=c0ee356e6d888a5351409da0d3216e1e22accc0aa56788c425f63c3397f3a223"
|
||||||
|
},
|
||||||
|
"registeredAt": "2010-07-20T01:13:28+09:00"
|
||||||
|
},
|
||||||
|
"ownerNickname": "ナノウ"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
const url = 'https://www.nicovideo.jp/api/watch/tmp/';
|
||||||
|
const params = {
|
||||||
|
_frontendId: frontendId,
|
||||||
|
_frontendVersion: frontendVersion,
|
||||||
|
};
|
||||||
|
const res = await fetch(`${url}${id}?${objToUrlParams(params)}`, {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': UserAgent,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const json: GetVideoInfoResponse = await res.json();
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function generateHlsSession(id: string, videoInfo: GetVideoInfoResponse) {
|
||||||
|
const params = {
|
||||||
|
actionTrackId: videoInfo.data.client.watchTrackId,
|
||||||
|
_frontendId: frontendId,
|
||||||
|
_frontendVersion: frontendVersion,
|
||||||
|
};
|
||||||
|
|
||||||
|
const videoAudioPairs = videoInfo.data.media.domand.videos.map(video => {
|
||||||
|
const audio = videoInfo.data.media.domand.audios.find(
|
||||||
|
audio => audio.qualityLevel === video.recommendedHighestAudioQualityLevel,
|
||||||
|
);
|
||||||
|
if (!audio) {
|
||||||
|
throw new Error('Audio not found');
|
||||||
|
}
|
||||||
|
return [video.id, audio.id];
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await fetch(`https://nvapi.nicovideo.jp/v1/tmp/watch/${id}/access-rights/hls?${objToUrlParams(params)}`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
outputs: videoAudioPairs,
|
||||||
|
}),
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'User-Agent': UserAgent,
|
||||||
|
'X-Access-Right-Key': videoInfo.data.media.domand.accessRightKey,
|
||||||
|
'X-Request-With': 'https://www.nicovideo.jp',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const cookie = res.headers.get('set-cookie');
|
||||||
|
|
||||||
|
const json: GenerateHlsSessionResponse = await res.json();
|
||||||
|
|
||||||
|
return {
|
||||||
|
cookie,
|
||||||
|
data: json,
|
||||||
|
};
|
||||||
|
}
|
18
src/constants.ts
Normal file
18
src/constants.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { RequestBase } from './types/request';
|
||||||
|
|
||||||
|
export const UserAgent = 'WindowsApplication';
|
||||||
|
|
||||||
|
export const CriUserAgent = 'CriHttpRequest';
|
||||||
|
|
||||||
|
export const GuestUser = {
|
||||||
|
loginId: '4a6utb743fkuk7d2',
|
||||||
|
password: '966n4jazzuai5e4x',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const requestBase: RequestBase = {
|
||||||
|
charset: 'UTF-8',
|
||||||
|
format: 'json',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const frontendId = 6;
|
||||||
|
export const frontendVersion = '0.0.0';
|
47
src/index.ts
Normal file
47
src/index.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import { generateHlsSession, getVideoInfo } from './api';
|
||||||
|
import { UserAgent } from './constants';
|
||||||
|
import { cookieStringToObj, downloadAesM3u8, getMediaPair, objToCookieString } from './utils';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
const videoId = 'sm11448603';
|
||||||
|
(async () => {
|
||||||
|
const videoInfo = await getVideoInfo(videoId);
|
||||||
|
// console.log(videoInfo);
|
||||||
|
const videoSession = await generateHlsSession(videoId, videoInfo);
|
||||||
|
// console.log(videoSession);
|
||||||
|
|
||||||
|
const expireTime = new Date(videoSession.data.data.expireTime);
|
||||||
|
const currentTime = new Date();
|
||||||
|
if (expireTime < currentTime) {
|
||||||
|
console.error('Session expired');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const highestVideo = videoInfo.data.media.domand.videos.sort((a, b) => b.qualityLevel - a.qualityLevel)[0];
|
||||||
|
const highestAudio = videoInfo.data.media.domand.audios.sort((a, b) => b.qualityLevel - a.qualityLevel)[0];
|
||||||
|
|
||||||
|
console.log(videoSession.data.data.contentUrl);
|
||||||
|
const cookie = objToCookieString({
|
||||||
|
nicosid: videoInfo.data.client.nicosid,
|
||||||
|
domand_bid: cookieStringToObj(videoSession.cookie).domand_bid,
|
||||||
|
});
|
||||||
|
const m3u8 = await fetch(videoSession.data.data.contentUrl, {
|
||||||
|
headers: {
|
||||||
|
Cookie: cookie,
|
||||||
|
'User-Agent': UserAgent,
|
||||||
|
},
|
||||||
|
}).then(res => res.text());
|
||||||
|
|
||||||
|
// console.log(m3u8);
|
||||||
|
|
||||||
|
const mediaPair = getMediaPair(highestVideo.id, highestAudio.id, m3u8);
|
||||||
|
// console.log(JSON.stringify(mediaPair, null, 2));
|
||||||
|
|
||||||
|
const video = await downloadAesM3u8(mediaPair.video?.uri, cookie);
|
||||||
|
fs.writeFileSync('video.mp4', Buffer.from(video));
|
||||||
|
|
||||||
|
// console.log(mediaPair.audio);
|
||||||
|
const audio = await downloadAesM3u8(mediaPair.audio['Main Audio'].uri, cookie);
|
||||||
|
fs.writeFileSync('audio.mp4', Buffer.from(audio));
|
||||||
|
|
||||||
|
})();
|
10
src/types/general.ts
Normal file
10
src/types/general.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
export type APIUser = {
|
||||||
|
userCode: string;
|
||||||
|
authToken: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export enum SearchAutoCompleteType {
|
||||||
|
Keyword = 0,
|
||||||
|
Music = 1,
|
||||||
|
Artist = 2,
|
||||||
|
}
|
140
src/types/request.ts
Normal file
140
src/types/request.ts
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
import { APIUser, SearchAutoCompleteType } from './general';
|
||||||
|
|
||||||
|
export type RequestBase = {
|
||||||
|
charset: 'UTF-8';
|
||||||
|
format: 'json';
|
||||||
|
};
|
||||||
|
|
||||||
|
export type LoginRequest = RequestBase & {
|
||||||
|
loginId: string;
|
||||||
|
password: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type LogoutRequest = RequestBase &
|
||||||
|
APIUser & {
|
||||||
|
compId: 1;
|
||||||
|
compAuthKey: '2/Qb9R@8s*';
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetMusicDetailRequest = RequestBase &
|
||||||
|
APIUser & {
|
||||||
|
compId: 1;
|
||||||
|
compAuthKey: '2/Qb9R@8s*';
|
||||||
|
deviceId: 22;
|
||||||
|
requestNo: string;
|
||||||
|
serviceId: 1;
|
||||||
|
contractId: 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetMusicStreamingURLRequest = RequestBase &
|
||||||
|
APIUser & {
|
||||||
|
compId: 1;
|
||||||
|
compAuthKey: '2/Qb9R@8s*';
|
||||||
|
deviceId: 22;
|
||||||
|
serviceId: 1;
|
||||||
|
requestNo: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetMusicRankingTermRequest = RequestBase &
|
||||||
|
APIUser & {
|
||||||
|
compId: 1;
|
||||||
|
compAuthKey: '2/Qb9R@8s*';
|
||||||
|
dispNumber: 1000;
|
||||||
|
pageNo: 1;
|
||||||
|
targetContractId: 0;
|
||||||
|
/**
|
||||||
|
* 202311
|
||||||
|
* YYYYmm
|
||||||
|
*/
|
||||||
|
targetStartDateFrom: number;
|
||||||
|
targetStartDateTo: number;
|
||||||
|
targetEndDateFrom: number;
|
||||||
|
targetEndDateTo: number;
|
||||||
|
sort: 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetMusicRankingRequest = RequestBase &
|
||||||
|
APIUser & {
|
||||||
|
compId: 1;
|
||||||
|
compAuthKey: '2/Qb9R@8s*';
|
||||||
|
dispNumber: 30;
|
||||||
|
pageNo: number;
|
||||||
|
targetContractId: 1;
|
||||||
|
musicViewsRankingId: number;
|
||||||
|
serviceId: 1;
|
||||||
|
deviceId: 22;
|
||||||
|
getCount: 200;
|
||||||
|
thumbnailType: 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SearchAutoCompleteRequest = APIUser & {
|
||||||
|
authKey: '2/Qb9R@8s*';
|
||||||
|
compId: 1;
|
||||||
|
keyword: string;
|
||||||
|
minseiModelNum: 'M1';
|
||||||
|
modelTypeCode: 2;
|
||||||
|
responseInfoType: SearchAutoCompleteType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetNewReleaseMusicRequest = RequestBase &
|
||||||
|
APIUser & {
|
||||||
|
compId: 1;
|
||||||
|
compAuthKey: '2/Qb9R@8s*';
|
||||||
|
deliveryRelativeWeek: 0;
|
||||||
|
dispNumber: 30;
|
||||||
|
pageNo: number;
|
||||||
|
serviceId: 1;
|
||||||
|
deviceId: 22;
|
||||||
|
targetContractId: 1;
|
||||||
|
thumbnailType: 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SearchVariousByKeywordRequest = APIUser & {
|
||||||
|
authKey: '2/Qb9R@8s*';
|
||||||
|
compId: 1;
|
||||||
|
dispCount: 30;
|
||||||
|
keyword: string;
|
||||||
|
minseiModelNum: 'M1';
|
||||||
|
modelPatternCode: 0;
|
||||||
|
modelTypeCode: 2;
|
||||||
|
pageNo: number;
|
||||||
|
shopType: '02';
|
||||||
|
sort: 2;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SearchMusicByKeywordRequest = APIUser & {
|
||||||
|
authKey: '2/Qb9R@8s*';
|
||||||
|
compId: 1;
|
||||||
|
dispCount: 30;
|
||||||
|
keyword: string;
|
||||||
|
minseiModelNum: 'M1';
|
||||||
|
modelPatternCode: 1;
|
||||||
|
modelTypeCode: 2;
|
||||||
|
pageNo: number;
|
||||||
|
shopType: '02';
|
||||||
|
sort: 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SearchArtistByKeywordRequest = APIUser & {
|
||||||
|
authKey: '2/Qb9R@8s*';
|
||||||
|
compId: 1;
|
||||||
|
dispCount: 30;
|
||||||
|
keyword: string;
|
||||||
|
minseiModelNum: 'M1';
|
||||||
|
modelPatternCode: 1;
|
||||||
|
modelTypeCode: 2;
|
||||||
|
pageNo: number;
|
||||||
|
shopType: '02';
|
||||||
|
sort: 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetMusicListByArtistRequest = APIUser & {
|
||||||
|
artistCode: number;
|
||||||
|
authKey: '2/Qb9R@8s*';
|
||||||
|
compId: 1;
|
||||||
|
dispCount: 30;
|
||||||
|
minseiModelNum: 'M1';
|
||||||
|
modelTypeCode: 2;
|
||||||
|
pageNo: number;
|
||||||
|
sort: 1;
|
||||||
|
};
|
576
src/types/response.ts
Normal file
576
src/types/response.ts
Normal file
@ -0,0 +1,576 @@
|
|||||||
|
export type GetVideoInfoResponse = JsonAPIResponse<{
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"meta": {
|
||||||
|
"status": 200
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"client": {
|
||||||
|
"nicosid": "1719238556.1102796574",
|
||||||
|
"watchId": "sm11448603",
|
||||||
|
"watchTrackId": "YTLfJqsNf4_1719238557065"
|
||||||
|
},
|
||||||
|
"genre": {
|
||||||
|
"key": "music_sound",
|
||||||
|
"label": "音楽・サウンド",
|
||||||
|
"isImmoral": false,
|
||||||
|
"isDisabled": false,
|
||||||
|
"isNotSet": false
|
||||||
|
},
|
||||||
|
"media": {
|
||||||
|
"domand": {
|
||||||
|
"videos": [
|
||||||
|
{
|
||||||
|
"id": "video-h264-720p",
|
||||||
|
"isAvailable": true,
|
||||||
|
"label": "720p",
|
||||||
|
"bitRate": 1471070,
|
||||||
|
"width": 960,
|
||||||
|
"height": 720,
|
||||||
|
"qualityLevel": 3,
|
||||||
|
"recommendedHighestAudioQualityLevel": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "video-h264-480p",
|
||||||
|
"isAvailable": true,
|
||||||
|
"label": "480p",
|
||||||
|
"bitRate": 699517,
|
||||||
|
"width": 640,
|
||||||
|
"height": 480,
|
||||||
|
"qualityLevel": 2,
|
||||||
|
"recommendedHighestAudioQualityLevel": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "video-h264-360p",
|
||||||
|
"isAvailable": true,
|
||||||
|
"label": "360p",
|
||||||
|
"bitRate": 555849,
|
||||||
|
"width": 480,
|
||||||
|
"height": 360,
|
||||||
|
"qualityLevel": 1,
|
||||||
|
"recommendedHighestAudioQualityLevel": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "video-h264-360p-lowest",
|
||||||
|
"isAvailable": true,
|
||||||
|
"label": "低画質",
|
||||||
|
"bitRate": 301851,
|
||||||
|
"width": 480,
|
||||||
|
"height": 360,
|
||||||
|
"qualityLevel": 0,
|
||||||
|
"recommendedHighestAudioQualityLevel": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"audios": [
|
||||||
|
{
|
||||||
|
"id": "audio-aac-192kbps",
|
||||||
|
"isAvailable": true,
|
||||||
|
"bitRate": 178506,
|
||||||
|
"samplingRate": 44100,
|
||||||
|
"integratedLoudness": -7.9000000000000003552713678800500929355621337890625,
|
||||||
|
"truePeak": 0.59999999999999997779553950749686919152736663818359375,
|
||||||
|
"qualityLevel": 1,
|
||||||
|
"loudnessCollection": [
|
||||||
|
{
|
||||||
|
"type": "video",
|
||||||
|
"value": 0.44157044735331252294230353072634898126125335693359375
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "pureAdPreroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "houseAdPreroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "networkAdPreroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "pureAdMidroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "houseAdMidroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "networkAdMidroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "pureAdPostroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "houseAdPostroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "networkAdPostroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "nicoadVideoIntroduce",
|
||||||
|
"value": 0.89125093813374556273032567332847975194454193115234375
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "nicoadBillboard",
|
||||||
|
"value": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "marquee",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "audio-aac-64kbps",
|
||||||
|
"isAvailable": true,
|
||||||
|
"bitRate": 92609,
|
||||||
|
"samplingRate": 44100,
|
||||||
|
"integratedLoudness": -7.9000000000000003552713678800500929355621337890625,
|
||||||
|
"truePeak": 0.59999999999999997779553950749686919152736663818359375,
|
||||||
|
"qualityLevel": 0,
|
||||||
|
"loudnessCollection": [
|
||||||
|
{
|
||||||
|
"type": "video",
|
||||||
|
"value": 0.44157044735331252294230353072634898126125335693359375
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "pureAdPreroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "houseAdPreroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "networkAdPreroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "pureAdMidroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "houseAdMidroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "networkAdMidroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "pureAdPostroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "houseAdPostroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "networkAdPostroll",
|
||||||
|
"value": 0.7079457843841379105498390345019288361072540283203125
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "nicoadVideoIntroduce",
|
||||||
|
"value": 0.89125093813374556273032567332847975194454193115234375
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "nicoadBillboard",
|
||||||
|
"value": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "marquee",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isStoryboardAvailable": false,
|
||||||
|
"accessRightKey": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJqdGkiOiI2Njc5N2Y5ZDE3MjMzIiwiZXhwIjoxNzE5MjM5MTU3LCJ0eXAiOiJBY2Nlc3MtUmlnaHQtS2V5IiwidmlkIjoic20xMTQ0ODYwMyIsInJpZCI6Im5pY292aWRlby1zbTExNDQ4NjAzIiwiZmlkIjo2LCJ1aWQiOiI2LVlUTGZKcXNOZjRfMTcxOTIzODU1NzA2NSIsImQiOjI4OCwidiI6WyJ2aWRlby1oMjY0LTcyMHAiLCJ2aWRlby1oMjY0LTQ4MHAiLCJ2aWRlby1oMjY0LTM2MHAiLCJ2aWRlby1oMjY0LTM2MHAtbG93ZXN0Il0sImEiOlsiYXVkaW8tYWFjLTE5MmticHMiLCJhdWRpby1hYWMtNjRrYnBzIl0sInMiOmZhbHNlLCJzaCI6ZmFsc2V9.lSUYPHzPGs7ChsfBHd0jY3_3zS2yGBLtk8M2qZNIXzfjMZzTPcnDMH02iedO5MagJYIuAmculBlkQI25h4VQzg"
|
||||||
|
},
|
||||||
|
"delivery": null,
|
||||||
|
"deliveryLegacy": null
|
||||||
|
},
|
||||||
|
"tag": {
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"name": "VOCALOID",
|
||||||
|
"isLocked": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "mztm",
|
||||||
|
"isLocked": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "蛍草",
|
||||||
|
"isLocked": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ハロ/ハワユ",
|
||||||
|
"isLocked": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ナノウ",
|
||||||
|
"isLocked": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "初音ミク",
|
||||||
|
"isLocked": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ミクオリジナル曲",
|
||||||
|
"isLocked": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ほえほえP",
|
||||||
|
"isLocked": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "VOCALOID伝説入り",
|
||||||
|
"isLocked": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "DAM&JOY配信中",
|
||||||
|
"isLocked": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "初音ミク名曲リンク",
|
||||||
|
"isLocked": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"video": {
|
||||||
|
"id": "sm11448603",
|
||||||
|
"title": "【初音ミクSoft】 ハロ/ハワユ 【オリジナル】",
|
||||||
|
"description": "詞&曲 : ナノウ (mylist\/9634824)<br \/>絵 : mztm (http:\/\/piapro.jp\/nico0410)<br \/>動画 : 蛍草 (mylist\/18321757)<br \/><br \/><br \/>※ニンテンドー3DS『初音ミク and Future Stars Project mirai』に、この曲が収録されました。<br \/>→ http:\/\/miku.sega.jp\/mirai\/<br \/><br \/>カラオケ → http:\/\/piapro.jp\/nir580<br \/><br \/><br \/>mylist\/34696796",
|
||||||
|
"count": {
|
||||||
|
"view": 3275900,
|
||||||
|
"comment": 43870,
|
||||||
|
"mylist": 72662,
|
||||||
|
"like": 3676
|
||||||
|
},
|
||||||
|
"duration": 288,
|
||||||
|
"thumbnail": {
|
||||||
|
"url": "https:\/\/nicovideo.cdn.nimg.jp\/thumbnails\/11448603\/11448603",
|
||||||
|
"middleUrl": null,
|
||||||
|
"largeUrl": null,
|
||||||
|
"player": "https:\/\/img.cdn.nimg.jp\/s\/nicovideo\/thumbnails\/11448603\/11448603.original\/a960x540l?key=b754efe8996ff38d0d93d7e620d33cefa4a9e0bd495f4356b5d6744f93f11d2a",
|
||||||
|
"ogp": "https:\/\/img.cdn.nimg.jp\/s\/nicovideo\/thumbnails\/11448603\/11448603.original\/r1280x720l?key=c0ee356e6d888a5351409da0d3216e1e22accc0aa56788c425f63c3397f3a223"
|
||||||
|
},
|
||||||
|
"registeredAt": "2010-07-20T01:13:28+09:00"
|
||||||
|
},
|
||||||
|
"ownerNickname": "ナノウ"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
client: {
|
||||||
|
nicosid: string;
|
||||||
|
watchId: string;
|
||||||
|
watchTrackId: string;
|
||||||
|
};
|
||||||
|
genre: {
|
||||||
|
key: string;
|
||||||
|
label: string;
|
||||||
|
isImmoral: boolean;
|
||||||
|
isDisabled: boolean;
|
||||||
|
isNotSet: boolean;
|
||||||
|
};
|
||||||
|
media: {
|
||||||
|
domand: {
|
||||||
|
videos: {
|
||||||
|
id: string;
|
||||||
|
isAvailable: boolean;
|
||||||
|
label: string;
|
||||||
|
bitRate: number;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
qualityLevel: number;
|
||||||
|
recommendedHighestAudioQualityLevel: number;
|
||||||
|
}[];
|
||||||
|
audios: {
|
||||||
|
id: string;
|
||||||
|
isAvailable: boolean;
|
||||||
|
bitRate: number;
|
||||||
|
samplingRate: number;
|
||||||
|
integratedLoudnessintegratedLoudness: number;
|
||||||
|
truePeak: number;
|
||||||
|
qualityLevel: number;
|
||||||
|
loudnessCollection: {
|
||||||
|
type: string;
|
||||||
|
value: number;
|
||||||
|
}[];
|
||||||
|
}[];
|
||||||
|
isStoryboardAvailable: boolean | null;
|
||||||
|
accessRightKey: string;
|
||||||
|
};
|
||||||
|
delivery: object | null;
|
||||||
|
deliveryLegacy: object | null;
|
||||||
|
};
|
||||||
|
tag: {
|
||||||
|
items: {
|
||||||
|
name: string;
|
||||||
|
isLocked: boolean;
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
video: {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
count: {
|
||||||
|
view: number;
|
||||||
|
comment: number;
|
||||||
|
mylist: number;
|
||||||
|
like: number;
|
||||||
|
};
|
||||||
|
duration: number;
|
||||||
|
thumbnail: {
|
||||||
|
url: string;
|
||||||
|
middleUrl: string | null;
|
||||||
|
largeUrl: string | null;
|
||||||
|
player: string;
|
||||||
|
ogp: string;
|
||||||
|
};
|
||||||
|
registeredAt: string;
|
||||||
|
};
|
||||||
|
ownerNickname: string;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
export type GenerateHlsSessionResponse = JsonAPIResponse<{
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"meta": {
|
||||||
|
"status": 201
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"contentUrl": "https://delivery.domand.nicovideo.jp/hlsbid/65361c1070b2ba9a714e625a/playlists/variants/98242b0e8e144626.m3u8?session=54eec16681fdfd3f67508da9718b863498242b0e8e14462600000000667ad11d76f33be01c6b2915&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kZWxpdmVyeS5kb21hbmQubmljb3ZpZGVvLmpwL2hsc2JpZC82NTM2MWMxMDcwYjJiYTlhNzE0ZTYyNWEvcGxheWxpc3RzL3ZhcmlhbnRzLzk4MjQyYjBlOGUxNDQ2MjYubTN1OFxcPyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3MTkzMjQ5NTd9fX1dfQ__&Signature=iUfOfsePAAFzZSfiT4li2OXQHjSpyNqQ3kY3YwPNwKsHR3lmxDzLmcY5ZEWvAiI5bClGS0wtoxBl2XRkY-q0nnlA5uaYLe1pmdiTxyBvo~7TiqQ7493vJGI4avhiUp9uWf6Ow3ORi1sD3s~D0ExkU7lG-GcBIsNnL3SOwabS44UnlbyMyhTzdse9FZEYnZ-qHYZd-blaNnKGbP~MsohQUrptJ80-hKpJ2GDPjHS70TLEVVvrAw0Gg-29O4meQQHKHrUhrWRs8mo3yYPOw1RDVljs~GCtjwOyilPsKjyauSVqwWH79kuJQSQGGrNaarkHrmoDIndgG12n2MRsT8lB7g__&Key-Pair-Id=K11RB80NFXU134",
|
||||||
|
"createTime": "2024-06-24T23:15:57+09:00",
|
||||||
|
"expireTime": "2024-06-25T23:15:57+09:00"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
contentUrl: string;
|
||||||
|
createTime: string; // 2024-06-24T23:15:57+09:00
|
||||||
|
expireTime: string;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
export type JsonAPIResponseBase = {
|
||||||
|
meta: {
|
||||||
|
status: number;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type JsonAPIResponse<T> = JsonAPIResponseBase & {
|
||||||
|
data: T;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type JsonListAPIResponse<T, L> = JsonAPIResponse<T> & {
|
||||||
|
list: L[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PaginationData = {
|
||||||
|
dataCount: string;
|
||||||
|
hasNext: string;
|
||||||
|
hasPreview: string;
|
||||||
|
overFlg: string;
|
||||||
|
pageCount: string;
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type LoginByDamtomoMemberIdResponse = {
|
||||||
|
authToken: string;
|
||||||
|
damtomoId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetMusicDetailResponse = {
|
||||||
|
artistCode: string;
|
||||||
|
artistName: string;
|
||||||
|
contentsId: string;
|
||||||
|
contentsYomi: string;
|
||||||
|
firstLine: string;
|
||||||
|
guideVocalList: {
|
||||||
|
contentsId: string;
|
||||||
|
duet: string;
|
||||||
|
playtime: string;
|
||||||
|
}[];
|
||||||
|
musicTypeList: {
|
||||||
|
musicTypeCode: string;
|
||||||
|
musicTypeId: string;
|
||||||
|
musicTypeName: string;
|
||||||
|
}[];
|
||||||
|
mylist: string;
|
||||||
|
requestNo: string;
|
||||||
|
songDifficulty: string;
|
||||||
|
songTechDifficulty: string;
|
||||||
|
thumbnailPathList: {
|
||||||
|
thumbnailPath: string;
|
||||||
|
thumbnailType: string;
|
||||||
|
}[];
|
||||||
|
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetMusicStreamingURLResponseData = {
|
||||||
|
karaokeContentsId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetMusicStreamingURLResponseList = {
|
||||||
|
contentsId: string;
|
||||||
|
duet: string;
|
||||||
|
highBitrateUrl: string;
|
||||||
|
lowBitrateUrl: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetMusicRankingTermResponseList = {
|
||||||
|
from: string;
|
||||||
|
to: string;
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetMusicRankingResponseList = {
|
||||||
|
artistCd: string;
|
||||||
|
artistName: string;
|
||||||
|
contentsId: string;
|
||||||
|
contentsName: string;
|
||||||
|
female: string;
|
||||||
|
lyrics: string;
|
||||||
|
male: string;
|
||||||
|
mix: string;
|
||||||
|
normal: string;
|
||||||
|
ranking: string;
|
||||||
|
requestNo: string;
|
||||||
|
url: string;
|
||||||
|
viewable: string;
|
||||||
|
views: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SearchAutoCompleteResponse = {
|
||||||
|
keyword: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SearchAutoCompleteResponseList = {
|
||||||
|
targetWord: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetNewReleaseMusicResponseList = {
|
||||||
|
artistCd: string;
|
||||||
|
artistName: string;
|
||||||
|
contentsId: string;
|
||||||
|
contentsName: string;
|
||||||
|
contentsYomi: string;
|
||||||
|
lyrics: string;
|
||||||
|
mylist: string;
|
||||||
|
requestNo: string;
|
||||||
|
streamKaraoke: string;
|
||||||
|
streamKaraokeList: {
|
||||||
|
contentsId: string;
|
||||||
|
contentsName: string;
|
||||||
|
contentsYomi: string;
|
||||||
|
duet: string;
|
||||||
|
karaokeContentsId: string;
|
||||||
|
playTime: string;
|
||||||
|
};
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SearchMusicResponse = {
|
||||||
|
hasNext: string;
|
||||||
|
hasPreview: string;
|
||||||
|
keyword: string;
|
||||||
|
overFlag: string;
|
||||||
|
pageCount: number;
|
||||||
|
pageNo: number;
|
||||||
|
totalCount: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SearchVariousByKeywordResponseList = {
|
||||||
|
animeFlag: string;
|
||||||
|
artist: string;
|
||||||
|
artistCode: number;
|
||||||
|
artistYomi: string;
|
||||||
|
damTomoMovieFlag: string;
|
||||||
|
damTomoPublicMovieFlag: string;
|
||||||
|
damTomoPublicRecordingFlag: string;
|
||||||
|
damTomoPublicVocalFlag: string;
|
||||||
|
futureReleaseFlag: string;
|
||||||
|
guideVocalFlag: string;
|
||||||
|
honninFlag: string;
|
||||||
|
kidsFlag: string;
|
||||||
|
liveFlag: string;
|
||||||
|
myListFlag: string;
|
||||||
|
newArrivalsFlag: string;
|
||||||
|
newReleaseFlag: string;
|
||||||
|
releaseDate: string;
|
||||||
|
requestNo: string;
|
||||||
|
scoreFlag: string;
|
||||||
|
shift: string;
|
||||||
|
title: string;
|
||||||
|
titleYomi: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SearchMusicByKeywordResponseList = {
|
||||||
|
animeFlag: string;
|
||||||
|
artist: string;
|
||||||
|
artistCode: number;
|
||||||
|
artistYomi: string;
|
||||||
|
damTomoMovieFlag: string;
|
||||||
|
futureReleaseFlag: string;
|
||||||
|
guideVocalFlag: string;
|
||||||
|
honninFlag: string;
|
||||||
|
kidsFlag: string;
|
||||||
|
liveFlag: string;
|
||||||
|
myListFlag: string;
|
||||||
|
newArrivalsFlag: string;
|
||||||
|
newReleaseFlag: string;
|
||||||
|
releaseDate: string;
|
||||||
|
requestNo: string;
|
||||||
|
scoreFlag: string;
|
||||||
|
shift: string;
|
||||||
|
title: string;
|
||||||
|
titleYomi: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SearchArtistByKeywordResponseList = {
|
||||||
|
artist: string;
|
||||||
|
artistCode: 40651;
|
||||||
|
artistYomi: string;
|
||||||
|
holdMusicCount: 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetMusicListByArtistResponse = {
|
||||||
|
artist: string;
|
||||||
|
artistCode: number;
|
||||||
|
artistYomi_Kana: string;
|
||||||
|
hasNext: string;
|
||||||
|
hasPreview: string;
|
||||||
|
overFlag: string;
|
||||||
|
pageCount: number;
|
||||||
|
pageNo: number;
|
||||||
|
totalCount: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetMusicListByArtistResponseList = {
|
||||||
|
animeFlag: string;
|
||||||
|
artist: string;
|
||||||
|
artistYomi: string;
|
||||||
|
damTomoMovieFlag: string;
|
||||||
|
damTomoPublicMovieFlag: string;
|
||||||
|
damTomoPublicRecordingFlag: string;
|
||||||
|
damTomoPublicVocalFlag: string;
|
||||||
|
futureReleaseFlag: string;
|
||||||
|
guideVocalFlag: string;
|
||||||
|
honninFlag: string;
|
||||||
|
kidsFlag: string;
|
||||||
|
liveFlag: string;
|
||||||
|
myListFlag: string;
|
||||||
|
newArrivalsFlag: string;
|
||||||
|
newReleaseFlag: string;
|
||||||
|
releaseDate: string;
|
||||||
|
requestNo: string;
|
||||||
|
scoreFlag: string;
|
||||||
|
shift: string;
|
||||||
|
title: string;
|
||||||
|
titleYomi: string;
|
||||||
|
};
|
190
src/utils.ts
Normal file
190
src/utils.ts
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
import { CriUserAgent, UserAgent } from './constants';
|
||||||
|
import { Parser } from 'm3u8-parser';
|
||||||
|
import * as crypto from 'crypto';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
type Manifest = {
|
||||||
|
allowCache: boolean;
|
||||||
|
endList: boolean;
|
||||||
|
mediaSequence: number;
|
||||||
|
discontinuitySequence: number;
|
||||||
|
targetDuration: number;
|
||||||
|
discontinuityStarts: number[];
|
||||||
|
segments: {
|
||||||
|
duration: number;
|
||||||
|
uri: string;
|
||||||
|
timeline: number;
|
||||||
|
key: {
|
||||||
|
method: string;
|
||||||
|
uri: string;
|
||||||
|
iv: Record<string, number>;
|
||||||
|
};
|
||||||
|
}[];
|
||||||
|
mediaGroups: {
|
||||||
|
AUDIO: {
|
||||||
|
[key: string]: {
|
||||||
|
default: string;
|
||||||
|
autoselect: boolean;
|
||||||
|
uri: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
VIDEO: {
|
||||||
|
[key: string]: {
|
||||||
|
default: string;
|
||||||
|
autoselect: boolean;
|
||||||
|
uri: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
'CLOSED-CAPTIONS': {
|
||||||
|
[key: string]: {
|
||||||
|
default: string;
|
||||||
|
autoselect: boolean;
|
||||||
|
uri: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
SUBTITLES: {
|
||||||
|
[key: string]: {
|
||||||
|
default: string;
|
||||||
|
autoselect: boolean;
|
||||||
|
uri: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
playlists: {
|
||||||
|
attributes: {
|
||||||
|
AUDIO: string;
|
||||||
|
'FRAME-RATE': number;
|
||||||
|
RESOLUTION: {
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
};
|
||||||
|
CODECS: string;
|
||||||
|
'AVERAGE-BANDWIDTH': string;
|
||||||
|
BANDWIDTH: number;
|
||||||
|
};
|
||||||
|
uri: string;
|
||||||
|
timeline: number;
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export function getMediaPair(targetVideoId: string, targetAudioId: string, m3u8: string) {
|
||||||
|
const parser = new Parser();
|
||||||
|
parser.push(m3u8);
|
||||||
|
parser.end();
|
||||||
|
|
||||||
|
const manifest: Manifest = parser.manifest;
|
||||||
|
const audio = manifest.mediaGroups.AUDIO[targetAudioId];
|
||||||
|
const video = manifest.playlists.find(playlist => playlist.uri.includes(targetVideoId));
|
||||||
|
|
||||||
|
return {
|
||||||
|
audio,
|
||||||
|
video,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const downloadAesM3u8 = async (url: string, cookie: string) => {
|
||||||
|
const m3u8 = await fetch(url, {
|
||||||
|
headers: {
|
||||||
|
Cookie: cookie,
|
||||||
|
'User-Agent': UserAgent,
|
||||||
|
},
|
||||||
|
}).then(res => res.text());
|
||||||
|
|
||||||
|
const parser = new Parser();
|
||||||
|
parser.push(m3u8);
|
||||||
|
parser.end();
|
||||||
|
|
||||||
|
const manifest: Manifest = parser.manifest;
|
||||||
|
|
||||||
|
// console.log(JSON.stringify(manifest, null, 2));
|
||||||
|
|
||||||
|
const initSegment = await fetch(manifest.segments[0].map.uri, {
|
||||||
|
headers: {
|
||||||
|
Cookie: cookie,
|
||||||
|
'User-Agent': UserAgent,
|
||||||
|
},
|
||||||
|
}).then(res => res.arrayBuffer());
|
||||||
|
|
||||||
|
const iv = Buffer.alloc(Object.keys(manifest.segments[0].key.iv).length * 4);
|
||||||
|
|
||||||
|
for (const key in manifest.segments[0].key.iv) {
|
||||||
|
iv.writeUInt32BE(manifest.segments[0].key.iv[key], parseInt(key) * 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
const key = await fetch(manifest.segments[0].key.uri, {
|
||||||
|
headers: {
|
||||||
|
Cookie: cookie,
|
||||||
|
'User-Agent': UserAgent,
|
||||||
|
},
|
||||||
|
}).then(res => res.arrayBuffer());
|
||||||
|
|
||||||
|
const decipher = crypto.createDecipheriv('aes-128-cbc', Buffer.from(key), iv);
|
||||||
|
|
||||||
|
const segments: Buffer[] = [];
|
||||||
|
|
||||||
|
segments.push(Buffer.from(initSegment));
|
||||||
|
|
||||||
|
let i = 0;
|
||||||
|
|
||||||
|
for (const segment of manifest.segments) {
|
||||||
|
const res = await fetch(segment.uri, {
|
||||||
|
headers: {
|
||||||
|
Cookie: cookie,
|
||||||
|
'User-Agent': UserAgent,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const buffer = await res.arrayBuffer();
|
||||||
|
|
||||||
|
const arrayBufferView = new Uint8Array(buffer);
|
||||||
|
|
||||||
|
let decrypted = decipher.update(arrayBufferView);
|
||||||
|
|
||||||
|
if (i > 0) {
|
||||||
|
decrypted = decrypted.subarray(32, decrypted.length)
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(`${i}.mp4`, Buffer.from(decrypted));
|
||||||
|
|
||||||
|
segments.push(decrypted);
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
segments.push(decipher.final());
|
||||||
|
|
||||||
|
const blob = new Blob(segments, { type: 'video/mp4' });
|
||||||
|
|
||||||
|
return blob.arrayBuffer();
|
||||||
|
};
|
||||||
|
|
||||||
|
export function bufferToHexString(buffer: Buffer) {
|
||||||
|
return Array.prototype.map
|
||||||
|
.call(buffer, function (x: number) {
|
||||||
|
return ('00' + x.toString(16)).slice(-2);
|
||||||
|
})
|
||||||
|
.join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function objToUrlParams(obj: Record<string, string | number>) {
|
||||||
|
return Object.keys(obj)
|
||||||
|
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`)
|
||||||
|
.join('&');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function objToCookieString(obj: Record<string, string>) {
|
||||||
|
return Object.keys(obj)
|
||||||
|
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`)
|
||||||
|
.join('; ');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function cookieStringToObj(cookieString: string) {
|
||||||
|
const obj: Record<string, string> = {};
|
||||||
|
|
||||||
|
cookieString.split(';').forEach(cookie => {
|
||||||
|
const [key, value] = cookie.trim().split('=');
|
||||||
|
obj[key] = value;
|
||||||
|
});
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
109
tsconfig.json
Normal file
109
tsconfig.json
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||||
|
|
||||||
|
/* Projects */
|
||||||
|
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
||||||
|
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
||||||
|
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
||||||
|
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
||||||
|
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
||||||
|
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
||||||
|
|
||||||
|
/* Language and Environment */
|
||||||
|
"target": "esnext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||||
|
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
||||||
|
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
||||||
|
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
||||||
|
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
||||||
|
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
||||||
|
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
||||||
|
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
||||||
|
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
||||||
|
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
||||||
|
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
||||||
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||||
|
|
||||||
|
/* Modules */
|
||||||
|
"module": "commonjs", /* Specify what module code is generated. */
|
||||||
|
"rootDir": "src", /* Specify the root folder within your source files. */
|
||||||
|
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||||
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||||
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||||
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
||||||
|
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
||||||
|
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
||||||
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||||
|
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
||||||
|
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
||||||
|
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
||||||
|
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
||||||
|
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
||||||
|
// "resolveJsonModule": true, /* Enable importing .json files. */
|
||||||
|
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
||||||
|
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
||||||
|
|
||||||
|
/* JavaScript Support */
|
||||||
|
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
||||||
|
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
||||||
|
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
||||||
|
|
||||||
|
/* Emit */
|
||||||
|
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||||
|
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
||||||
|
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
||||||
|
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||||
|
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||||
|
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
||||||
|
"outDir": "dist", /* Specify an output folder for all emitted files. */
|
||||||
|
// "removeComments": true, /* Disable emitting comments. */
|
||||||
|
// "noEmit": true, /* Disable emitting files from a compilation. */
|
||||||
|
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||||
|
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
||||||
|
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
||||||
|
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
||||||
|
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||||
|
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
||||||
|
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
||||||
|
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
||||||
|
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
||||||
|
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
||||||
|
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
||||||
|
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
||||||
|
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
||||||
|
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
||||||
|
|
||||||
|
/* Interop Constraints */
|
||||||
|
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
||||||
|
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
||||||
|
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
||||||
|
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
||||||
|
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
||||||
|
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
||||||
|
|
||||||
|
/* Type Checking */
|
||||||
|
"strict": true, /* Enable all strict type-checking options. */
|
||||||
|
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
||||||
|
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
||||||
|
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
||||||
|
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
||||||
|
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
||||||
|
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
||||||
|
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
||||||
|
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
||||||
|
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
||||||
|
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
||||||
|
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
||||||
|
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
||||||
|
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
||||||
|
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
||||||
|
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
||||||
|
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
||||||
|
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
||||||
|
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
||||||
|
|
||||||
|
/* Completeness */
|
||||||
|
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||||
|
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user