potentially fix looping
add limits by db
This commit is contained in:
parent
f0280b51b4
commit
5d230a6b54
4 changed files with 20 additions and 2 deletions
|
@ -127,6 +127,8 @@ func (s *SyncManager) Start() error {
|
||||||
}
|
}
|
||||||
lbryChannelName := channels[0].DesiredChannelName
|
lbryChannelName := channels[0].DesiredChannelName
|
||||||
syncs = make([]Sync, 1)
|
syncs = make([]Sync, 1)
|
||||||
|
s.maxVideoLength = time.Duration(channels[0].LengthLimit) * time.Minute
|
||||||
|
s.maxVideoSize = channels[0].SizeLimit
|
||||||
syncs[0] = Sync{
|
syncs[0] = Sync{
|
||||||
APIConfig: s.apiConfig,
|
APIConfig: s.apiConfig,
|
||||||
YoutubeChannelID: s.syncProperties.YoutubeChannelID,
|
YoutubeChannelID: s.syncProperties.YoutubeChannelID,
|
||||||
|
@ -147,6 +149,7 @@ func (s *SyncManager) Start() error {
|
||||||
clientPublishAddress: channels[0].PublishAddress,
|
clientPublishAddress: channels[0].PublishAddress,
|
||||||
publicKey: channels[0].PublicKey,
|
publicKey: channels[0].PublicKey,
|
||||||
transferState: channels[0].TransferState,
|
transferState: channels[0].TransferState,
|
||||||
|
LastUploadedVideo: channels[0].LastUploadedVideo,
|
||||||
}
|
}
|
||||||
shouldInterruptLoop = true
|
shouldInterruptLoop = true
|
||||||
} else {
|
} else {
|
||||||
|
@ -174,6 +177,8 @@ func (s *SyncManager) Start() error {
|
||||||
if c.TotalSubscribers < 1000 {
|
if c.TotalSubscribers < 1000 {
|
||||||
maxVideoLength = 1 * time.Hour
|
maxVideoLength = 1 * time.Hour
|
||||||
}
|
}
|
||||||
|
maxVideoLength = time.Duration(c.LengthLimit) * time.Minute
|
||||||
|
s.maxVideoSize = c.SizeLimit
|
||||||
syncs = append(syncs, Sync{
|
syncs = append(syncs, Sync{
|
||||||
APIConfig: s.apiConfig,
|
APIConfig: s.apiConfig,
|
||||||
YoutubeChannelID: c.ChannelId,
|
YoutubeChannelID: c.ChannelId,
|
||||||
|
@ -194,6 +199,7 @@ func (s *SyncManager) Start() error {
|
||||||
clientPublishAddress: c.PublishAddress,
|
clientPublishAddress: c.PublishAddress,
|
||||||
publicKey: c.PublicKey,
|
publicKey: c.PublicKey,
|
||||||
transferState: c.TransferState,
|
transferState: c.TransferState,
|
||||||
|
LastUploadedVideo: c.LastUploadedVideo,
|
||||||
})
|
})
|
||||||
if q != StatusFailed {
|
if q != StatusFailed {
|
||||||
continue queues
|
continue queues
|
||||||
|
|
|
@ -68,6 +68,7 @@ type Sync struct {
|
||||||
publicKey string
|
publicKey string
|
||||||
defaultAccountID string
|
defaultAccountID string
|
||||||
MaxVideoLength time.Duration
|
MaxVideoLength time.Duration
|
||||||
|
LastUploadedVideo string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sync) AppendSyncedVideo(videoID string, published bool, failureReason string, claimName string, claimID string, metadataVersion int8, size int64) {
|
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(),
|
S3Config: s.Manager.GetS3AWSConfig(),
|
||||||
Stopper: s.grp,
|
Stopper: s.grp,
|
||||||
IPPool: ipPool,
|
IPPool: ipPool,
|
||||||
})
|
}, s.LastUploadedVideo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,9 @@ type YoutubeChannel struct {
|
||||||
TransferState int `json:"transfer_state"`
|
TransferState int `json:"transfer_state"`
|
||||||
PublishAddress string `json:"publish_address"`
|
PublishAddress string `json:"publish_address"`
|
||||||
PublicKey string `json:"public_key"`
|
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) {
|
func (a *APIConfig) FetchChannels(status string, cp *SyncProperties) ([]YoutubeChannel, error) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ type VideoParams struct {
|
||||||
|
|
||||||
var mostRecentlyFailedChannel string // TODO: fix this hack!
|
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
|
var videos []Video
|
||||||
if quickSync && maxVideos > 50 {
|
if quickSync && maxVideos > 50 {
|
||||||
|
@ -70,6 +70,14 @@ func GetVideosToSync(config *sdk.APIConfig, channelID string, syncedVideos map[s
|
||||||
for i, videoID := range videoIDs {
|
for i, videoID := range videoIDs {
|
||||||
playlistMap[videoID] = int64(i)
|
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 len(videoIDs) < 1 {
|
||||||
if channelID == mostRecentlyFailedChannel {
|
if channelID == mostRecentlyFailedChannel {
|
||||||
|
|
Loading…
Reference in a new issue