Skip to content

Commit

Permalink
support nicochannel
Browse files Browse the repository at this point in the history
  • Loading branch information
Last-Order committed Jan 16, 2022
1 parent ff06ee9 commit 0c8539f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
4 changes: 2 additions & 2 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minyami",
"version": "4.4.12",
"version": "4.4.13",
"description": "",
"main": "dist/exports.js",
"types": "dist/exports.d.ts",
Expand Down
11 changes: 11 additions & 0 deletions src/core/archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions src/core/live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions src/core/parsers/nicochannel.ts
Original file line number Diff line number Diff line change
@@ -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 {};
}
}

0 comments on commit 0c8539f

Please sign in to comment.