Skip to content

Commit

Permalink
Add missing proxy url field to the MessageEmbed.VideoInfo class (#2618)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaksternano committed Feb 17, 2024
1 parent 833563d commit 621fb7b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -676,6 +679,32 @@ public String getUrl()
return url;
}

/**
* The url of the video, proxied by Discord
* <br>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.
* <br>This usually isn't the actual video width, but instead the starting embed window size.
Expand Down
Expand Up @@ -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));
}
Expand Down

0 comments on commit 621fb7b

Please sign in to comment.