potentially fix looping

add limits by db
This commit is contained in:
Niko Storni 2020-08-06 20:32:49 +02:00
parent f0280b51b4
commit 5d230a6b54
4 changed files with 20 additions and 2 deletions

View file

@ -127,6 +127,8 @@ func (s *SyncManager) Start() error {
}
lbryChannelName := channels[0].DesiredChannelName
syncs = make([]Sync, 1)
s.maxVideoLength = time.Duration(channels[0].LengthLimit) * time.Minute
s.maxVideoSize = channels[0].SizeLimit
syncs[0] = Sync{
APIConfig: s.apiConfig,
YoutubeChannelID: s.syncProperties.YoutubeChannelID,
@ -147,6 +149,7 @@ func (s *SyncManager) Start() error {
clientPublishAddress: channels[0].PublishAddress,
publicKey: channels[0].PublicKey,
transferState: channels[0].TransferState,
LastUploadedVideo: channels[0].LastUploadedVideo,
}
shouldInterruptLoop = true
} else {
@ -174,6 +177,8 @@ func (s *SyncManager) Start() error {
if c.TotalSubscribers < 1000 {
maxVideoLength = 1 * time.Hour
}
maxVideoLength = time.Duration(c.LengthLimit) * time.Minute
s.maxVideoSize = c.SizeLimit
syncs = append(syncs, Sync{
APIConfig: s.apiConfig,
YoutubeChannelID: c.ChannelId,
@ -194,6 +199,7 @@ func (s *SyncManager) Start() error {
clientPublishAddress: c.PublishAddress,
publicKey: c.PublicKey,
transferState: c.TransferState,
LastUploadedVideo: c.LastUploadedVideo,
})
if q != StatusFailed {
continue queues

View file

@ -68,6 +68,7 @@ type Sync struct {
publicKey string
defaultAccountID string
MaxVideoLength time.Duration
LastUploadedVideo string
}
func (s *Sync) AppendSyncedVideo(videoID string, published bool, failureReason string, claimName string, claimID string, metadataVersion int8, size int64) {
@ -897,7 +898,7 @@ func (s *Sync) enqueueYoutubeVideos() error {
S3Config: s.Manager.GetS3AWSConfig(),
Stopper: s.grp,
IPPool: ipPool,
})
}, s.LastUploadedVideo)
if err != nil {
return err
}

View file

@ -63,6 +63,9 @@ type YoutubeChannel struct {
TransferState int `json:"transfer_state"`
PublishAddress string `json:"publish_address"`
PublicKey string `json:"public_key"`
LengthLimit int `json:"length_limit"`
SizeLimit int `json:"size_limit"`
LastUploadedVideo string `json:"last_uploaded_video"`
}
func (a *APIConfig) FetchChannels(status string, cp *SyncProperties) ([]YoutubeChannel, error) {

View file

@ -53,7 +53,7 @@ type VideoParams struct {
var mostRecentlyFailedChannel string // TODO: fix this hack!
func GetVideosToSync(config *sdk.APIConfig, channelID string, syncedVideos map[string]sdk.SyncedVideo, quickSync bool, maxVideos int, videoParams VideoParams) ([]Video, error) {
func GetVideosToSync(config *sdk.APIConfig, channelID string, syncedVideos map[string]sdk.SyncedVideo, quickSync bool, maxVideos int, videoParams VideoParams, lastUploadedVideo string) ([]Video, error) {
var videos []Video
if quickSync && maxVideos > 50 {
@ -70,6 +70,14 @@ func GetVideosToSync(config *sdk.APIConfig, channelID string, syncedVideos map[s
for i, videoID := range videoIDs {
playlistMap[videoID] = int64(i)
}
//this will ensure that we at least try to sync the video that was marked as last uploaded video in the database.
if lastUploadedVideo != "" {
_, ok := playlistMap[lastUploadedVideo]
if !ok {
playlistMap[lastUploadedVideo] = 0
videoIDs = append(videoIDs, lastUploadedVideo)
}
}
if len(videoIDs) < 1 {
if channelID == mostRecentlyFailedChannel {