To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 1f8c3168 authored by Christof Gerber's avatar Christof Gerber
Browse files

Test for video existence before upload regardless if playlist exists.

parent a3d8e2ca
Pipeline #51852 failed with stages
in 11 minutes and 26 seconds
......@@ -464,43 +464,33 @@ func LoadYouTubeAnnotationsPlaylist(playlistID string, language string, collecti
}
log.WithFields(log.Fields{"playlistID": playlistID, "language": language, "quantity": len(members)}).Trace("Videos found in playlist")
// check if playlist already exists
found, err := annotation.PlaylistExists(playlistID, collection)
if err != nil {
return err
}
var newVideos int
var newVideos []string
if found {
// only add non-existing videos
for _, videoID := range members {
found, err := annotation.VideoExists("youtube://"+videoID, collection)
if err != nil {
return err
}
// upload videos to mongoDB
for _, videoID := range members {
if !found {
newVideos = append(newVideos, videoID)
}
// check if video exists
found, err := annotation.VideoExists("youtube://"+videoID, collection)
if err != nil {
return err
}
} else {
// add all playlist videos
newVideos = members
}
log.WithFields(log.Fields{"playlistID": playlistID, "language": language, "NumVideos": len(members), "NumNewVideos": len(newVideos)}).Debug("Videos found in playlist ")
// load new videos
if !found {
// upload videos to mongoDB
for _, videoID := range newVideos {
err := loadYouTubeAnnotationsVideo(videoID, language, collection, playlist)
if err != nil {
log.Warning(err)
continue
newVideos++
err := loadYouTubeAnnotationsVideo(videoID, language, collection, playlist)
if err != nil {
log.Warning(err)
continue
}
} else {
log.WithFields(log.Fields{"id": videoID}).Trace("Video exists")
}
}
log.WithFields(log.Fields{"playlistID": playlistID, "language": language, "NumVideos": len(members), "NumNewVideos": newVideos}).Debug("Videos found in playlist ")
return nil
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment