Init
This commit is contained in:
parent
264c97183e
commit
3faede7b1c
74 changed files with 6228 additions and 1 deletions
55
ext/pinterest/util.go
Normal file
55
ext/pinterest/util.go
Normal file
|
@ -0,0 +1,55 @@
|
|||
package pinterest
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"govd/enums"
|
||||
"govd/models"
|
||||
"govd/util/parser"
|
||||
)
|
||||
|
||||
func ParseVideoObject(videoObj *Videos) ([]*models.MediaFormat, error) {
|
||||
var formats []*models.MediaFormat
|
||||
|
||||
for key, video := range videoObj.VideoList {
|
||||
if key != "HLS" {
|
||||
formats = append(formats, &models.MediaFormat{
|
||||
FormatID: key,
|
||||
URL: []string{video.URL},
|
||||
Type: enums.MediaTypeVideo,
|
||||
VideoCodec: enums.MediaCodecAVC,
|
||||
AudioCodec: enums.MediaCodecAAC,
|
||||
Width: video.Width,
|
||||
Height: video.Height,
|
||||
Duration: video.Duration / 1000,
|
||||
Thumbnail: []string{video.Thumbnail},
|
||||
})
|
||||
} else {
|
||||
hlsFormats, err := parser.ParseM3U8FromURL(video.URL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to extract hls formats: %w", err)
|
||||
}
|
||||
for _, hlsFormat := range hlsFormats {
|
||||
hlsFormat.Duration = video.Duration / 1000
|
||||
hlsFormat.Thumbnail = []string{video.Thumbnail}
|
||||
formats = append(formats, hlsFormat)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return formats, nil
|
||||
}
|
||||
|
||||
func BuildPinRequestParams(pinID string) map[string]string {
|
||||
options := map[string]interface{}{
|
||||
"options": map[string]interface{}{
|
||||
"field_set_key": "unauth_react_main_pin",
|
||||
"id": pinID,
|
||||
},
|
||||
}
|
||||
|
||||
jsonData, _ := json.Marshal(options)
|
||||
return map[string]string{
|
||||
"data": string(jsonData),
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue