music: more yt fixes

This commit is contained in:
Cynthia Foxwell 2023-01-23 18:22:53 -07:00
parent 046b49666d
commit a68d11f89b

View file

@ -4,7 +4,11 @@ const playdl = require("play-dl");
const ffprobe = require("node-ffprobe"); const ffprobe = require("node-ffprobe");
const Command = require("../lib/command.js"); const Command = require("../lib/command.js");
const {formatTime, selectionMessage, parseHtmlEntities} = require("../lib/utils.js"); const {
formatTime,
selectionMessage,
parseHtmlEntities,
} = require("../lib/utils.js");
const REGEX_YOUTUBE = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$/; const REGEX_YOUTUBE = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$/;
const REGEX_YOUTUBE_PLAYLIST = const REGEX_YOUTUBE_PLAYLIST =
@ -214,8 +218,11 @@ async function enqueue({
.replace("vi_webp", "vi") .replace("vi_webp", "vi")
.replace(".webp", ".jpg"); .replace(".webp", ".jpg");
const formats = info?.format; let formats = info?.format;
if (formats) { if (formats) {
formats = formats.filter(
(obj) => obj.audioQuality != null && obj.container == "webm"
);
formats.sort((a, b) => b.bitrate - a.bitrate); formats.sort((a, b) => b.bitrate - a.bitrate);
media = formats[0].url; media = formats[0].url;
} }
@ -295,7 +302,10 @@ async function enqueue({
fields: [ fields: [
{ {
name: "Title", name: "Title",
value: (title && title != url ? `[${title}](${url})` : url).substring(0, 1024), value: (title && title != url
? `[${title}](${url})`
: url
).substring(0, 1024),
inline: true, inline: true,
}, },
{ {