From 621fb7bf897293b2ce71c26cdca1bcf4cf17765e Mon Sep 17 00:00:00 2001 From: shaksternano <54268387+shaksternano@users.noreply.github.com> Date: Sat, 17 Feb 2024 11:16:16 +0000 Subject: [PATCH] Add missing proxy url field to the MessageEmbed.VideoInfo class (#2618) --- .../jda/api/entities/MessageEmbed.java | 31 ++++++++++++++++++- .../jda/internal/entities/EntityBuilder.java | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java b/src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java index d677147059..13efabaf0b 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java +++ b/src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java @@ -18,6 +18,7 @@ import net.dv8tion.jda.annotations.ForRemoval; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.utils.AttachmentProxy; +import net.dv8tion.jda.api.utils.FileProxy; import net.dv8tion.jda.api.utils.ImageProxy; import net.dv8tion.jda.api.utils.data.DataArray; import net.dv8tion.jda.api.utils.data.DataObject; @@ -655,12 +656,14 @@ public boolean equals(Object obj) public static class VideoInfo { protected final String url; + protected final String proxyUrl; protected final int width; protected final int height; - public VideoInfo(String url, int width, int height) + public VideoInfo(String url, String proxyUrl, int width, int height) { this.url = url; + this.proxyUrl = proxyUrl; this.width = width; this.height = height; } @@ -676,6 +679,32 @@ public String getUrl() return url; } + /** + * The url of the video, proxied by Discord + *
This url is used to access the video through Discord instead of directly to prevent ip scraping. + * + * @return Possibly-null String containing the proxied video url. + */ + @Nullable + public String getProxyUrl() + { + return proxyUrl; + } + + /** + * Returns a {@link FileProxy} for this embed video. + * + * @return Possibly-null {@link FileProxy} of this embed video + * + * @see #getProxyUrl() + */ + @Nullable + public FileProxy getProxy() + { + final String proxyUrl = getProxyUrl(); + return proxyUrl == null ? null : new FileProxy(proxyUrl); + } + /** * The width of the video. *
This usually isn't the actual video width, but instead the starting embed window size. diff --git a/src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java b/src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java index 6b30eab45b..00440cd534 100644 --- a/src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java +++ b/src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java @@ -1991,6 +1991,7 @@ public MessageEmbed createMessageEmbed(DataObject content) { DataObject obj = content.getObject("video"); video = new VideoInfo(obj.getString("url", null), + obj.getString("proxy_url", null), obj.getInt("width", -1), obj.getInt("height", -1)); }