Add support for new SDK (0.37.*) and support for upgrading channels and claims to new metadata #28
3 changed files with 632 additions and 638 deletions
|
@ -756,7 +756,7 @@ func (s *Sync) enqueueYoutubeVideos() error {
|
||||||
}
|
}
|
||||||
_, ok := playlistMap[k]
|
_, ok := playlistMap[k]
|
||||||
if !ok {
|
if !ok {
|
||||||
notOnYoutube = append(notOnYoutube, sources.NewMockedVideo(s.videoDirectory, k, s.Manager.GetS3AWSConfig()))
|
notOnYoutube = append(notOnYoutube, sources.NewMockedVideo(s.videoDirectory, k, s.YoutubeChannelID, s.Manager.GetS3AWSConfig()))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ type YoutubeVideo struct {
|
||||||
publishedAt time.Time
|
publishedAt time.Time
|
||||||
dir string
|
dir string
|
||||||
youtubeInfo *youtube.Video
|
youtubeInfo *youtube.Video
|
||||||
|
youtubeChannelID string
|
||||||
tags []string
|
tags []string
|
||||||
awsConfig aws.Config
|
awsConfig aws.Config
|
||||||
thumbnailURL string
|
thumbnailURL string
|
||||||
|
@ -95,15 +96,17 @@ func NewYoutubeVideo(directory string, videoData *youtube.Video, playlistPositio
|
||||||
youtubeInfo: videoData,
|
youtubeInfo: videoData,
|
||||||
awsConfig: awsConfig,
|
awsConfig: awsConfig,
|
||||||
mocked: false,
|
mocked: false,
|
||||||
|
youtubeChannelID: videoData.Snippet.ChannelId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func NewMockedVideo(directory string, videoID string, awsConfig aws.Config) *YoutubeVideo {
|
func NewMockedVideo(directory string, videoID string, youtubeChannelID string, awsConfig aws.Config) *YoutubeVideo {
|
||||||
return &YoutubeVideo{
|
return &YoutubeVideo{
|
||||||
id: videoID,
|
id: videoID,
|
||||||
playlistPosition: 0,
|
playlistPosition: 0,
|
||||||
dir: directory,
|
dir: directory,
|
||||||
awsConfig: awsConfig,
|
awsConfig: awsConfig,
|
||||||
mocked: true,
|
mocked: true,
|
||||||
|
youtubeChannelID: youtubeChannelID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,23 +390,30 @@ func (v *YoutubeVideo) downloadAndPublish(daemon *jsonrpc.Client, params SyncPar
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *YoutubeVideo) getMetadata() (languages []string, locations []jsonrpc.Location, tags []string) {
|
func (v *YoutubeVideo) getMetadata() (languages []string, locations []jsonrpc.Location, tags []string) {
|
||||||
if v.mocked {
|
|
||||||
return nil, nil, tagsManager.SanitizeTags([]string{})
|
|
||||||
}
|
|
||||||
languages = nil
|
languages = nil
|
||||||
|
locations = nil
|
||||||
|
tags = nil
|
||||||
|
if !v.mocked {
|
||||||
if v.youtubeInfo.Snippet.DefaultLanguage != "" {
|
if v.youtubeInfo.Snippet.DefaultLanguage != "" {
|
||||||
languages = []string{v.youtubeInfo.Snippet.DefaultLanguage}
|
languages = []string{v.youtubeInfo.Snippet.DefaultLanguage}
|
||||||
}
|
}
|
||||||
|
|
||||||
locations = nil
|
|
||||||
if v.youtubeInfo.RecordingDetails != nil && v.youtubeInfo.RecordingDetails.Location != nil {
|
if v.youtubeInfo.RecordingDetails != nil && v.youtubeInfo.RecordingDetails.Location != nil {
|
||||||
locations = []jsonrpc.Location{{
|
locations = []jsonrpc.Location{{
|
||||||
Latitude: util.PtrToString(fmt.Sprintf("%.7f", v.youtubeInfo.RecordingDetails.Location.Latitude)),
|
Latitude: util.PtrToString(fmt.Sprintf("%.7f", v.youtubeInfo.RecordingDetails.Location.Latitude)),
|
||||||
Longitude: util.PtrToString(fmt.Sprintf("%.7f", v.youtubeInfo.RecordingDetails.Location.Longitude)),
|
Longitude: util.PtrToString(fmt.Sprintf("%.7f", v.youtubeInfo.RecordingDetails.Location.Longitude)),
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
tags = append([]string{youtubeCategories[v.youtubeInfo.Snippet.CategoryId]}, v.youtubeInfo.Snippet.Tags...)
|
tags = v.youtubeInfo.Snippet.Tags
|
||||||
tags = tagsManager.SanitizeTags(tags)
|
}
|
||||||
|
tags, err := tagsManager.SanitizeTags(tags, v.youtubeChannelID)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln(err.Error())
|
||||||
|
}
|
||||||
|
if !v.mocked {
|
||||||
|
tags = append(tags, youtubeCategories[v.youtubeInfo.Snippet.CategoryId])
|
||||||
|
}
|
||||||
|
|
||||||
return languages, locations, tags
|
return languages, locations, tags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,7 +458,6 @@ func (v *YoutubeVideo) reprocess(daemon *jsonrpc.Client, params SyncParams, exis
|
||||||
return nil, errors.Err(err)
|
return nil, errors.Err(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var description *string
|
|
||||||
if v.mocked {
|
if v.mocked {
|
||||||
pr, err := daemon.StreamUpdate(existingVideoData.ClaimID, jsonrpc.StreamUpdateOptions{
|
pr, err := daemon.StreamUpdate(existingVideoData.ClaimID, jsonrpc.StreamUpdateOptions{
|
||||||
StreamCreateOptions: &jsonrpc.StreamCreateOptions{
|
StreamCreateOptions: &jsonrpc.StreamCreateOptions{
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue