Skip to content

Commit

Permalink
Merge pull request #43 from xpadev-net/develop
Browse files Browse the repository at this point in the history
release: v0.0.21
  • Loading branch information
xpadev-net authored Nov 29, 2023
2 parents 5dadbca + b637a14 commit 564842d
Show file tree
Hide file tree
Showing 11 changed files with 609 additions and 455 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ niconicommentsを使って動画を書き出す簡易ツール(?)です

## 注意事項
- なにか損害が発生しても一切責任を負いません
- 基本的に見切り発車でリリースするので1日経たないうちに次のリリース出ることが多々あります
新しいバージョンが出た後は1日くらい様子見てから使うことをおすすめします

## 特徴
- 一時ファイルを使用しないためディスク容量を必要としません
Expand Down
34 changes: 21 additions & 13 deletions electron/dialog.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { OpenDialogReturnValue, SaveDialogOptions } from "electron";
import { dialog } from "electron";
import * as path from "path";

import type { FfprobeOutput } from "@/@types/ffmpeg";
import type {
Expand All @@ -13,6 +14,7 @@ import { sendMessageToController } from "./controller-window";
import { ffprobePath } from "./ffmpeg";
import { encodeJson } from "./lib/json";
import { spawn } from "./lib/spawn";
import { store } from "./store";
import { identifyCommentFormat } from "./utils/niconicomments";

const selectFile = async (
Expand Down Expand Up @@ -114,20 +116,26 @@ const selectMovie = async (): Promise<
const selectComment = async (): Promise<
ApiResponseSelectComment | undefined
> => {
const path = await dialog.showOpenDialog({
const lastExt = `${store.get("commentFileExt")}`;
const formats = [
{ name: "formatted/legacy/v1/owner JSON", extensions: ["json"] },
{ name: "niconicome XML", extensions: ["xml"] },
{ name: "legacyOwner TXT", extensions: ["txt"] },
{
name: "All Files",
extensions: ["*"],
},
].sort((item) => {
return item.extensions.includes(lastExt.slice(1)) ? -1 : 0;
});
const pathResult = await dialog.showOpenDialog({
properties: ["openFile"],
filters: [
{ name: "formatted/legacy/v1/owner JSON", extensions: ["json"] },
{ name: "niconicome XML", extensions: ["xml"] },
{ name: "legacyOwner TXT", extensions: ["txt"] },
{
name: "All Files",
extensions: ["*"],
},
],
filters: formats,
});
if (path.canceled) return;
const filePath = path.filePaths[0];
if (pathResult.canceled) return;
const filePath = pathResult.filePaths[0];
const ext = path.extname(filePath);
store.set("commentFileExt", ext);
const format = identifyCommentFormat(filePath);
if (!format) {
sendMessageToController({
Expand All @@ -139,7 +147,7 @@ const selectComment = async (): Promise<
}
return {
type: "selectComment",
path: path.filePaths[0],
path: pathResult.filePaths[0],
format: format,
};
};
Expand Down
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
43 changes: 21 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "niconicomments-convert",
"private": false,
"version": "0.0.20",
"version": "0.0.21",
"type": "commonjs",
"license": "MIT",
"main": "build/electron/electron.js",
Expand All @@ -25,45 +25,44 @@
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@fontsource/roboto": "^5.0.8",
"@mui/icons-material": "^5.14.16",
"@mui/material": "^5.14.16",
"@mui/icons-material": "^5.14.18",
"@mui/material": "^5.14.18",
"@xpadev-net/niconicomments": "^0.2.61",
"axios": "^1.6.0",
"axios": "^1.6.2",
"electron-store": "^8.1.0",
"jotai": "^2.5.1",
"jotai": "^2.6.0",
"jsdom": "^22.1.0",
"sqlite3": "^5.1.6"
},
"devDependencies": {
"@types/body-parser": "^1.19.4",
"@types/follow-redirects": "^1.14.3",
"@types/jsdom": "^21.1.4",
"@types/node": "^20.8.10",
"@types/react": "^18.2.35",
"@types/react-dom": "^18.2.14",
"@types/sqlite3": "^3.1.10",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"@vitejs/plugin-react": "^4.1.1",
"@types/body-parser": "^1.19.5",
"@types/follow-redirects": "^1.14.4",
"@types/jsdom": "^21.1.6",
"@types/node": "^20.10.0",
"@types/react-dom": "^18.2.17",
"@types/sqlite3": "^3.1.11",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"@vitejs/plugin-react": "^4.2.0",
"body-parser": "^1.20.2",
"concurrently": "^8.2.2",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"electron": "^27.0.3",
"electron-builder": "^24.6.4",
"eslint": "^8.53.0",
"electron": "^27.1.2",
"electron-builder": "^24.9.1",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"prettier": "^3.0.3",
"lint-staged": "^15.1.0",
"prettier": "^3.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^5.0.5",
"sass": "^1.69.5",
"typescript": "^5.2.2",
"vite": "^4.5.0"
"typescript": "^5.3.2",
"vite": "^5.0.2"
},
"optionalDependencies": {
"win-protect": "^1.0.0"
Expand Down
1 change: 1 addition & 0 deletions src/controller/movie-picker/remote/dmc/dmc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const DMCMoviePicker: FC<Props> = ({ metadata, onChange }) => {
onChange={(e) => setSelectedAudio(e.target.value)}
>
{metadata.data.media.delivery.movie.audios.map((val) => {
if (!val.isAvailable) return <></>;
return (
<MenuItem key={val.id} value={val.id}>
{val.id}
Expand Down
1 change: 1 addition & 0 deletions src/controller/movie-picker/remote/dms/dms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const DMSMoviePicker: FC<Props> = ({ metadata, onChange }) => {
onChange={(e) => setSelectedAudio(e.target.value)}
>
{metadata.data.media.domand.audios.map((val) => {
if (!val.isAvailable) return <></>;
return (
<MenuItem key={val.id} value={val.id}>
{val.id}
Expand Down
2 changes: 0 additions & 2 deletions src/controller/queue/convert-item.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { StopOutlined } from "@mui/icons-material";
import { IconButton } from "@mui/material";
import type { FC } from "react";
import { useMemo } from "react";

Expand Down
2 changes: 0 additions & 2 deletions src/controller/queue/movie-item.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { StopOutlined } from "@mui/icons-material";
import { IconButton } from "@mui/material";
import type { FC } from "react";
import { useMemo } from "react";

Expand Down
4 changes: 4 additions & 0 deletions src/controller/queue/queue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const QueueDisplay: FC = () => {
}
};
window.api.onResponse(callback);
void window.api.request({
type: "getQueue",
host: "controller",
});
return () => window.api.remove(callback);
}, []);
return (
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts → vite.config.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import react from "@vitejs/plugin-react";
module.exports = {
export default {
plugins: [
react(),
],
Expand Down
Loading

0 comments on commit 564842d

Please sign in to comment.