如何通过Powershell获取YouTube视频详细信息(标题,作者,持续时间等)?

时间:2017-05-27 05:10:49

标签: powershell youtube youtube-data-api

我有这个剧本:

param(
  [String]$VideoId
)

[String]$gdata_uri = "http://gdata.youtube.com/feeds/api/videos/$VideoId"

$metadata = irm $gdata_uri
$duration = $metadata.entry['media:group']['yt:duration'].seconds
echo $duration

获得了所需YouTube视频的持续时间,但从那时起API已经发生变化,不再有效。我获得了一个API密钥,并将旧的API链接与新的API链接交换:https://www.googleapis.com/youtube/v3/videos?id=$VideoId&key=<my_api_key>&part=contentDetails但它仍然不起作用,因此其他一些内容已经更改。

有人可以帮助调整此脚本以使用新API,还可以从持续时间获取其他信息吗?

1 个答案:

答案 0 :(得分:2)

好的,我终于开始工作了。对不起,如果我把时间浪费在我容易回答的问题上。

只需将select drop_views_by_owner('newuser'); -- list views and drop them select drop_views_by_owner('newuser', false); -- only list views select drop_functions_by_owner('newuser'); -- list functions and drop them select drop_functions_by_owner('newuser', false); -- only list functions 更改为$duration = $metadata.entry['media:group']['yt:duration'].seconds,并根据作者等其他信息进行调整,您可以在浏览器中输入API网址,找出要更改的内容。

现在我需要确定如何将ISO8601设置为秒,但我想我现在将传递Stack Overflow ...

编辑:在这里,如果您是来自Google,因为我无法找到如何将YouTube持续时间字符串设置为秒的直接答案,我是通过以下部分制作的:

$duration = $metadata.items.contentDetails.duration

现金:

祝你好运。