2021-07-26 17:26:39 -07:00
|
|
|
package scraper
|
|
|
|
|
2021-08-03 15:38:19 -07:00
|
|
|
import (
|
2022-03-13 17:09:43 -07:00
|
|
|
"path"
|
2021-08-03 15:38:19 -07:00
|
|
|
)
|
|
|
|
|
2021-08-04 01:23:55 -07:00
|
|
|
type ImageID int64
|
2021-08-01 15:52:04 -07:00
|
|
|
|
2021-07-26 17:26:39 -07:00
|
|
|
type Image struct {
|
2023-06-27 21:56:29 -03:00
|
|
|
ID ImageID `db:"id"`
|
|
|
|
TweetID TweetID `db:"tweet_id"`
|
|
|
|
Width int `db:"width"`
|
|
|
|
Height int `db:"height"`
|
|
|
|
RemoteURL string `db:"remote_url"`
|
|
|
|
LocalFilename string `db:"local_filename"`
|
|
|
|
IsDownloaded bool `db:"is_downloaded"`
|
2021-07-26 17:26:39 -07:00
|
|
|
}
|
2021-08-03 15:38:19 -07:00
|
|
|
|
2021-08-03 17:34:44 -07:00
|
|
|
func ParseAPIMedia(apiMedia APIMedia) Image {
|
2022-10-15 15:06:06 -04:00
|
|
|
local_filename := get_prefixed_path(path.Base(apiMedia.MediaURLHttps))
|
|
|
|
|
2022-03-13 17:09:43 -07:00
|
|
|
return Image{
|
|
|
|
ID: ImageID(apiMedia.ID),
|
|
|
|
RemoteURL: apiMedia.MediaURLHttps,
|
|
|
|
Width: apiMedia.OriginalInfo.Width,
|
|
|
|
Height: apiMedia.OriginalInfo.Height,
|
|
|
|
LocalFilename: local_filename,
|
|
|
|
IsDownloaded: false,
|
|
|
|
}
|
2021-08-03 17:34:44 -07:00
|
|
|
}
|