refactor tags_mapping name
remove failure state for transfers
This commit is contained in:
parent
291a105269
commit
77d0efcf3c
7 changed files with 16 additions and 18 deletions
|
@ -1,4 +1,4 @@
|
||||||
package ipManager
|
package ip_manager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/asaskevich/govalidator"
|
"github.com/asaskevich/govalidator"
|
|
@ -92,7 +92,6 @@ const (
|
||||||
TransferStateNotTouched = iota
|
TransferStateNotTouched = iota
|
||||||
TransferStatePending
|
TransferStatePending
|
||||||
TransferStateComplete
|
TransferStateComplete
|
||||||
TransferStateFailed = -1
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *SyncManager) Start() error {
|
func (s *SyncManager) Start() error {
|
||||||
|
|
|
@ -10,10 +10,11 @@ import (
|
||||||
"github.com/lbryio/lbry.go/v2/extras/errors"
|
"github.com/lbryio/lbry.go/v2/extras/errors"
|
||||||
"github.com/lbryio/lbry.go/v2/extras/jsonrpc"
|
"github.com/lbryio/lbry.go/v2/extras/jsonrpc"
|
||||||
"github.com/lbryio/lbry.go/v2/extras/util"
|
"github.com/lbryio/lbry.go/v2/extras/util"
|
||||||
"github.com/lbryio/ytsync/tagsManager"
|
|
||||||
"github.com/lbryio/ytsync/thumbs"
|
|
||||||
logUtils "github.com/lbryio/ytsync/util"
|
logUtils "github.com/lbryio/ytsync/util"
|
||||||
|
|
||||||
|
"github.com/lbryio/ytsync/tags_manager"
|
||||||
|
"github.com/lbryio/ytsync/thumbs"
|
||||||
|
|
||||||
"github.com/shopspring/decimal"
|
"github.com/shopspring/decimal"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"google.golang.org/api/googleapi/transport"
|
"google.golang.org/api/googleapi/transport"
|
||||||
|
@ -386,7 +387,7 @@ func (s *Sync) ensureChannelOwnership() error {
|
||||||
claimCreateOptions := jsonrpc.ClaimCreateOptions{
|
claimCreateOptions := jsonrpc.ClaimCreateOptions{
|
||||||
Title: &channelInfo.Title,
|
Title: &channelInfo.Title,
|
||||||
Description: &channelInfo.Description,
|
Description: &channelInfo.Description,
|
||||||
Tags: tagsManager.GetTagsForChannel(s.YoutubeChannelID),
|
Tags: tags_manager.GetTagsForChannel(s.YoutubeChannelID),
|
||||||
Languages: languages,
|
Languages: languages,
|
||||||
Locations: locations,
|
Locations: locations,
|
||||||
ThumbnailURL: &thumbnailURL,
|
ThumbnailURL: &thumbnailURL,
|
||||||
|
|
|
@ -384,9 +384,7 @@ func (s *Sync) setChannelTerminationStatus(e *error) {
|
||||||
var transferState *int
|
var transferState *int
|
||||||
|
|
||||||
if s.shouldTransfer() {
|
if s.shouldTransfer() {
|
||||||
if *e != nil {
|
if *e == nil {
|
||||||
transferState = util.PtrToInt(TransferStateFailed)
|
|
||||||
} else {
|
|
||||||
transferState = util.PtrToInt(TransferStateComplete)
|
transferState = util.PtrToInt(TransferStateComplete)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,10 @@ import (
|
||||||
"github.com/lbryio/lbry.go/v2/extras/stop"
|
"github.com/lbryio/lbry.go/v2/extras/stop"
|
||||||
"github.com/lbryio/lbry.go/v2/extras/util"
|
"github.com/lbryio/lbry.go/v2/extras/util"
|
||||||
|
|
||||||
"github.com/lbryio/ytsync/ipManager"
|
"github.com/lbryio/ytsync/ip_manager"
|
||||||
"github.com/lbryio/ytsync/namer"
|
"github.com/lbryio/ytsync/namer"
|
||||||
"github.com/lbryio/ytsync/sdk"
|
"github.com/lbryio/ytsync/sdk"
|
||||||
"github.com/lbryio/ytsync/tagsManager"
|
"github.com/lbryio/ytsync/tags_manager"
|
||||||
"github.com/lbryio/ytsync/thumbs"
|
"github.com/lbryio/ytsync/thumbs"
|
||||||
|
|
||||||
duration "github.com/ChannelMeter/iso8601duration"
|
duration "github.com/ChannelMeter/iso8601duration"
|
||||||
|
@ -220,7 +220,7 @@ func (v *YoutubeVideo) download(useIPv6 bool) error {
|
||||||
fmt.Sprintf("duration <= %d", int(math.Round(v.maxVideoLength*3600))),
|
fmt.Sprintf("duration <= %d", int(math.Round(v.maxVideoLength*3600))),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
sourceAddress, err := ipManager.GetNextIP(useIPv6)
|
sourceAddress, err := ip_manager.GetNextIP(useIPv6)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if sourceAddress == "throttled" {
|
if sourceAddress == "throttled" {
|
||||||
for {
|
for {
|
||||||
|
@ -230,8 +230,8 @@ func (v *YoutubeVideo) download(useIPv6 bool) error {
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(ipManager.IPCooldownPeriod)
|
time.Sleep(ip_manager.IPCooldownPeriod)
|
||||||
sourceAddress, err = ipManager.GetNextIP(useIPv6)
|
sourceAddress, err = ip_manager.GetNextIP(useIPv6)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ func (v *YoutubeVideo) download(useIPv6 bool) error {
|
||||||
return errors.Err(err)
|
return errors.Err(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defer ipManager.ReleaseIP(sourceAddress)
|
defer ip_manager.ReleaseIP(sourceAddress)
|
||||||
if useIPv6 {
|
if useIPv6 {
|
||||||
log.Infof("using IPv6: %s", sourceAddress)
|
log.Infof("using IPv6: %s", sourceAddress)
|
||||||
ytdlArgs = append(ytdlArgs,
|
ytdlArgs = append(ytdlArgs,
|
||||||
|
@ -282,7 +282,7 @@ runcmd:
|
||||||
if err = cmd.Wait(); err != nil {
|
if err = cmd.Wait(); err != nil {
|
||||||
if strings.Contains(err.Error(), "exit status 1") {
|
if strings.Contains(err.Error(), "exit status 1") {
|
||||||
if strings.Contains(string(errorLog), "HTTP Error 429") {
|
if strings.Contains(string(errorLog), "HTTP Error 429") {
|
||||||
ipManager.SetIpThrottled(sourceAddress, v.stopGroup)
|
ip_manager.SetIpThrottled(sourceAddress, v.stopGroup)
|
||||||
} else if strings.Contains(string(errorLog), "giving up after 0 fragment retries") && qualityIndex < len(qualities)-1 {
|
} else if strings.Contains(string(errorLog), "giving up after 0 fragment retries") && qualityIndex < len(qualities)-1 {
|
||||||
qualityIndex++
|
qualityIndex++
|
||||||
goto runcmd
|
goto runcmd
|
||||||
|
@ -477,7 +477,7 @@ func (v *YoutubeVideo) getMetadata() (languages []string, locations []jsonrpc.Lo
|
||||||
}
|
}
|
||||||
tags = v.youtubeInfo.Snippet.Tags
|
tags = v.youtubeInfo.Snippet.Tags
|
||||||
}
|
}
|
||||||
tags, err := tagsManager.SanitizeTags(tags, v.youtubeChannelID)
|
tags, err := tags_manager.SanitizeTags(tags, v.youtubeChannelID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln(err.Error())
|
log.Errorln(err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package tagsManager
|
package tags_manager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
|
@ -1,4 +1,4 @@
|
||||||
package tagsManager
|
package tags_manager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
Loading…
Reference in a new issue