From 0c8539f6e88518bbef1f9a9aa6acf5ba54a3062d Mon Sep 17 00:00:00 2001 From: Eridanus Sora Date: Sun, 16 Jan 2022 23:05:09 +0800 Subject: [PATCH] support nicochannel --- npm-shrinkwrap.json | 4 ++-- package.json | 2 +- src/core/archive.ts | 11 +++++++++++ src/core/live.ts | 10 ++++++++++ src/core/parsers/nicochannel.ts | 12 ++++++++++++ 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/core/parsers/nicochannel.ts diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 1dc53d0..eb2473c 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,12 +1,12 @@ { "name": "minyami", - "version": "4.4.12", + "version": "4.4.13", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "minyami", - "version": "4.4.12", + "version": "4.4.13", "license": "GPL-3.0-or-later", "dependencies": { "@eridanussora/reconnecting-websocket": "^4.4.2", diff --git a/package.json b/package.json index 8017a30..4f99e31 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minyami", - "version": "4.4.12", + "version": "4.4.13", "description": "", "main": "dist/exports.js", "types": "dist/exports.d.ts", diff --git a/src/core/archive.ts b/src/core/archive.ts index 79c5cfe..84995b1 100644 --- a/src/core/archive.ts +++ b/src/core/archive.ts @@ -81,6 +81,7 @@ class ArchiveDownloader extends Downloader { */ async parse() { // parse m3u8 + console.log(this.m3u8); if (this.m3u8.encryptKeys.length > 0) { // Encrypted const key = this.m3u8.encryptKeys[0]; @@ -102,6 +103,16 @@ class ArchiveDownloader extends Downloader { parser.default.parse({ downloader: this, }); + } else if (this.m3u8Path.includes("hls-auth.cloud.stream.co.jp")) { + logger.info("Site comfirmed: Nicochannel."); + const nicoChannelParser = await import("./parsers/nicochannel"); + nicoChannelParser.default.parse({ + downloader: this, + }); + const commonParser = await import("./parsers/common"); + await commonParser.default.parse({ + downloader: this, + }); } else { logger.warning(`Site is not supported by Minyami Core. Try common parser.`); try { diff --git a/src/core/live.ts b/src/core/live.ts index 33af8fd..4fb227a 100644 --- a/src/core/live.ts +++ b/src/core/live.ts @@ -124,6 +124,16 @@ export default class LiveDownloader extends Downloader { parser.default.parse({ downloader: this, }); + } else if (this.m3u8Path.includes("hls-auth.cloud.stream.co.jp")) { + logger.info("Site comfirmed: Nicochannel."); + const nicoChannelParser = await import("./parsers/nicochannel"); + nicoChannelParser.default.parse({ + downloader: this, + }); + const commonParser = await import("./parsers/common"); + await commonParser.default.parse({ + downloader: this, + }); } else { logger.warning(`Site is not supported by Minyami Core. Try common parser.`); try { diff --git a/src/core/parsers/nicochannel.ts b/src/core/parsers/nicochannel.ts new file mode 100644 index 0000000..91d12af --- /dev/null +++ b/src/core/parsers/nicochannel.ts @@ -0,0 +1,12 @@ +import { URL } from "url"; +import { ParserOptions, ParserResult } from "./types"; + +export default class Parser { + static parse({ downloader }: ParserOptions): ParserResult { + downloader.setOnChunkNaming((chunk) => { + const pathname = new URL(chunk.url).pathname.split("/"); + return `${pathname[pathname.length - 2]}_${pathname[pathname.length - 1]}`; + }); + return {}; + } +}