cobalt icon indicating copy to clipboard operation
cobalt copied to clipboard

Add twitch video (not clip) support

Open Slips-PC opened this issue 2 years ago • 8 comments

Seemingly, during the initial PR for Twitch Clip support, VOD support was added and then removed citing that "there's no point in downloading entire streams". Unfortunately, the /videos/ portion of the URI also happens to include highlights which are considerably more useful to download. I think it'd be nice if this was re-added if that's possible.

Slips-PC avatar Oct 21 '23 20:10 Slips-PC

I think there is actually a great point in downloading entire streams anyway! VODs do get deleted after some time and so many people do download streams to preserve them. I'd love for that to be re-added.

suprstarrd avatar Oct 28 '23 19:10 suprstarrd

hello! Any update on this?

Lemon553311-dev avatar Jan 07 '24 12:01 Lemon553311-dev

would really love to use this feature as a speedrun moderator. many runs are submitted with twitch videos, and online tools for frame perfect retimes aren't always reliable

katzerax avatar May 29 '24 22:05 katzerax

Just chiming into say this would be a nice feature, and I agree with the previous commenters. If nothing else, it's probably worth updating the documentation to say Cobalt only supports Twitch clips (and not VODs) in the meantime.

NichCodes avatar Sep 23 '24 23:09 NichCodes

Just ran into this problem of not being able to download a full VOD to create clips. Definitely worth disclaiming that only clips are supported in the “Supported services” dropdown, or clarifying it if someone enters a twitch.tv link that isn’t detected as a clip.

HaleyHalcyon avatar Oct 30 '24 01:10 HaleyHalcyon

I leave here some instruction in case of someone will want to implement vod downloading.

  1. Receive the PlaybackAccessToken via a basic gql call, like this:
PlaybackAccessToken: (vod_id: string) => {
  return {
    operationName: "PlaybackAccessToken",
    variables: {
      isLive: false,
      login: "",
      isVod: true,
      vodID: vod_id,
      playerType: "channel_home_live",
      platform: "web",
    },
    extensions: {
      persistedQuery: {
          version: 1,
          sha256Hash: "ed230aa1e33e07eebb8928504583da78a5173989fadfb1ac94be06a04f3cdbe9";
      }
    }
  }
};
  1. Get the VOD m3u8 manifest with available sources from the URL:https://usher.ttvnw.net/vod/${vod_id}.m3u8?${query}. The query parameters should include the sig and token obtained in step 1. Parse it to get URLs for different qualities. query example:
const query = new URLSearchParams({
  // not needed
  // acmb: eyJBcHBWZXJzaW9uIjoiMTQwZjZkMDMtZjUyYS00MjZiLTk4NGQtYTMyZWEwYTQyZWNkIn0=
  allow_source: "true",
  browser_family: "chrome",
  browser_version: "131.0",
  cdm: "wv",
  os_name: "Windows",
  os_version: "NT 10.0",
  p: "3141898",
  platform: "web",
  // not needed
  // play_session_id: b4c74da3c461e38af1384931fdac1b13
  player_backend: "mediaplayer",
  player_version: "1.36.0-rc.1",
  playlist_include_framerate: "true",
  reassignments_supported: "true",
  sig: sig,
  supported_codecs: "av1,h265,h264",
  token: token,
  transcode_mode: "cbr_v1",
});
  1. Choose a quality and get the final m3u8 with TS chunks (there is no need for a token here).
  2. Download the chunked video. Use url of m3u8 + name of ts chunk.

P.S.: There is no rate limiting for downloading chunks; you can download many parts concurrently (I checked 10 parallel downloads).

shevernitskiy avatar Jan 15 '25 07:01 shevernitskiy

100% upvote this.

elouangrimm avatar Jan 20 '25 15:01 elouangrimm

Is this ever happening?

Andy-Danderson avatar Jun 01 '25 15:06 Andy-Danderson