koishi-plugin-video-parser-all 0.8.9 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +20 -7
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -72,7 +72,7 @@ const PLATFORM_KEYWORDS = {
|
|
|
72
72
|
tiktok: ['tiktok', 'tiktok.com', 'www.tiktok.com'],
|
|
73
73
|
xigua: ['xigua', 'ixigua.com'],
|
|
74
74
|
haokan: ['haokan', 'haokan.baidu.com'],
|
|
75
|
-
li: ['
|
|
75
|
+
li: ['video.li'],
|
|
76
76
|
meipai: ['meipai', 'meipai.com'],
|
|
77
77
|
quanmin: ['quanmin', 'quanmin.tv'],
|
|
78
78
|
twitter: ['twitter', 'x.com'],
|
|
@@ -88,16 +88,29 @@ function getErrorMessage(error) {
|
|
|
88
88
|
function extractUrl(content) {
|
|
89
89
|
const urlMatches = content.match(/https?:\/\/[^\s\"\'\>]+/gi) || [];
|
|
90
90
|
return urlMatches.filter(url => {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
try {
|
|
92
|
+
const hostname = new URL(url).hostname.toLowerCase();
|
|
93
|
+
if (hostname === 'multimedia.nt.qq.com.cn')
|
|
94
|
+
return false;
|
|
95
|
+
return Object.values(PLATFORM_KEYWORDS).some(group => group.some(keyword => hostname.includes(keyword) || (!keyword.includes('.') && url.toLowerCase().includes(keyword))));
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
const lower = url.toLowerCase();
|
|
99
|
+
return Object.values(PLATFORM_KEYWORDS).some(group => group.some(keyword => lower.includes(keyword)));
|
|
100
|
+
}
|
|
93
101
|
});
|
|
94
102
|
}
|
|
95
103
|
function getPlatformType(url) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
return
|
|
104
|
+
try {
|
|
105
|
+
const hostname = new URL(url).hostname.toLowerCase();
|
|
106
|
+
if (hostname === 'multimedia.nt.qq.com.cn')
|
|
107
|
+
return null;
|
|
108
|
+
for (const [platform, keywords] of Object.entries(PLATFORM_KEYWORDS)) {
|
|
109
|
+
if (keywords.some(k => hostname.includes(k) || (!k.includes('.') && url.toLowerCase().includes(k))))
|
|
110
|
+
return platform;
|
|
111
|
+
}
|
|
100
112
|
}
|
|
113
|
+
catch { }
|
|
101
114
|
return null;
|
|
102
115
|
}
|
|
103
116
|
function cleanUrl(url) {
|
package/package.json
CHANGED