41 lines
879 B
Go
Raw Normal View History

package scraper
import (
"fmt"
"sort"
)
type VideoID int64
// TODO video-source-user: extract source user information (e.g., someone shares a video
// from someone else).
2021-08-01 15:52:04 -07:00
type Video struct {
2021-08-01 15:52:04 -07:00
ID VideoID
TweetID TweetID
2021-10-10 16:06:47 -07:00
Width int
Height int
RemoteURL string
LocalFilename string
IsDownloaded bool
2021-10-04 21:06:53 -07:00
IsGif bool
}
func ParseAPIVideo(apiVideo APIExtendedMedia, tweet_id TweetID) Video {
variants := apiVideo.VideoInfo.Variants
sort.Sort(variants)
local_filename := fmt.Sprintf("%d.mp4", tweet_id)
return Video{
ID: VideoID(apiVideo.ID),
TweetID: tweet_id,
2021-10-10 16:06:47 -07:00
Width: apiVideo.OriginalInfo.Width,
Height: apiVideo.OriginalInfo.Height,
RemoteURL: variants[0].URL,
LocalFilename: local_filename,
IsDownloaded: false,
2021-10-04 21:06:53 -07:00
IsGif: apiVideo.Type == "animated_gif",
}
}