美文网首页外文API翻译
YouTube 字幕下载 API 接口,可实现批量下载

YouTube 字幕下载 API 接口,可实现批量下载

作者: cf90a13ef126 | 来源:发表于2017-12-26 15:38 被阅读25次

    YouTube 字幕下载网站 https://zhuwei.me/y2b/ 开放了 YouTube 字幕下载 API 接口 ,字幕组、搬运工的各位同学不用再一个个手动点击下载 YouTube 的字幕素材了。

    YouTube 字幕下载 API 接口

    获取视频支持的字幕

    https://www.youtube.com/watch?v=XzK98UbxbjY 为例, 获取 video_idXzK98UbxbjY 的视频支持的字幕:
    GET https://api.zhuwei.me/v1/captions/XzK98UbxbjY
    返回结果:

    {
        "meta": {
            "code": 200, 
            "msg": "OK", 
            "limit_remaining": 92
        }, 
        "response": {
            "captions": {
                "video_url": "https://www.youtube.com/watch?v=XzK98UbxbjY", 
                "title": "Google Home | Smart Home", 
                "available_captions_count": 2, 
                "available_captions": [
                    {
                        "language": "en", 
                        "caption_content_url": "https://api.zhuwei.me/v1/captions/XzK98UbxbjY/contents/en", 
                        "autogenerated": true, 
                        "machinetranslated": false
                    }, 
                    {
                        "language": "zh-Hans", 
                        "caption_content_url": "https://api.zhuwei.me/v1/captions/XzK98UbxbjY/contents/machinetranslations/zh-Hans", 
                        "autogenerated": true, 
                        "machinetranslated": true
                    }
                ]
            }
        }
    }
    

    返回参数说明:

    • autogenerated:自动生成的字幕
    • machinetranslated:机器翻译的字幕

    获取字幕内容

    从上一步返回的支持字幕信息中,选择某语言对应的 caption_content_url,可选参数有两个 :

    • multilanguage :获取双语字幕
    • notimeline :获取的不带时间轴的字幕内容
      请求示例:
      GET https://api.zhuwei.me/v1/captions/XzK98UbxbjY/contents/en?multilanguage=multilanguage
      成功返回结果
    {
        "meta": {
            "code": 200, 
            "msg": "OK", 
            "limit_remaining": 93
        }, 
        "contents": {
            "language": "en", 
            "multilanguage": true, 
            "notimeline": false, 
            "content": "1\r\n00:00:00,030 --> 00:00:02,759\r\nthis is google help any it works with\n\u8fd9\u662f\u8c37\u6b4c\u7684\u5e2e\u52a9\u4efb\u4f55\u5b83\u4e0e\r\n\r\n2\r\n00:00:02,759 --> 00:00:04,469\r\nsmart lights smart bugs and over a\n\u667a\u80fd\u706f\u5149\u667a\u80fd\u7f3a\u9677\u548c\u5728\r\n\r\n3\r\n00:00:04,469 --> 00:00:06,450\r\nthousand other smart home devices which\n\u5343\u53f0\u667a\u80fd\u5bb6\u5c45\u8bbe\u5907\uff0c\u5176\r\n\r\n4\r\n00:00:06,450 --> 00:00:08,609\r\nis just smart like instead of always\n \u53ea\u662f\u806a\u660e\u5f97\u50cf\uff0c\u800c\u4e0d\u662f\u603b\u662f\r\n\r\n5\r\n00:00:08,609 --> 00:00:10,109\r\nturning on the garbage disposal by\n \u6253\u5f00\u5783\u573e\u5904\u7f6e\r\n\r\n6\r\n00:00:10,109 --> 00:00:12,750\r\nmistake just say hey Google turn on the\n\u9519\u8bef\u53ea\u662f\u8bf4\u563f\u8c37\u6b4c\u6253\u5f00\r\n\r\n7\r\n00:00:12,750 --> 00:00:14,699\r\nkitchen light or that moment you realize\n \u53a8\u623f\u7684\u706f\u6216\u4f60\u8ba4\u8bc6\u7684\u90a3\u4e00\u523b\r\n\r\n8\r\n00:00:14,699 --> 00:00:17,789\r\noh no the iron hey Google turn off the\n \u54e6\uff0c\u4e0d\u94c1\u54ce\u8c37\u6b4c\u5173\u95ed\r\n\r\n9\r\n00:00:17,789 --> 00:00:19,859\r\nbedroom plug you can even say hey Google\n\u5367\u5ba4\u63d2\u4ef6\uff0c\u4f60\u751a\u81f3\u53ef\u4ee5\u8bf4\u563f\u8c37\u6b4c\r\n\r\n10\r\n00:00:19,859 --> 00:00:22,559\r\nmake it cool then your wife can say hey\n \u8ba9\u5b83\u51b7\u5374\uff0c\u7136\u540e\u4f60\u7684\u59bb\u5b50\u53ef\u4ee5\u8bf4\u563f\r\n\r\n11\r\n00:00:22,559 --> 00:00:25,379\r\nGoogle make it warmer it's Google home\n\u8c37\u6b4c\u8ba9\u6e29\u6696\u5b83\u7684\u8c37\u6b4c\u4e3b\u9875\r\n\r\n12\r\n00:00:25,379 --> 00:00:28,269\r\nand Google home is now starting at $29\n\u548c\u8c37\u6b4c\u7684\u5bb6\u73b0\u5728\u5df2\u7ecf\u5f00\u59cb\u5728$ 29\u65e5\r\n\r\n13\r\n00:00:28,269 --> 00:00:30,459\r\n[Music]\n [\u97f3\u4e50] \r\n\r\n"
        }
    }
    

    注:所有请求都需要在请求参数里添加api-key ,可在 YouTube 字幕下载 API 接口 获取。

    相关文章

      网友评论

        本文标题:YouTube 字幕下载 API 接口,可实现批量下载

        本文链接:https://www.haomeiwen.com/subject/xtlxgxtx.html