Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DMS(domand)の更新に対応 #42

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions electron/lib/niconico/dms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ lib/niconico/dms.ts / downloadDMS / invalid accessRights`,
);
const manifestRaw = await manifestReq.text();
const manifests = Array.from(
manifestRaw.match(
/https:\/\/.+?\.nicovideo\.jp\/.+?\.m3u8(?:\?sh=[a-zA-Z0-9_-]+)?/g,
) ?? [],
manifestRaw.match(/https:\/\/.+?\.nicovideo\.jp\/.+?\.m3u8[^"]+/g) ?? [],
);
const getManifestUrl = (format: string): string | undefined => {
for (const url of manifests) {
Expand Down Expand Up @@ -273,16 +271,15 @@ const fetchWithCookie = (

const getSegments = (manifest: string): { segments: string[]; key: string } => {
const key = manifest.match(
/https:\/\/.+?\.nicovideo\.jp\/.+?\.key(?:\?sh=[a-zA-Z0-9_-]+)?/g,
/https:\/\/.+?\.nicovideo\.jp\/.+?\.key[^"\n]*/g,
)?.[0];
if (!key) {
throw new Error("failed to get key");
}
return {
segments: Array.from(
manifest.match(
/https:\/\/.+?\.nicovideo\.jp\/.+?\.cmf[av](?:\?sh=[a-zA-Z0-9_-]+)?/g,
) ?? [],
manifest.match(/https:\/\/.+?\.nicovideo\.jp\/.+?\.cmf[av][^"\n]*/g) ??
[],
),
key,
};
Expand Down