我需要以特定格式引用大约一百个YouTube视频,并希望仅使用视频URL自动生成这些引用。
我知道现有的网站可以做到这一点(例如Scribbr(,但为了提高效率,我需要不同格式的输出。
我有一些基本的HTML和Javascript能力,如果我有一种方法可以获得视频的标题、上传者的名称和发布日期(月DD,YYYY(作为字符串,我觉得我可以把它们拼凑在一起。然而,我不知道该怎么做。
我已经研究过从https://www.youtube.com/oembed?url=urlgoeshere&format=json,但这似乎不包括日期,我甚至不知道如何从中获得标题。
这个问题可能太模糊了,但你有什么建议吗?谢谢你抽出时间。
如果我有一种方法来获得视频的标题上传器和发布日期(年月日(作为字符串。
为了获得这些值,您可以按照以下步骤操作:
- 对于您的第一个请求(即:https://www.youtube.com/oembed?url=urlgoeshere&format=json(,提取通道名称:
示例:
URL:
https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=6EHSlhnE6Ck&format=json
结果-为清晰而格式化:
{
"title": "Understanding Digital Tracking",
"author_name": "GCFLearnFree.org",
"author_url": "https://www.youtube.com/user/gcflearnfree",
"type": "video",
"height": 113,
"width": 200,
"version": "1.0",
"provider_name": "YouTube",
"provider_url": "https://www.youtube.com/",
"thumbnail_height": 360,
"thumbnail_width": 480,
"thumbnail_url": "https://i.ytimg.com/vi/6EHSlhnE6Ck/hqdefault.jpg",
"html": "u003ciframe width=u0022200u0022 height=u0022113u0022 src=u0022https://www.youtube.com/embed/6EHSlhnE6Ck?feature=oembedu0022 frameborder=u00220u0022 allow=u0022accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-pictureu0022 allowfullscreenu003eu003c/iframeu003e"
}
- 通过读取";CCD_ 2";值:
"author_url":"https://www.youtube.com/user/gcflearnfree">
- 使用此请求获取视频的标题、上传者名称和发布日期:
URL:https://www.youtube.com/feeds/videos.xml?user=<name_of_the_user>
-用步骤2中获得的名称替换<name_of_the_user>
。
示例:https://www.youtube.com/feeds/videos.xml?user=gcflearnfree
- 使用步骤3中显示的URL进行请求-您将得到以下结果:
示例:
<feed
xmlns:yt="http://www.youtube.com/xml/schemas/2015"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns="http://www.w3.org/2005/Atom">
<link rel="self" href="http://www.youtube.com/feeds/videos.xml?user=gcflearnfree"/>
<id>yt:channel:UCeYUHG6o0YguM-g23htdsSw</id>
<yt:channelId>UCeYUHG6o0YguM-g23htdsSw</yt:channelId> <-- Use channel_id instead.
<title>GCFLearnFree.org</title>
<link rel="alternate" href="https://www.youtube.com/channel/UCeYUHG6o0YguM-g23htdsSw"/>
<author>
<name>GCFLearnFree.org</name> <-- Name of the publisher
<uri>https://www.youtube.com/channel/UCeYUHG6o0YguM-g23htdsSw</uri>
</author>
<published>2007-02-27T15:22:42+00:00</published><-- Publication date
<entry>
<id>yt:video:xKuJrmlCdig</id>
<yt:videoId>xKuJrmlCdig</yt:videoId>
<yt:channelId>UCeYUHG6o0YguM-g23htdsSw</yt:channelId>
<title>What is HTML?</title><-- Title of the video
<link rel="alternate" href="https://www.youtube.com/watch?v=xKuJrmlCdig"/>
<author>
<name>GCFLearnFree.org</name>
<uri>https://www.youtube.com/channel/UCeYUHG6o0YguM-g23htdsSw</uri>
</author>
<published>2021-05-04T17:29:00+00:00</published>
<updated>2021-05-05T06:31:50+00:00</updated>
<media:group>
<media:title>What is HTML?</media:title>
<media:content url="https://www.youtube.com/v/xKuJrmlCdig?version=3" type="application/x-shockwave-flash" width="640" height="390"/>
<media:thumbnail url="https://i1.ytimg.com/vi/xKuJrmlCdig/hqdefault.jpg" width="480" height="360"/>
<media:description>In this video, you’ll learn about HTML and how it is used to code webpages. We hope you enjoy! To learn more, check out our Basic HTML tutorial here: https://edu.gcfglobal.org/en/basic-html/ #whatishtml #htmlcode #learnhtml</media:description>
<media:community>
<media:starRating count="100" average="4.80" min="1" max="5"/>
<media:statistics views="1571"/>
</media:community>
</media:group>
</entry>
[More entries goes here...]
</feed>
从以前的结果中,您可以读取视频的标题、上传者的名称和发布日期(YYYY,XX月(。