ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
130.49k stars 9.85k forks source link

Add support for “danmaku” subtitles on nicovideo.jp #13841

Open linkmauve opened 7 years ago

linkmauve commented 7 years ago

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2017.08.06. If it's not, read this FAQ entry and update. Issues with outdated version will be rejected.

Before submitting an issue make sure you have:

What is the purpose of your issue?


If the purpose of this issue is a site support request please provide all kinds of example URLs support for which should be included (replace following example URLs by yours):


Description of your issue, suggested solution and other information

Most videos on nicovideo.jp contain an XML file representing comments from users, meant to be rendered on top of the video in a similar way as subtitles.

youtube-dl should expose a way to retrieve this track, either to then convert it to ass, or to (be made available to video players](https://github.com/mpv-player/mpv/issues/4722).

yan12125 commented 7 years ago

As a reference, for HTML5 videos, danmaku is served via a mysterious format from /api.json/

[
    {
        "ping": {
            "content": "rs:0"
        }
    },
    {
        "ping": {
            "content": "ps:0"
        }
    },
    {
        "thread": {
            "language": 1,
            "last_res": 1,
            "resultcode": 0,
            "revision": 1,
            "server_time": 1502041119,
            "thread": "1498481660",
            "ticket": "0x2e826693"
        }
    },
    {
        "leaf": {
            "count": 1,
            "language": 1,
            "thread": "1498481660"
        }
    },
    {
        "ping": {
            "content": "pf:0"
        }
    },
    {
        "ping": {
            "content": "ps:1"
        }
    },
    {
        "thread": {
            "language": 1,
            "last_res": 1,
            "resultcode": 0,
            "revision": 1,
            "server_time": 1502041119,
            "thread": "1498481660",
            "ticket": "0x2e826693"
        }
    },
    {
        "chat": {
            "anonymity": 1,
            "content": "给战姬打call,终于要出了",
            "date": 1498483144,
            "date_usec": 187515,
            "language": 1,
            "mail": "184",
            "no": 1,
            "premium": 1,
            "thread": "1498481660",
            "user_id": "7BSCuGwpjDFvigUQMAaMjC-q1WA",
            "vpos": 1402
        }
    },
    {
        "ping": {
            "content": "pf:1"
        }
    },
    {
        "ping": {
            "content": "ps:2"
        }
    },
    {
        "thread": {
            "fork": 1,
            "last_res": 1,
            "resultcode": 0,
            "revision": 1,
            "server_time": 1502041119,
            "thread": "1498481660",
            "ticket": "1500127358"
        }
    },
    {
        "global_num_res": {
            "num_res": 931,
            "thread": "1498481660"
        }
    },
    {
        "chat": {
            "content": "@ジャンプ sm31574832",
            "date": 1500127358,
            "date_usec": 201000,
            "fork": 1,
            "no": 1,
            "thread": "1498481660",
            "vpos": 19800
        }
    },
    {
        "ping": {
            "content": "pf:2"
        }
    },
    {
        "ping": {
            "content": "rf:0"
        }
    }
]

This is captured from http://www.nicovideo.jp/watch/sm31464864.

kayb94 commented 6 years ago

So the "chat" -> "content" is what is supposed to be the subtitle (I don't know japanese)?

"date" seems to be epoch, I mean seconds since 01/01/1970. It can be converted on command line e.g. by the following: > date --date='@1500127358' Sat Jul 15 16:02:38 CEST 2017

EDIT: At least I am not interested after seeing nicovideo requires login. ^^

usushio commented 6 years ago

Hi, I found a blog article that explains the various fields in the JSON file here (in Japanese): https://qiita.com/tor4kichi/items/74939b49954d3e72d789 Hopefully, it will be useful for this purpose.