From 3bdec4e52d4b6bb0e93e48d8576421c68d2f8ab9 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Thu, 14 Aug 2025 15:10:27 -0600 Subject: [PATCH] music: attempt proxy --- package.json | 3 +- pnpm-lock.yaml | 212 +++++++++++++++++++++++++++++++++++++++++-- src/index.js | 6 +- src/modules/music.js | 82 +++++++++++------ 4 files changed, 263 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index c003ddd..99f6dd1 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "homepage": "https://gitdab.com/Cynosphere/HiddenPhox#readme", "dependencies": { "@ctrl/tinycolor": "^3.6.0", + "@marshift/strawberry": "^1.7.2", "@peertube/http-signature": "^1.7.0", "@projectdysnomia/dysnomia": "github:projectdysnomia/dysnomia#dev", "dumpy": "github:Cynosphere/dumpy.js", @@ -27,9 +28,9 @@ "jimp": "^0.22.7", "murmurhash": "^2.0.1", "node-ffprobe": "^3.0.0", + "proxy-agent": "^6.5.0", "sh": "github:Cynosphere/sh", "sharp": "^0.32.0", - "spitroast": "^1.4.3", "sqlite3": "^5.1.6", "undici": "^7.10.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b85f5c2..735f1be 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@ctrl/tinycolor': specifier: ^3.6.0 version: 3.6.0 + '@marshift/strawberry': + specifier: ^1.7.2 + version: 1.7.2 '@peertube/http-signature': specifier: ^1.7.0 version: 1.7.0 @@ -35,15 +38,15 @@ importers: node-ffprobe: specifier: ^3.0.0 version: 3.0.0 + proxy-agent: + specifier: ^6.5.0 + version: 6.5.0 sh: specifier: github:Cynosphere/sh version: https://codeload.github.com/Cynosphere/sh/tar.gz/ea34c6dbaee8d4e8fb516230b164c97a18d5db81 sharp: specifier: ^0.32.0 version: 0.32.0 - spitroast: - specifier: ^1.4.3 - version: 1.4.3 sqlite3: specifier: ^5.1.6 version: 5.1.6(encoding@0.1.13) @@ -437,6 +440,9 @@ packages: resolution: {integrity: sha512-4ySo4CjzStuprMwk35H5pPbkymjv1SF3jGLj6rAHp/xT/RF7TL7bd9CTm1xDY49K2qF7jmR/g7k+SkLETP6opA==} hasBin: true + '@marshift/strawberry@1.7.2': + resolution: {integrity: sha512-s5dpuaO2G9MXrX3NZo1dduJ3Pmdcj5m0XHlHs7X7B86a0zKHN8WTC3XRSTv9BGWV6IWzjIFxImOi4yofyy5OaA==} + '@msgpack/msgpack@2.8.0': resolution: {integrity: sha512-h9u4u/jiIRKbq25PM+zymTyW6bhTzELvOoUd+AvYriWOAKpLGnIamaET3pnHYoI5iYphAHBI4ayx0MehR+VVPQ==} engines: {node: '>= 10'} @@ -527,6 +533,9 @@ packages: resolution: {integrity: sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==} engines: {node: '>= 6'} + '@tootallnate/quickjs-emscripten@0.23.0': + resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==} + '@types/keyv@3.1.4': resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==} @@ -556,6 +565,10 @@ packages: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} + agent-base@7.1.4: + resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==} + engines: {node: '>= 14'} + agentkeepalive@4.3.0: resolution: {integrity: sha512-7Epl1Blf4Sy37j4v9f9FjICCh4+KAQOyXgHEwlyBiAQLbhKdq/i2QQU3amQalS/wPhdPzDXPL5DMR5bkn+YeWg==} engines: {node: '>= 8.0.0'} @@ -599,12 +612,20 @@ packages: resolution: {integrity: sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==} engines: {node: '>=0.8'} + ast-types@0.13.4: + resolution: {integrity: sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==} + engines: {node: '>=4'} + balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + basic-ftp@5.0.5: + resolution: {integrity: sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==} + engines: {node: '>=10.0.0'} + bcrypt-pbkdf@1.0.2: resolution: {integrity: sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==} @@ -699,6 +720,10 @@ packages: resolution: {integrity: sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==} engines: {node: '>=0.10'} + data-uri-to-buffer@6.0.2: + resolution: {integrity: sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==} + engines: {node: '>= 14'} + debug@4.3.4: resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} @@ -719,6 +744,10 @@ packages: deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} + degenerator@5.0.1: + resolution: {integrity: sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==} + engines: {node: '>= 14'} + delegates@1.0.0: resolution: {integrity: sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==} @@ -767,6 +796,11 @@ packages: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} + escodegen@2.1.0: + resolution: {integrity: sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==} + engines: {node: '>=6.0'} + hasBin: true + eslint-scope@7.2.0: resolution: {integrity: sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -784,6 +818,11 @@ packages: resolution: {integrity: sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + esprima@4.0.1: + resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} + engines: {node: '>=4'} + hasBin: true + esquery@1.5.0: resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==} engines: {node: '>=0.10'} @@ -868,6 +907,10 @@ packages: resolution: {integrity: sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ==} engines: {node: '>=4'} + get-uri@6.0.5: + resolution: {integrity: sha512-b1O07XYq8eRuVzBNgJLstU6FYc1tS6wnMtF1I1D9lE8LxZSOGZ7LhxN54yPP6mGw5f2CkXY2BQUL9Fx41qvcIg==} + engines: {node: '>= 14'} + getpass@0.1.7: resolution: {integrity: sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==} @@ -919,10 +962,18 @@ packages: resolution: {integrity: sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==} engines: {node: '>= 6'} + http-proxy-agent@7.0.2: + resolution: {integrity: sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==} + engines: {node: '>= 14'} + https-proxy-agent@5.0.1: resolution: {integrity: sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==} engines: {node: '>= 6'} + https-proxy-agent@7.0.6: + resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==} + engines: {node: '>= 14'} + humanize-ms@1.2.1: resolution: {integrity: sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==} @@ -969,6 +1020,10 @@ packages: ini@1.3.8: resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} + ip-address@10.0.1: + resolution: {integrity: sha512-NWv9YLW4PoW2B7xtzaS3NCot75m6nK7Icdv0o3lfMceJVRfSoQwqD4wEH5rLwoKJwUiZ/rfpiVBhnaF0FK4HoA==} + engines: {node: '>= 12'} + ip@2.0.0: resolution: {integrity: sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==} @@ -1069,6 +1124,10 @@ packages: resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} engines: {node: '>=10'} + lru-cache@7.18.3: + resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==} + engines: {node: '>=12'} + make-dir@3.1.0: resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} engines: {node: '>=8'} @@ -1163,6 +1222,10 @@ packages: resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==} engines: {node: '>= 0.6'} + netmask@2.0.2: + resolution: {integrity: sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==} + engines: {node: '>= 0.4.0'} + node-abi@3.40.0: resolution: {integrity: sha512-zNy02qivjjRosswoYmPi8hIKJRr8MpQyeKT6qlcq/OnOgA3Rhoae+IYOqsM9V5+JnHWmxKnWOT2GxvtqdtOCXA==} engines: {node: '>=10'} @@ -1232,6 +1295,14 @@ packages: resolution: {integrity: sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==} engines: {node: '>=10'} + pac-proxy-agent@7.2.0: + resolution: {integrity: sha512-TEB8ESquiLMc0lV8vcd5Ql/JAKAoyzHFXaStwjkzpOpC5Yv+pIzLfHvjTSdf3vpa2bMiUQrg9i6276yn8666aA==} + engines: {node: '>= 14'} + + pac-resolver@7.0.1: + resolution: {integrity: sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg==} + engines: {node: '>= 14'} + pako@1.0.11: resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==} @@ -1316,6 +1387,13 @@ packages: resolution: {integrity: sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g==} engines: {node: '>=10'} + proxy-agent@6.5.0: + resolution: {integrity: sha512-TmatMXdr2KlRiA2CyDu8GqR8EjahTG3aY3nXjdzFyoZbmB8hrBsTyMezhULIXKnC0jpfjlmiZ3+EaCzoInSu/A==} + engines: {node: '>= 14'} + + proxy-from-env@1.1.0: + resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} + pump@3.0.0: resolution: {integrity: sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==} @@ -1417,12 +1495,21 @@ packages: resolution: {integrity: sha512-a6KW9G+6B3nWZ1yB8G7pJwL3ggLy1uTzKAgCb7ttblwqdz9fMGJUuTy3uFzEP48FAs9FLILlmzDlE2JJhVQaXQ==} engines: {node: '>= 10'} + socks-proxy-agent@8.0.5: + resolution: {integrity: sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==} + engines: {node: '>= 14'} + socks@2.7.1: resolution: {integrity: sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==} engines: {node: '>= 10.13.0', npm: '>= 3.0.0'} - spitroast@1.4.3: - resolution: {integrity: sha512-JdkzAy2tT82ahx+eEtM5ohBeHICqFln/Yzo+vPGnE5sX1LYgPHCU2qcaSIJfR/xNrhI0q+ftwFz0H2aJysv3EA==} + socks@2.8.7: + resolution: {integrity: sha512-HLpt+uLy/pxB+bum/9DzAgiKS8CX1EvbWxI4zlmgGCExImLdiad2iCwXT5Z4c9c3Eq8rP2318mPW2c+QbtjK8A==} + engines: {node: '>= 10.0.0', npm: '>= 3.0.0'} + + source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} sqlite3@5.1.6: resolution: {integrity: sha512-olYkWoKFVNSSSQNvxVUfjiVbz3YtBwTJj+mfV5zpHmqW3sELx2Cf4QCdirMelhM5Zh+KDVaKgQHqCxrqiWHybw==} @@ -1497,6 +1584,9 @@ packages: tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} + tslib@2.8.1: + resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + tunnel-agent@0.6.0: resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==} @@ -2121,6 +2211,8 @@ snapshots: - encoding - supports-color + '@marshift/strawberry@1.7.2': {} + '@msgpack/msgpack@2.8.0': {} '@nodelib/fs.scandir@2.1.5': @@ -2223,6 +2315,8 @@ snapshots: '@tootallnate/once@1.1.2': optional: true + '@tootallnate/quickjs-emscripten@0.23.0': {} + '@types/keyv@3.1.4': dependencies: '@types/node': 18.16.0 @@ -2249,6 +2343,8 @@ snapshots: transitivePeerDependencies: - supports-color + agent-base@7.1.4: {} + agentkeepalive@4.3.0: dependencies: debug: 4.3.4 @@ -2300,10 +2396,16 @@ snapshots: assert-plus@1.0.0: {} + ast-types@0.13.4: + dependencies: + tslib: 2.8.1 + balanced-match@1.0.2: {} base64-js@1.5.1: {} + basic-ftp@5.0.5: {} + bcrypt-pbkdf@1.0.2: dependencies: tweetnacl: 0.14.5 @@ -2417,6 +2519,8 @@ snapshots: dependencies: assert-plus: 1.0.0 + data-uri-to-buffer@6.0.2: {} + debug@4.3.4: dependencies: ms: 2.1.2 @@ -2429,6 +2533,12 @@ snapshots: deep-is@0.1.4: {} + degenerator@5.0.1: + dependencies: + ast-types: 0.13.4 + escodegen: 2.1.0 + esprima: 4.0.1 + delegates@1.0.0: {} depd@2.0.0: @@ -2477,6 +2587,14 @@ snapshots: escape-string-regexp@4.0.0: {} + escodegen@2.1.0: + dependencies: + esprima: 4.0.1 + estraverse: 5.3.0 + esutils: 2.0.3 + optionalDependencies: + source-map: 0.6.1 + eslint-scope@7.2.0: dependencies: esrecurse: 4.3.0 @@ -2535,6 +2653,8 @@ snapshots: acorn-jsx: 5.3.2(acorn@8.8.2) eslint-visitor-keys: 3.4.0 + esprima@4.0.1: {} + esquery@1.5.0: dependencies: estraverse: 5.3.0 @@ -2623,6 +2743,14 @@ snapshots: get-stream@3.0.0: {} + get-uri@6.0.5: + dependencies: + basic-ftp: 5.0.5 + data-uri-to-buffer: 6.0.2 + debug: 4.3.4 + transitivePeerDependencies: + - supports-color + getpass@0.1.7: dependencies: assert-plus: 1.0.0 @@ -2697,6 +2825,13 @@ snapshots: - supports-color optional: true + http-proxy-agent@7.0.2: + dependencies: + agent-base: 7.1.4 + debug: 4.3.4 + transitivePeerDependencies: + - supports-color + https-proxy-agent@5.0.1: dependencies: agent-base: 6.0.2 @@ -2704,6 +2839,13 @@ snapshots: transitivePeerDependencies: - supports-color + https-proxy-agent@7.0.6: + dependencies: + agent-base: 7.1.4 + debug: 4.3.4 + transitivePeerDependencies: + - supports-color + humanize-ms@1.2.1: dependencies: ms: 2.1.3 @@ -2746,6 +2888,8 @@ snapshots: ini@1.3.8: {} + ip-address@10.0.1: {} + ip@2.0.0: optional: true @@ -2849,6 +2993,8 @@ snapshots: dependencies: yallist: 4.0.0 + lru-cache@7.18.3: {} + make-dir@3.1.0: dependencies: semver: 6.3.0 @@ -2954,6 +3100,8 @@ snapshots: negotiator@0.6.3: optional: true + netmask@2.0.2: {} + node-abi@3.40.0: dependencies: semver: 7.5.0 @@ -3039,6 +3187,24 @@ snapshots: aggregate-error: 3.1.0 optional: true + pac-proxy-agent@7.2.0: + dependencies: + '@tootallnate/quickjs-emscripten': 0.23.0 + agent-base: 7.1.4 + debug: 4.3.4 + get-uri: 6.0.5 + http-proxy-agent: 7.0.2 + https-proxy-agent: 7.0.6 + pac-resolver: 7.0.1 + socks-proxy-agent: 8.0.5 + transitivePeerDependencies: + - supports-color + + pac-resolver@7.0.1: + dependencies: + degenerator: 5.0.1 + netmask: 2.0.2 + pako@1.0.11: {} parent-module@1.0.1: @@ -3106,6 +3272,21 @@ snapshots: retry: 0.12.0 optional: true + proxy-agent@6.5.0: + dependencies: + agent-base: 7.1.4 + debug: 4.3.4 + http-proxy-agent: 7.0.2 + https-proxy-agent: 7.0.6 + lru-cache: 7.18.3 + pac-proxy-agent: 7.2.0 + proxy-from-env: 1.1.0 + socks-proxy-agent: 8.0.5 + transitivePeerDependencies: + - supports-color + + proxy-from-env@1.1.0: {} + pump@3.0.0: dependencies: end-of-stream: 1.4.4 @@ -3198,8 +3379,7 @@ snapshots: dependencies: is-arrayish: 0.3.2 - smart-buffer@4.2.0: - optional: true + smart-buffer@4.2.0: {} socks-proxy-agent@6.2.1: dependencies: @@ -3210,13 +3390,27 @@ snapshots: - supports-color optional: true + socks-proxy-agent@8.0.5: + dependencies: + agent-base: 7.1.4 + debug: 4.3.4 + socks: 2.8.7 + transitivePeerDependencies: + - supports-color + socks@2.7.1: dependencies: ip: 2.0.0 smart-buffer: 4.2.0 optional: true - spitroast@1.4.3: {} + socks@2.8.7: + dependencies: + ip-address: 10.0.1 + smart-buffer: 4.2.0 + + source-map@0.6.1: + optional: true sqlite3@5.1.6(encoding@0.1.13): dependencies: @@ -3315,6 +3509,8 @@ snapshots: tr46@0.0.3: {} + tslib@2.8.1: {} + tunnel-agent@0.6.0: dependencies: safe-buffer: 5.2.1 diff --git a/src/index.js b/src/index.js index 9145e52..ca9b1a8 100644 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,7 @@ const {Client, Collection, Channel, Permission} = require("@projectdysnomia/dysn const fs = require("node:fs"); const {resolve} = require("node:path"); const sqlite3 = require("sqlite3"); -const {instead, before} = require("spitroast"); +const {instead, before} = require("@marshift/strawberry"); const config = require("#root/config.json"); const apikeys = require("#root/apikeys.json"); @@ -237,11 +237,11 @@ bot.on("rawWS", (packet) => { } }); -instead("spawn", bot.shards, function (args, orig) { +instead(bot.shards, "spawn", function (args, orig) { const ret = orig.apply(this, args); const shard = this.get(args[0]); if (shard) { - before("sendWS", shard.__proto__, function ([op, _data]) { + before(shard.__proto__, "sendWS", function ([op, _data]) { if (op === GatewayOPCodes.IDENTIFY) { _data.properties.browser = "Discord Embedded"; delete _data.properties.device; diff --git a/src/modules/music.js b/src/modules/music.js index eb08173..87a0212 100644 --- a/src/modules/music.js +++ b/src/modules/music.js @@ -1,6 +1,8 @@ -const {Collection} = require("@projectdysnomia/dysnomia"); +const {Collection, VoiceConnection} = require("@projectdysnomia/dysnomia"); +const WebSocket = require("ws"); const ffprobe = require("node-ffprobe"); +const {ProxyAgent} = require("proxy-agent"); const Command = require("#lib/command.js"); @@ -21,6 +23,26 @@ let SOUNDCLOUD_CLIENTID; hf.voiceStorage = hf.voiceStorage || new Collection(); const voiceStorage = hf.voiceStorage; +if (hf.config.proxy) { + process.env.HTTP_PROXY = hf.config.proxy; + const agent = new ProxyAgent({}); + process.env.HTTP_PROXY = null; + + // temp hack until feature request fulfilled + Object.defineProperty(VoiceConnection.prototype, "ws", { + get() { + return this._ws; + }, + set(ws) { + if (ws == null) { + this._ws = null; + } else { + this._ws = WebSocket(this.endpoint.href, {agent}); + } + }, + }); +} + // https://stackoverflow.com/a/12646864 ยง "Updating to ES6 / ECMAScript 2015" function shuffleArray(array) { for (let i = array.length - 1; i > 0; i--) { @@ -278,9 +300,15 @@ async function enqueue({guild_id, voice_id, text_id, url, type, addedBy, suppres stream = !info.duration; if (info.tags) { - title = `${ - info.tags.artist ?? info.tags.ARTIST ?? info.tags.album_artist ?? info.tags.ALBUM_ARTIST ?? "" - } - ${info.tags.title ?? info.tags.TITLE ?? ""}`; + title = stream + ? info.tags.StreamTitle + : `${ + info.tags.artist ?? + info.tags.ARTIST ?? + info.tags.album_artist ?? + info.tags.ALBUM_ARTIST ?? + "" + } - ${info.tags.title ?? info.tags.TITLE ?? ""}`; } length = info.duration ? Math.floor(info.duration) * 1000 : 0; @@ -415,7 +443,8 @@ async function youtubeSearch(msg, str) { } } -const NOWPLAYING_BAR_LENGTH = 30; +const NOWPLAYING_BAR_LENGTH = 32; +const NOWPLAYING_BAR_CHAR = "\u2014"; const command = new Command("music"); command.addAlias("m"); @@ -608,6 +637,15 @@ command.callback = async function (msg, line, args, {shuffle = false, limit = -1 const connection = voiceStorage.get(msg.guildID); const nowPlaying = connection.nowplaying; if (!nowPlaying || !connection.connection.playing) return "Nothing is currently playing."; + let title = nowPlaying.title; + if (nowPlaying.stream) { + try { + const info = await ffprobe(nowPlaying.url).then((obj) => obj.format); + if (info.tags.StreamTitle) title = info.tags.StreamTitle; + } catch { + // noop + } + } const position = Date.now() - nowPlaying.start; @@ -615,35 +653,23 @@ command.callback = async function (msg, line, args, {shuffle = false, limit = -1 const timePos = formatTime(position); const progress = nowPlaying.length == 0 ? 1 : position / nowPlaying.length; - const barLength = Math.round(progress * NOWPLAYING_BAR_LENGTH); - const bar = `\`[${"=".repeat(barLength)}${" ".repeat(NOWPLAYING_BAR_LENGTH - barLength)}]\``; - const time = `\`${timePos}${" ".repeat(NOWPLAYING_BAR_LENGTH + 2 - timePos.length - timeEnd.length)}${timeEnd}\``; + const numBarChars = NOWPLAYING_BAR_LENGTH - timePos.length - timeEnd.length - 2; + const barLength = Math.round(progress * numBarChars); + + const bar = `\`\`\`ansi\n${timePos} ${NOWPLAYING_BAR_CHAR.repeat(barLength)}\x1b[30m${NOWPLAYING_BAR_CHAR.repeat( + numBarChars - barLength + )}\x1b[39m ${timeEnd}\`\`\``; return { embed: { title: ":musical_note: Now Playing", color: 0x0088cc, - fields: [ - { - name: "Title", - value: (nowPlaying.title && nowPlaying.title != nowPlaying.url - ? `[${nowPlaying.title}](${nowPlaying.url})` - : nowPlaying.url - ).substring(0, 1024), - inline: true, - }, - { - name: "Added by", - value: `<@${nowPlaying.addedBy}>`, - inline: true, - }, - { - name: bar, - value: time, - inline: false, - }, - ], + description: `## ${(title && title !== nowPlaying.url + ? `[${title}](${nowPlaying.url})` + : nowPlaying.url + ).substring(0, 1024)}\n**Added by:** <@${nowPlaying.addedBy}>\n\n${bar}`, + thumbnail: {url: nowPlaying.thumbnail}, }, }; }