music: switch to youtubei.js
This commit is contained in:
parent
a9c293e8fb
commit
105f5c2eee
3 changed files with 133 additions and 41 deletions
|
@ -19,7 +19,6 @@
|
|||
"homepage": "https://gitdab.com/Cynosphere/HiddenPhox#readme",
|
||||
"dependencies": {
|
||||
"@ctrl/tinycolor": "^3.6.0",
|
||||
"@distube/ytdl-core": "^4.11.9",
|
||||
"@projectdysnomia/dysnomia": "^0.1.1",
|
||||
"dumpy": "github:Cynosphere/dumpy.js",
|
||||
"google-images": "^2.1.0",
|
||||
|
@ -27,7 +26,8 @@
|
|||
"murmurhash": "^2.0.1",
|
||||
"node-ffprobe": "^3.0.0",
|
||||
"sharp": "^0.32.0",
|
||||
"sqlite3": "^5.1.6"
|
||||
"sqlite3": "^5.1.6",
|
||||
"youtubei.js": "^4.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^8.39.0",
|
||||
|
|
137
pnpm-lock.yaml
137
pnpm-lock.yaml
|
@ -4,9 +4,6 @@ dependencies:
|
|||
'@ctrl/tinycolor':
|
||||
specifier: ^3.6.0
|
||||
version: 3.6.0
|
||||
'@distube/ytdl-core':
|
||||
specifier: ^4.11.9
|
||||
version: 4.11.9
|
||||
'@projectdysnomia/dysnomia':
|
||||
specifier: ^0.1.1
|
||||
version: 0.1.1
|
||||
|
@ -31,6 +28,9 @@ dependencies:
|
|||
sqlite3:
|
||||
specifier: ^5.1.6
|
||||
version: 5.1.6
|
||||
youtubei.js:
|
||||
specifier: ^4.3.0
|
||||
version: 4.3.0
|
||||
|
||||
devDependencies:
|
||||
eslint:
|
||||
|
@ -57,16 +57,6 @@ packages:
|
|||
engines: {node: '>=10'}
|
||||
dev: false
|
||||
|
||||
/@distube/ytdl-core@4.11.9:
|
||||
resolution: {integrity: sha512-wlQu48gG9eV8YCASpra1bw2iXIlc3FuF/WiB8akBGmrp/jd9tGvuxwgOH5oKYQZYSSjzazsW2VX7L5rt+8Fu5Q==}
|
||||
engines: {node: '>=12'}
|
||||
dependencies:
|
||||
m3u8stream: 0.8.6
|
||||
miniget: 4.2.2
|
||||
sax: 1.2.4
|
||||
undici: 5.22.0
|
||||
dev: false
|
||||
|
||||
/@eslint-community/eslint-utils@4.4.0(eslint@8.39.0):
|
||||
resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
|
@ -987,7 +977,6 @@ packages:
|
|||
resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/agent-base@6.0.2:
|
||||
resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==}
|
||||
|
@ -1087,6 +1076,10 @@ packages:
|
|||
resolution: {integrity: sha512-vHdS19CnY3hwiNdkaqk93DvjVLfbEcI8mys4UjuWrlX1haDmroo8o4xCzh4wD6DGV6HxRCyauwhHRqMTfERtjw==}
|
||||
dev: false
|
||||
|
||||
/boolbase@1.0.0:
|
||||
resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==}
|
||||
dev: false
|
||||
|
||||
/brace-expansion@1.1.11:
|
||||
resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==}
|
||||
dependencies:
|
||||
|
@ -1241,6 +1234,25 @@ packages:
|
|||
which: 2.0.2
|
||||
dev: true
|
||||
|
||||
/css-select@5.1.0:
|
||||
resolution: {integrity: sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==}
|
||||
dependencies:
|
||||
boolbase: 1.0.0
|
||||
css-what: 6.1.0
|
||||
domhandler: 5.0.3
|
||||
domutils: 3.0.1
|
||||
nth-check: 2.1.1
|
||||
dev: false
|
||||
|
||||
/css-what@6.1.0:
|
||||
resolution: {integrity: sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==}
|
||||
engines: {node: '>= 6'}
|
||||
dev: false
|
||||
|
||||
/cssom@0.5.0:
|
||||
resolution: {integrity: sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw==}
|
||||
dev: false
|
||||
|
||||
/debug@4.3.4:
|
||||
resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
|
||||
engines: {node: '>=6.0'}
|
||||
|
@ -1290,10 +1302,37 @@ packages:
|
|||
esutils: 2.0.3
|
||||
dev: true
|
||||
|
||||
/dom-serializer@2.0.0:
|
||||
resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==}
|
||||
dependencies:
|
||||
domelementtype: 2.3.0
|
||||
domhandler: 5.0.3
|
||||
entities: 4.5.0
|
||||
dev: false
|
||||
|
||||
/dom-walk@0.1.2:
|
||||
resolution: {integrity: sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==}
|
||||
dev: false
|
||||
|
||||
/domelementtype@2.3.0:
|
||||
resolution: {integrity: sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==}
|
||||
dev: false
|
||||
|
||||
/domhandler@5.0.3:
|
||||
resolution: {integrity: sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==}
|
||||
engines: {node: '>= 4'}
|
||||
dependencies:
|
||||
domelementtype: 2.3.0
|
||||
dev: false
|
||||
|
||||
/domutils@3.0.1:
|
||||
resolution: {integrity: sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q==}
|
||||
dependencies:
|
||||
dom-serializer: 2.0.0
|
||||
domelementtype: 2.3.0
|
||||
domhandler: 5.0.3
|
||||
dev: false
|
||||
|
||||
/duplexer3@0.1.5:
|
||||
resolution: {integrity: sha512-1A8za6ws41LQgv9HrE/66jyC5yuSjQ3L/KOpFtoBilsAK2iA2wuS5rTt1OCzIvtS2V7nVmedsUU+DGRcjBmOYA==}
|
||||
dev: false
|
||||
|
@ -1316,6 +1355,11 @@ packages:
|
|||
once: 1.4.0
|
||||
dev: false
|
||||
|
||||
/entities@4.5.0:
|
||||
resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
|
||||
engines: {node: '>=0.12'}
|
||||
dev: false
|
||||
|
||||
/env-paths@2.2.1:
|
||||
resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==}
|
||||
engines: {node: '>=6'}
|
||||
|
@ -1625,6 +1669,19 @@ packages:
|
|||
resolution: {integrity: sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==}
|
||||
dev: false
|
||||
|
||||
/html-escaper@3.0.3:
|
||||
resolution: {integrity: sha512-RuMffC89BOWQoY0WKGpIhn5gX3iI54O6nRA0yC124NYVtzjmFWBIiFd8M0x+ZdX0P9R4lADg1mgP8C7PxGOWuQ==}
|
||||
dev: false
|
||||
|
||||
/htmlparser2@8.0.2:
|
||||
resolution: {integrity: sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==}
|
||||
dependencies:
|
||||
domelementtype: 2.3.0
|
||||
domhandler: 5.0.3
|
||||
domutils: 3.0.1
|
||||
entities: 4.5.0
|
||||
dev: false
|
||||
|
||||
/http-cache-semantics@4.1.1:
|
||||
resolution: {integrity: sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==}
|
||||
dev: false
|
||||
|
@ -1812,6 +1869,12 @@ packages:
|
|||
- encoding
|
||||
dev: false
|
||||
|
||||
/jintr@1.0.0:
|
||||
resolution: {integrity: sha512-Kbyb5jiIzmTrbhbdjQGt+jjVzn9BPluvL3mZU5ihFQIEGjCHUA4+rsXE2PNDKmg1UlfdTn3947aSwWOVnc5UIw==}
|
||||
dependencies:
|
||||
acorn: 8.8.2
|
||||
dev: false
|
||||
|
||||
/jpeg-js@0.4.4:
|
||||
resolution: {integrity: sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg==}
|
||||
dev: false
|
||||
|
@ -1843,6 +1906,16 @@ packages:
|
|||
type-check: 0.4.0
|
||||
dev: true
|
||||
|
||||
/linkedom@0.14.25:
|
||||
resolution: {integrity: sha512-Q5BvQVFzMveMxHvZ9L3E60duxSVPIWQRzY2HJKpCV4pRzY3jS/r/a1upLeo/Nup9mDRJ5MS0FX2hRR+wRo+Hiw==}
|
||||
dependencies:
|
||||
css-select: 5.1.0
|
||||
cssom: 0.5.0
|
||||
html-escaper: 3.0.3
|
||||
htmlparser2: 8.0.2
|
||||
uhyphen: 0.2.0
|
||||
dev: false
|
||||
|
||||
/load-bmfont@1.4.1:
|
||||
resolution: {integrity: sha512-8UyQoYmdRDy81Brz6aLAUhfZLwr5zV0L3taTQ4hju7m6biuwiWiJXjPhBJxbUQJA8PrkvJ/7Enqmwk2sM14soA==}
|
||||
dependencies:
|
||||
|
@ -1879,14 +1952,6 @@ packages:
|
|||
yallist: 4.0.0
|
||||
dev: false
|
||||
|
||||
/m3u8stream@0.8.6:
|
||||
resolution: {integrity: sha512-LZj8kIVf9KCphiHmH7sbFQTVe4tOemb202fWwvJwR9W5ENW/1hxJN6ksAWGhQgSBSa3jyWhnjKU1Fw1GaOdbyA==}
|
||||
engines: {node: '>=12'}
|
||||
dependencies:
|
||||
miniget: 4.2.2
|
||||
sax: 1.2.4
|
||||
dev: false
|
||||
|
||||
/make-dir@3.1.0:
|
||||
resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==}
|
||||
engines: {node: '>=8'}
|
||||
|
@ -1937,11 +2002,6 @@ packages:
|
|||
dom-walk: 0.1.2
|
||||
dev: false
|
||||
|
||||
/miniget@4.2.2:
|
||||
resolution: {integrity: sha512-a7voNL1N5lDMxvTMExOkg+Fq89jM2vY8pAi9ZEWzZtfNmdfP6RXkvUtFnCAXoCv2T9k1v/fUJVaAEuepGcvLYA==}
|
||||
engines: {node: '>=12'}
|
||||
dev: false
|
||||
|
||||
/minimatch@3.1.2:
|
||||
resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==}
|
||||
dependencies:
|
||||
|
@ -2146,6 +2206,12 @@ packages:
|
|||
dev: false
|
||||
optional: true
|
||||
|
||||
/nth-check@2.1.1:
|
||||
resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==}
|
||||
dependencies:
|
||||
boolbase: 1.0.0
|
||||
dev: false
|
||||
|
||||
/object-assign@4.1.1:
|
||||
resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
@ -2647,6 +2713,10 @@ packages:
|
|||
resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==}
|
||||
dev: false
|
||||
|
||||
/tslib@2.5.0:
|
||||
resolution: {integrity: sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==}
|
||||
dev: false
|
||||
|
||||
/tunnel-agent@0.6.0:
|
||||
resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==}
|
||||
dependencies:
|
||||
|
@ -2671,6 +2741,10 @@ packages:
|
|||
engines: {node: '>=10'}
|
||||
dev: true
|
||||
|
||||
/uhyphen@0.2.0:
|
||||
resolution: {integrity: sha512-qz3o9CHXmJJPGBdqzab7qAYuW8kQGKNEuoHFYrBwV6hWIMcpAmxDLXojcHfFr9US1Pe6zUswEIJIbLI610fuqA==}
|
||||
dev: false
|
||||
|
||||
/undici@5.22.0:
|
||||
resolution: {integrity: sha512-fR9RXCc+6Dxav4P9VV/sp5w3eFiSdOjJYsbtWfd4s5L5C4ogyuVpdKIVHeW0vV1MloM65/f7W45nR9ZxwVdyiA==}
|
||||
engines: {node: '>=14.0'}
|
||||
|
@ -2815,6 +2889,15 @@ packages:
|
|||
engines: {node: '>=10'}
|
||||
dev: true
|
||||
|
||||
/youtubei.js@4.3.0:
|
||||
resolution: {integrity: sha512-HdU6Awdr1nUWy0Ph7WdmoYPWL0ovx+S4w40eeTzAENr5xiUENsLuXcvULRc2fRCIxi+n7Q6142VVhmM4yK/g5g==}
|
||||
dependencies:
|
||||
jintr: 1.0.0
|
||||
linkedom: 0.14.25
|
||||
tslib: 2.5.0
|
||||
undici: 5.22.0
|
||||
dev: false
|
||||
|
||||
github.com/Cynosphere/dumpy.js/5fc22353cdcb97084bab572266390e780d9f7a7b:
|
||||
resolution: {tarball: https://codeload.github.com/Cynosphere/dumpy.js/tar.gz/5fc22353cdcb97084bab572266390e780d9f7a7b}
|
||||
name: dumpy
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
const {Collection} = require("@projectdysnomia/dysnomia");
|
||||
|
||||
const ytdl = require("@distube/ytdl-core");
|
||||
const {Innertube} = require("youtubei.js");
|
||||
let yt;
|
||||
Innertube.create({
|
||||
generate_session_locally: true,
|
||||
}).then((x) => (yt = x));
|
||||
const ffprobe = require("node-ffprobe");
|
||||
|
||||
const Command = require("../lib/command.js");
|
||||
|
@ -203,26 +207,31 @@ async function enqueue({
|
|||
if (type == "yt") {
|
||||
let info;
|
||||
try {
|
||||
info = await ytdl.getInfo(url, {});
|
||||
let id = url;
|
||||
if (/^https?:\/\//.test(url)) {
|
||||
const uri = new URL(url);
|
||||
if (uri.hostname == "youtu.be") {
|
||||
id = uri.pathname.substring(1);
|
||||
} else if (uri.hostname.indexOf("youtube.com") > -1) {
|
||||
id = uri.searchParams.get("v");
|
||||
}
|
||||
}
|
||||
info = await yt.getBasicInfo(id);
|
||||
} catch (err) {
|
||||
await textChannel.createMessage({
|
||||
content: `:warning: Failed to get metadata: \`\`\`\n${err}\n\`\`\``,
|
||||
});
|
||||
}
|
||||
|
||||
title = parseHtmlEntities(info?.videoDetails?.title);
|
||||
length = info?.videoDetails?.lengthSeconds * 1000;
|
||||
thumbnail = info?.videoDetails?.thumbnails?.[
|
||||
info.videoDetails.thumbnails.length - 1
|
||||
].url
|
||||
title = parseHtmlEntities(info?.basic_info?.title);
|
||||
length = info?.basic_info?.duration * 1000;
|
||||
thumbnail = info?.basic_info?.thumbnail?.[0].url
|
||||
.replace("vi_webp", "vi")
|
||||
.replace(".webp", ".jpg");
|
||||
|
||||
media = ytdl(url, {
|
||||
quality: "highestaudio",
|
||||
filter: "audioonly",
|
||||
highWaterMark: 1 << 25,
|
||||
});
|
||||
media = info
|
||||
?.chooseFormat({type: "audio", quality: "best"})
|
||||
?.decipher(yt.session.player);
|
||||
} else if (type == "sc") {
|
||||
if (url?.startsWith("sc:"))
|
||||
url = url.replace(/^sc:/, "https://soundcloud.com/");
|
||||
|
|
Loading…
Reference in a new issue