From 715658ada4d93ea20b2f7604b414b49d8693bac6 Mon Sep 17 00:00:00 2001 From: Valentine Date: Fri, 26 Apr 2024 01:13:39 +0300 Subject: [PATCH] add HLSURL to Video --- types.go | 2 ++ util.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/types.go b/types.go index be34a0d..35fccd5 100644 --- a/types.go +++ b/types.go @@ -21,6 +21,7 @@ type ( ID string Preview string URL string + HLSURL string } // GIF type. @@ -127,6 +128,7 @@ type ( URL string `json:"url"` VideoInfo struct { Variants []struct { + Type string `json:"content_type"` Bitrate int `json:"bitrate"` URL string `json:"url"` } `json:"variants"` diff --git a/util.go b/util.go index bec2573..0a2f658 100644 --- a/util.go +++ b/util.go @@ -248,6 +248,9 @@ func parseLegacyTweet(user *legacyUser, tweet *legacyTweet) *Tweet { maxBitrate := 0 for _, variant := range media.VideoInfo.Variants { + if variant.Type == "application/x-mpegURL" { + video.HLSURL = variant.URL + } if variant.Bitrate > maxBitrate { video.URL = strings.TrimSuffix(variant.URL, "?tag=10") maxBitrate = variant.Bitrate