require channel name, read channel ids from file
This commit is contained in:
parent
70c6ee7ddb
commit
d3109e1016
3 changed files with 36 additions and 13 deletions
|
@ -3,8 +3,7 @@
|
|||
- make sure you don't have a `.lbryum/wallets/default_wallet`
|
||||
- delete existing wallet if there's nothing you need there, or better yet, move it somewhere else in case you need it later
|
||||
- make sure daemon is stopped and can be controlled with `systemctl`
|
||||
- run `lbry ytsync YOUTUBE_KEY YOUTUBE_CHANNEL_ID LBRY_CHANNEL_NAME --max-tries=5`
|
||||
- `max-tries` will retry errors that you will probably get (e.g. failed publishes)
|
||||
- run `lbry ytsync YOUTUBE_KEY LBRY_CHANNEL_NAME YOUTUBE_CHANNEL_ID`
|
||||
- after sync is complete, daemon will be stopped and wallet will be moved to `~/wallets/`
|
||||
- now mark content as synced in doc
|
||||
|
||||
|
|
17
setup.go
17
setup.go
|
@ -28,12 +28,9 @@ func (s *Sync) walletSetup() error {
|
|||
}
|
||||
log.Debugf("Source channel has %d videos", numOnSource)
|
||||
|
||||
numPublished := uint64(0)
|
||||
if s.LbryChannelName != "" {
|
||||
numPublished, err = s.daemon.NumClaimsInChannel(s.LbryChannelName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
numPublished, err := s.daemon.NumClaimsInChannel(s.LbryChannelName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Debugf("We already published %d videos", numPublished)
|
||||
|
||||
|
@ -88,11 +85,9 @@ func (s *Sync) walletSetup() error {
|
|||
return err
|
||||
}
|
||||
|
||||
if s.LbryChannelName != "" {
|
||||
err = s.ensureChannelOwnership()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = s.ensureChannelOwnership()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
balanceResp, err = s.daemon.WalletBalance()
|
||||
|
|
29
ytsync.go
29
ytsync.go
|
@ -1,6 +1,7 @@
|
|||
package ytsync
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
|
@ -69,6 +70,14 @@ func (s *Sync) FullCycle() error {
|
|||
return errors.New("no $HOME env var found")
|
||||
}
|
||||
|
||||
if s.YoutubeChannelID == "" {
|
||||
channelID, err := getChannelIDFromFile(s.LbryChannelName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.YoutubeChannelID = channelID
|
||||
}
|
||||
|
||||
defaultWalletDir := os.Getenv("HOME") + "/.lbryum/wallets/default_wallet"
|
||||
walletBackupDir := os.Getenv("HOME") + "/wallets/" + strings.Replace(s.LbryChannelName, "@", "", 1)
|
||||
|
||||
|
@ -341,3 +350,23 @@ func stopDaemonViaSystemd() error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getChannelIDFromFile(channelName string) (string, error) {
|
||||
channelsJSON, err := ioutil.ReadFile("./channels")
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, 0)
|
||||
}
|
||||
|
||||
var channels map[string]string
|
||||
err = json.Unmarshal(channelsJSON, &channels)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, 0)
|
||||
}
|
||||
|
||||
channelID, ok := channels[channelName]
|
||||
if !ok {
|
||||
return "", errors.New("channel not in list")
|
||||
}
|
||||
|
||||
return channelID, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue