alamminsalo / orion

Cross platform Twitch.tv client
GNU General Public License v3.0
315 stars 60 forks source link

VOD chat replay not working #209

Closed rakslice closed 6 years ago

rakslice commented 6 years ago

The old undocumented VOD rechat-messages API, the use of which was a hack that included parsing of an error message to get the VOD chat start offset, seems to have stopped working.

rakslice commented 6 years ago

The updated Twitch website includes new VOD chat replay functionality including the ability for VOD viewers to post a message into the recorded chat at the current time offset. https://blog.twitch.tv/chat-on-videos-feature-expanding-to-all-videos-9d71167d8b52 Clearly there's a new API required for this. It's not clear to me whether this functionality is live for all users or part of the new beta site.

rakslice commented 6 years ago

I took a quick look at the new historical chat requests.

There's an initial request:

GET https://api.twitch.tv/v5/videos/_VODID/comments?content_offset_seconds=zero-based-offset

where _VODID is the numerical identifier without a leading v and zero-based-offset is the number of seconds from the start of the VOD.

The response is JSON:

{
    "comments": [{"_id": /* a UUID */,
                  "created_at":  /* RFC-3339 time with three decimal places on the seconds */,
                  ...},
                 ...
                 ],
    "_next": /* alphanumeric string */,
    "_prev": /* alphanumeric string */
}

_next and _prev seem to be omitted when there is no further chat in that direction.

This is followed by requests:

GET https://api.twitch.tv/v5/videos/180208234/comments?cursor=string

where string is the _next value from a previous response. These have the same format of response as those for the offset-based requests.

Both of the requests have header Accept: application/vnd.twitchtv.v5+json

rakslice commented 6 years ago

The individual objects in comments look like:

{
    "_id": "77412f40-4db7-4409-a603-7a29663db3a5",
    "created_at": "2017-10-06T20:42:42.424Z",
    "updated_at": "2017-10-06T20:42:42.424Z",
    "channel_id": "12345678",
    "content_type": "video",
    "content_id": "123456789",
    "content_offset_seconds": 42.424,
    "commenter": {
        "display_name": "SomeUserName",
        "_id": "43243212",
        "name": "someusername",
        "type": "user",
        "bio": null,
        "created_at": "2014-01-01T11:11:11.424242Z",
        "updated_at": "2017-09-04T20:41:27.424242Z",
        "logo": "https://static-cdn.jtvnw.net/jtv_user_pictures/1234abcd1234abcd-profile_image-300x300.jpeg"
    },
    "source": "chat",
    "state": "published",
    "message": {
        "body": "something SomeEmote something else",
        "fragments": [{
                "text": "something "
            }, {
                "text": "SomeEmote",
                "emoticon": {
                    "emoticon_id": "123456",
                    "emoticon_set_id": ""
                }
            }
        }, {
            "text": " something else"
        }
        ],
        "is_action": false,
        "user_badges": [{
                "_id": "bits",
                "version": "1000"
            }
        ],
        "user_color": "#1234AB"
    },
    "more_replies": false
}
rakslice commented 6 years ago

I'm working on replacing the existing VOD chat replay code with a version that handles this.