64 lines
1.9 KiB
Go
64 lines
1.9 KiB
Go
package main
|
|
|
|
import (
|
|
"net/url"
|
|
"time"
|
|
)
|
|
|
|
type Integration struct {
|
|
Category string `json:"category"`
|
|
Type string `json:"type"`
|
|
}
|
|
type DimensionAppMetadata struct {
|
|
InRoomID string `json:"inRoomId"`
|
|
WrapperURLBase string `json:"wrapperUrlBase"`
|
|
WrapperID string `json:"wrapperId"`
|
|
ScalarWrapperID string `json:"scalarWrapperId"`
|
|
Integration Integration `json:"integration"`
|
|
LastUpdatedTs int64 `json:"lastUpdatedTs"`
|
|
}
|
|
type Data struct {
|
|
VideoURL string `json:"videoUrl"`
|
|
URL string `json:"url"`
|
|
DimensionAppMetadata DimensionAppMetadata `json:"dimension:app:metadata"`
|
|
}
|
|
type YoutubeWidget struct {
|
|
Type string `json:"type"`
|
|
URL string `json:"url"`
|
|
Name string `json:"name"`
|
|
Data Data `json:"data"`
|
|
CreatorUserID string `json:"creatorUserId"`
|
|
ID string `json:"id"`
|
|
RoomID string `json:"roomId"`
|
|
EventID string `json:"eventId"`
|
|
}
|
|
type Unsigned struct {
|
|
Age int `json:"age"`
|
|
}
|
|
|
|
func NewYT(videoName, videoID, roomID string) *YoutubeWidget {
|
|
encodedVod := url.QueryEscape("https://youtube.com/embed/" + videoID)
|
|
return &YoutubeWidget{
|
|
Type: "im.vector.modular.widgets",
|
|
URL: "https://" + DimensionServer + "/widgets/video?url=" + encodedVod,
|
|
Name: videoName,
|
|
Data: Data{
|
|
VideoURL: "https://www.youtube.com/watch?v=" + videoID,
|
|
URL: "https://youtube.com/embed/" + videoID,
|
|
DimensionAppMetadata: DimensionAppMetadata{
|
|
InRoomID: roomID,
|
|
WrapperURLBase: "https://" + DimensionServer + "/widgets/video?url=",
|
|
WrapperID: "video",
|
|
ScalarWrapperID: "youtube",
|
|
Integration: Integration{
|
|
Category: "widget",
|
|
Type: "youtube",
|
|
},
|
|
LastUpdatedTs: time.Now().UnixNano() / int64(time.Millisecond),
|
|
},
|
|
},
|
|
CreatorUserID: "@" + Username + ":" + HomeserverDomain,
|
|
ID: "dimension-m.video-simp",
|
|
}
|
|
}
|