diff --git a/sources/ucbVideo.go b/sources/ucbVideo.go index 23adfb8..deb1286 100644 --- a/sources/ucbVideo.go +++ b/sources/ucbVideo.go @@ -44,6 +44,10 @@ func (v ucbVideo) ID() string { return v.id } +func (v ucbVideo) PlaylistPosition() int { + return 0 +} + func (v ucbVideo) IDAndNum() string { return v.ID() + " (?)" } diff --git a/sources/youtubeVideo.go b/sources/youtubeVideo.go index 52c871c..15c87a2 100644 --- a/sources/youtubeVideo.go +++ b/sources/youtubeVideo.go @@ -46,6 +46,10 @@ func (v YoutubeVideo) ID() string { return v.id } +func (v YoutubeVideo) PlaylistPosition() int { + return int(v.playlistPosition) +} + func (v YoutubeVideo) IDAndNum() string { return v.ID() + " (" + strconv.Itoa(int(v.playlistPosition)) + " in channel)" } @@ -120,6 +124,16 @@ func (v YoutubeVideo) download() error { return videoInfo.Download(videoInfo.Formats.Best(ytdl.FormatAudioEncodingKey)[0], downloadedFile) } +func (v YoutubeVideo) delete() error { + videoPath := v.getFilename() + err := os.Remove(videoPath) + if err != nil { + return err + } + log.Debugln(v.id + " deleted from disk (" + videoPath + ")") + return nil +} + func (v YoutubeVideo) triggerThumbnailSave() error { client := &http.Client{Timeout: 30 * time.Second} @@ -199,6 +213,13 @@ func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount f return errors.Prefix("publish error", err) } + err = v.delete() + if err != nil { + // the video was published anyway so it should be marked as published + // for that to happen, no errors should be returned any further than here + log.Debugln(errors.Prefix("delete error", err)) + } + return nil } diff --git a/ytsync.go b/ytsync.go index 781709e..3ca763d 100644 --- a/ytsync.go +++ b/ytsync.go @@ -36,6 +36,7 @@ const ( type video interface { ID() string IDAndNum() string + PlaylistPosition() int PublishedAt() time.Time Sync(*jsonrpc.Client, string, float64, string) error }