add HLSURL to Video

This commit is contained in:
Valentine 2024-04-26 01:13:39 +03:00
parent 6bcb914751
commit 715658ada4
2 changed files with 5 additions and 0 deletions

View file

@ -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"`

View file

@ -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