From cd7d7b3c36ccd4577572a7cd150c629f71848737 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Thu, 28 Sep 2023 21:39:23 -0600 Subject: [PATCH] music: attempt to remap HLS urls to not be relative and see if ffmpeg accepts it --- src/modules/music.js | 9 +++++--- src/modules/utility.js | 48 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/src/modules/music.js b/src/modules/music.js index 393c185..2090224 100644 --- a/src/modules/music.js +++ b/src/modules/music.js @@ -232,10 +232,13 @@ async function enqueue({ length = info?.duration * 1000; thumbnail = info?.thumbnailUrl; + const hlsUrl = new URL(info.hls); media = Readable.from( - await fetch( - info?.audioStreams?.sort((a, b) => a.bitrate - b.bitrate)?.[0]?.url - ).then((res) => res.body) + await fetch(info.hls) + .then((res) => res.text()) + .then((data) => + data.replaceAll("/api/manifest/", `https://${hlsUrl.hostname}$1`) + ) ); } else if (type == "sc") { if (url?.startsWith("sc:")) diff --git a/src/modules/utility.js b/src/modules/utility.js index 02b3093..fce8fdb 100644 --- a/src/modules/utility.js +++ b/src/modules/utility.js @@ -145,17 +145,24 @@ const GUILD_FEATURES = { ANIMATED_ICON: {icon: "\u{1f39e}"}, APPLICATION_COMMAND_PERMISSIONS_V2: {icon: "\u2699\ufe0f"}, AUTO_MODERATION: {icon: "\u{1f6e1}"}, + AUTOMOD_TRIGGER_KEYWORD_FILTER: {icon: "\u{1f6e1}"}, + AUTOMOD_TRIGGER_ML_SPAM_FILTER: {icon: "\u{1f6e1}"}, + AUTOMOD_TRIGGER_SPAM_LINK_FILTER: {icon: "\u{1f6e1}"}, AUTOMOD_TRIGGER_USER_PROFILE: {icon: "\u{1faaa}"}, BANNER: {icon: "\u{1f5bc}"}, BFG: {icon: "\u{1f388}", name: "BFG"}, + BOOSTING_TIERS_EXPERIMENT_MEDIUM_GUILD: {icon: "\u{1f48e}"}, + BOOSTING_TIERS_EXPERIMENT_SMALL_GUILD: {icon: "\u{1f48e}"}, BOT_DEVELOPER_EARLY_ACCESS: {icon: "\u{1f9ea}"}, BURST_REACTIONS: {icon: "\u2728", name: "Super Reactions"}, + CHANNEL_BANNER: {icon: "\u{1f5bc}"}, CHANNEL_ICON_EMOJIS_GENERATED: {icon: "\u{1f603}"}, CHANNEL_HIGHLIGHTS: {icon: "\u{1f5c3}"}, CHANNEL_HIGHLIGHTS_DISABLED: {icon: "\u{1f6ab}"}, CLYDE_DISABLED: {icon: "\u{1f6ab}"}, CLYDE_ENABLED: {icon: "\u{1f916}"}, CLYDE_EXPERIMENT_ENABLED: {icon: "\u{1f9ea}"}, + COMMERCE: {icon: "\u{1f6cd}"}, COMMUNITY: {icon: "\u{1f3d8}"}, COMMUNITY_CANARY: {icon: "\u{1f9ea}"}, COMMUNITY_EXP_LARGE_GATED: {icon: "\u{1f3d8}"}, @@ -175,15 +182,25 @@ const GUILD_FEATURES = { DISCOVERABLE_DISABLED: {icon: "\u{1f6ab}"}, ENABLED_DISCOVERABLE_BEFORE: {icon: "\u{1f9ed}"}, EXPOSED_TO_ACTIVITIES_WTP_EXPERIMENT: {icon: "\u{1f9ea}"}, + EXPOSED_TO_BOOSTING_TIERS_EXPERIMENT: {icon: "\u{1f9ea}"}, + FEATURABLE: {icon: "\u{1f9ed}"}, + FORCE_RELAY: {icon: "\u{1f4fb}"}, GUESTS_ENABLED: {icon: "\u{1f465}"}, + GUILD_AUTOMOD_DEFAULT_LIST: {icon: "\u{1f6e1}"}, + GUILD_COMMUNICATION_DISABLED_GUILDS: {icon: "\u{1f6d1}"}, GUILD_HOME_DEPRECATION_OVERRIDE: {icon: "\u{1f3da}"}, GUILD_HOME_OVERRIDE: {icon: "\u{1f3e0}"}, GUILD_HOME_TEST: {icon: "\u{1f9ea}"}, GUILD_MEMBER_VERIFICATION_EXPERIMENT: {icon: "\u{1f9ea}"}, GUILD_ONBOARDING: {icon: "\u{1f5f3}"}, + GUILD_ONBOARDING_ADMIN_ONLY: {icon: "\u{1f5f3}"}, GUILD_ONBOARDING_EVER_ENABLED: {icon: "\u{1f5f3}"}, GUILD_ONBOARDING_HAS_PROMPTS: {icon: "\u{1f5f3}"}, GUILD_PRODUCTS: {icon: "\u{1f6cd}"}, + GUILD_ROLE_SUBSCRIPTIONS: {icon: "\u{1f4b3}"}, + GUILD_ROLE_SUBSCRIPTION_PURCHASE_FEEDBACK_LOOP: {icon: "\u{1f4b3}"}, + GUILD_ROLE_SUBSCRIPTION_TIER_TEMPLATE: {icon: "\u{1f4b3}"}, + GUILD_ROLE_SUBSCRIPTION_TRIALS: {icon: "\u{1f4b3}"}, GUILD_SERVER_GUIDE: {icon: "\u{1f9ae}"}, GUILD_WEB_PAGE_VANITY_URL: {icon: "\u{1f4c4}"}, HAD_EARLY_ACTIVITIES_ACCESS: {icon: "\u{1f680}"}, @@ -195,22 +212,37 @@ const GUILD_FEATURES = { INVITE_SPLASH: {icon: "\u{1f5bc}"}, INVITES_DISABLED: {icon: "\u26d4"}, LINKED_TO_HUB: {icon: "\u{1f3eb}"}, + LURKABLE: {icon: "\u{1f441}"}, + MARKETPLACES_CONNECTION_ROLES: {icon: "\u{1f517}"}, + MEDIA_CHANNEL_ALPHA: {icon: "\u{1f5bc}"}, + MEMBER_LIST_DISABLED: {icon: "\u{1f6ab}"}, + MEMBER_PROFILES: {icon: "\u{1faaa}"}, MEMBER_SAFETY_PAGE_ROLLOUT: {icon: "\u{1f6e1}"}, MEMBER_VERIFICATION_GATE_ENABLED: {icon: "\u{1f6e1}"}, MEMBER_VERIFICATION_MANUAL_APPROVAL: {icon: "\u2705"}, + MOBILE_WEB_ROLE_SUBSCRIPTION_PURCHASE_PAGE: {icon: "\u{1f4b3}"}, + MONETIZATION_ENABLED: {icon: "\u{1f4b0}"}, MORE_EMOJI: {icon: "\u{1f603}"}, MORE_STICKERS: {icon: "\u{1f5bc}"}, NEWS: {icon: "\u{1f4f0}"}, + NEW_THREAD_PERMISSIONS: {icon: "\u{1f9f5}"}, NON_COMMUNITY_RAID_ALERTS: {icon: "\u{1f6a8}"}, PARTNERED: {icon: "\u267e\ufe0f"}, PREMIUM_TIER_3_OVERRIDE: {icon: "\u{1f48e}"}, PREVIEW_ENABLED: {icon: "\u{1f441}"}, + PRIVATE_THREADS: {icon: "\u{1f9f5}"}, PRODUCTS_AVAILABLE_FOR_PURCHASE: {icon: "\u{1f6cd}"}, + PUBLIC: {icon: "\u{1f9ed}"}, + PUBLIC_DISABLED: {icon: "\u{1f6ab}"}, RAID_ALERTS_DISABLED: {icon: "\u{1f6ab}"}, + RAID_ALERTS_ENABLED: {icon: "\u{1f6a8}"}, RELAY_ENABLED: {icon: "\u{1f4fb}"}, + RESTRICT_SPAM_RISK_GUILDS: {icon: "\u{1f6d1}"}, ROLE_ICONS: {icon: "\u{1f3f7}"}, ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE: {icon: "\u{1f4b3}"}, ROLE_SUBSCRIPTIONS_ENABLED: {icon: "\u{1f4b3}"}, + ROLE_SUBSCRIPTIONS_ENABLED_FOR_PURCHASE: {icon: "\u{1f4b3}"}, + SEVEN_DAY_THREAD_ARCHIVE: {icon: "\u{1f9f5}"}, SHARD: {icon: "\u{1f4a0}"}, SHARED_CANVAS_FRIENDS_AND_FAMILY_TEST: {icon: "\u{1f58c}"}, SOUNDBOARD: {icon: "\u{1f50a}"}, @@ -224,10 +256,19 @@ const GUILD_FEATURES = { SUMMARIES_LONG_LOOKBACK: {icon: "\u{1f5c2}"}, STAFF_LEVEL_COLLABORATOR_REQUIRED: {icon: "\u{1f6e0}"}, STAFF_LEVEL_RESTRICTED_COLLABORATOR_REQUIRED: {icon: "\u{1f6e0}"}, + TEXT_IN_STAGE_ENABLED: {icon: "\u{1f5e8}"}, + TEXT_IN_VOICE_ENABLED: {icon: "\u{1f5e8}"}, + THREADS_ENABLED_TESTING: {icon: "\u{1f9f5}"}, + THREADS_ENABLED: {icon: "\u{1f9f5}"}, THREAD_DEFAULT_AUTO_ARCHIVE_DURATION: {icon: "\u{1f9f5}"}, + THREADS_ONLY_CHANNEL: {icon: "\u{1f5e8}", name: "Forum Channels"}, + THREE_DAY_THREAD_ARCHIVE: {icon: "\u{1f9f5}"}, + TICKETED_EVENTS_ENABLED: {icon: "\u{1f39f}"}, + TICKETING_ENABLED: {icon: "\u{1f39f}"}, VANITY_URL: {icon: "\u{1f517}"}, VERIFIED: {icon: "\u2b50"}, VIP_REGIONS: {icon: "\u{1f399}"}, + VOICE_CHANNEL_EFFECTS: {icon: "\u2728"}, VOICE_IN_THREADS: {icon: "\u{1f399}"}, WELCOME_SCREEN_ENABLED: {icon: "\u{1f44b}"}, }; @@ -991,11 +1032,12 @@ presence.callback = async function (msg, line) { if (target) { if (!target.clientStatus) return `**${pomello(target)}** is offline.`; - let icons = ""; + const icons = []; for (const platform of Object.keys(target.clientStatus)) { const status = target.clientStatus[platform]; + if (status == "offline") continue; - icons += (PRESENCE_ICONS[platform][status] ?? "") + " "; + icons.push(PRESENCE_ICONS[platform][status]); } const embeds = []; @@ -1203,7 +1245,7 @@ presence.callback = async function (msg, line) { } return { - content: `Presence for **${pomello(target)}**: ${icons.trim()}`, + content: `Presence for **${pomello(target)}**: ${icons.join(" ")}`, embeds, files, };