diff --git a/package.json b/package.json
index 31cf248..ba99c2a 100644
--- a/package.json
+++ b/package.json
@@ -38,6 +38,7 @@
"eslint-plugin-svelte3": "^3.2.0",
"exio": "^0.6.47",
"express": "4.17.3",
+ "filenamify": "^6.0.0",
"html2canvas": "^1.4.1",
"iframe-translator": "^0.3.5",
"is-dark-color": "^1.2.0",
@@ -61,5 +62,6 @@
"typescript": "4.3.5",
"vite": "2.9.16",
"vite-plugin-web-extension": "^1.4.0"
- }
+ },
+ "dependencies": {}
}
diff --git a/src/components/YtcFilterWelcome.svelte b/src/components/YtcFilterWelcome.svelte
index 571e8c3..376ec23 100644
--- a/src/components/YtcFilterWelcome.svelte
+++ b/src/components/YtcFilterWelcome.svelte
@@ -36,7 +36,7 @@
v{version}:
- auto-open setting + more.
+ auto-open, filenames, + more.
diff --git a/src/ts/ytcf-logic.ts b/src/ts/ytcf-logic.ts
index de3d9cd..3f78646 100644
--- a/src/ts/ytcf-logic.ts
+++ b/src/ts/ytcf-logic.ts
@@ -5,6 +5,7 @@ import { getRandomString } from './chat-utils';
import parseRegex from 'regex-parser';
import { isLangMatch, parseTranslation } from './tl-tag-detect';
import { YTCF_MESSAGEDUMPINFOS_KEY, isLiveTL } from './chat-constants';
+import { filenamifyPath } from 'filenamify';
const browserObject = chrome;
@@ -608,11 +609,22 @@ export const getAllMessageDumpInfoItems = async (): Promise {
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
- return ((obj?.info?.video?.title) ?? '') || obj?.info?.channel?.name ||
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
- obj?.info?.video?.videoId || obj?.info?.channel?.channelId ||
- (obj?.lastEdited !== undefined ? new Date(obj?.lastEdited) : new Date()).toISOString();
+ // // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
+ // return ((obj?.info?.video?.title) ?? '') || obj?.info?.channel?.name ||
+ // // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
+ // obj?.info?.video?.videoId || obj?.info?.channel?.channelId ||
+ // (obj?.lastEdited !== undefined ? new Date(obj?.lastEdited) : new Date()).toISOString();
+ // cut title to 100 characters
+ const title = (obj?.info?.video?.title || '').slice(0, 100);
+ const channelName = obj?.info?.channel?.name;
+ const videoId = obj?.info?.video?.videoId;
+ const channelId = obj?.info?.channel?.channelId;
+ const lastEdited = obj?.lastEdited !== undefined ? new Date(obj?.lastEdited) : new Date();
+ const result = (title ? title : '') + (channelName ? ` - ${channelName}` : (channelId ? ` - ${channelId}` : '')) + (videoId ? ` - ${videoId}` : '');
+ if (!result) {
+ return lastEdited.toISOString();
+ }
+ return filenamifyPath(result, {replacement: '_'});
};
export const downloadAsJson = async (item: YtcF.MessageDumpInfoItem): Promise => {
diff --git a/yarn.lock b/yarn.lock
index 80c616b..8b31d8d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2789,6 +2789,11 @@ filename-reserved-regex@^2.0.0:
resolved "https://registry.yarnpkg.com/filename-reserved-regex/-/filename-reserved-regex-2.0.0.tgz#abf73dfab735d045440abfea2d91f389ebbfa229"
integrity sha1-q/c9+rc10EVECr/qLZHzieu/oik=
+filename-reserved-regex@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/filename-reserved-regex/-/filename-reserved-regex-3.0.0.tgz#3d5dd6d4e2d73a3fed2ebc4cd0b3448869a081f7"
+ integrity sha512-hn4cQfU6GOT/7cFHXBqeBg2TbrMBgdD0kcjLhvSQYYwm3s4B6cjvBfb7nBALJLAXqmU5xajSa7X2NnUud/VCdw==
+
filenamify@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/filenamify/-/filenamify-3.0.0.tgz#9603eb688179f8c5d40d828626dcbb92c3a4672c"
@@ -2798,6 +2803,13 @@ filenamify@^3.0.0:
strip-outer "^1.0.0"
trim-repeated "^1.0.0"
+filenamify@^6.0.0:
+ version "6.0.0"
+ resolved "https://registry.yarnpkg.com/filenamify/-/filenamify-6.0.0.tgz#38def94098c62154c42a41d822650f5f55bcbac2"
+ integrity sha512-vqIlNogKeyD3yzrm0yhRMQg8hOVwYcYRfjEoODd49iCprMn4HL85gK3HcykQE53EPIpX3HcAbGA5ELQv216dAQ==
+ dependencies:
+ filename-reserved-regex "^3.0.0"
+
fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz"