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 1c0daf49 authored by Christof Gerber's avatar Christof Gerber
Browse files

Upload only non-existent videos with LoadYouTubeAnnotationsPlaylist

parent 589809d5
Pipeline #51590 failed with stages
in 75 minutes and 1 second
......@@ -3,12 +3,15 @@ module gitlab.ethz.ch/chgerber/youtubedl
go 1.12
require (
github.com/asticode/go-astisub v0.0.0-20190514140258-c0ed7925c393
github.com/asticode/go-astisub v0.0.0-20191118142924-b4f5e92c6747
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.3.0
gitlab.ethz.ch/chgerber/MessageComposition v0.0.0-20190606100759-1b591f45e7e5
gitlab.ethz.ch/chgerber/annotation/v2 v2.2.0
github.com/stretchr/testify v1.4.0
gitlab.ethz.ch/chgerber/MessageComposition v0.4.4
gitlab.ethz.ch/chgerber/annotation v1.0.0
gitlab.ethz.ch/chgerber/annotation/v2 v2.2.1-0.20191202155807-228a1bc5e412
gitlab.ethz.ch/chgerber/monitor v0.0.0-20190527191251-2bb9dd731340
go.mongodb.org/mongo-driver v1.0.3
google.golang.org/api v0.6.0
go.mongodb.org/mongo-driver v1.1.3
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d // indirect
google.golang.org/api v0.14.0
)
This diff is collapsed.
......@@ -437,7 +437,36 @@ func LoadYouTubeAnnotationsPlaylist(playlistID string, language string, collecti
}
log.WithFields(log.Fields{"playlistID": playlistID, "language": language, "quantity": len(members)}).Trace("Videos found in playlist")
for _, videoID := range members {
// check if playlist already exists
found, err := annotation.PlaylistExists(playlistID, collection)
if err != nil {
return err
}
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
}
if !found {
newVideos = append(newVideos, videoID)
}
}
} 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 ")
// upload videos to mongoDB
for _, videoID := range newVideos {
err := loadYouTubeAnnotationsVideo(videoID, language, collection, playlist)
if err != nil {
log.Warning(err)
......
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