Java 中的 YouTube MediaThumbnail 质量

发布于 2024-12-15 06:26:45 字数 348 浏览 3 评论 0原文

我想在使用 Java 中的 VideoEntry 时从可用的缩略图中获得最高质量的缩略图。

我正在使用 gdata 库。

我知道最好的一个是 xml 中具有属性 yt:name="hqdefault" 的属性,但我不知道如何从代码中的 MediaThumbnail 获取该属性值。

MediaThumbnail 类中没有相应的方法。

我的目标是如果可用则使用“hqdefault”,如果不可用则使用“默认”。 到目前为止,我使用的是缩略图列表中的第一个,但据我了解,它不一定是“默认”列表,因为列表可以按随机顺序出现。

有没有办法在不解析 url 的情况下找出 MediaThumbnail 的质量?

I want to get the highest quality thumbnail from the ones available while working with VideoEntry in Java.

I'm using the gdata libraries.

I know that the best one is the one with the attribute yt:name="hqdefault" in the xml but I have no idea how to get that attribute value from the MediaThumbnail in code.

There is no method for that in the MediaThumbnail class.

My goal is to use the "hqdefault" one if it's available and if not then use the "default" one.
So far I'm using the first from the thumbnail list, but as I understand it won't necessarily be the "default" one since the list can come in a random order.

Is there any way to find out the quality of the MediaThumbnail without parsing the url?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦在深巷 2024-12-22 06:26:45

以下代码列出了视频的所有可能的缩略图。选择适合您的。

for (MediaThumbnail mediaThumbnail : VideoEntry.getMediaGroup().getThumbnails()) {
System.out.println(mediaThumbnail.getUrl());
}  

Following code lists all possible thumbnails for a video. Choose whichever is suitable for you.

for (MediaThumbnail mediaThumbnail : VideoEntry.getMediaGroup().getThumbnails()) {
System.out.println(mediaThumbnail.getUrl());
}  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文