rearrange a bit

This commit is contained in:
Alex Grintsvayg 2017-09-22 09:24:43 -04:00
parent 09cafcba40
commit 6adb38d23f
No known key found for this signature in database
GPG key ID: AEB3F089F86A22B5
5 changed files with 33 additions and 14 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
/.idea
/bin

View file

@ -299,3 +299,12 @@ func (d *Client) Publish(name, filePath string, bid float64, options PublishOpti
"change_address": options.ChangeAddress,
})
}
func (d *Client) BlobAnnounce(blobHash, sdHash, streamHash *string) (*BlobAnnounceResponse, error) {
response := new(BlobAnnounceResponse)
return response, d.call(response, "blob_announce", map[string]interface{}{
"blob_hash": blobHash,
"stream_hash": streamHash,
"sd_hash": sdHash,
})
}

View file

@ -263,4 +263,7 @@ type ChannelListMineResponse []struct {
type WalletListResponse []string
type PublishResponse struct {
// TODO
}
type BlobAnnounceResponse bool

16
main.go
View file

@ -1,16 +1,24 @@
package main
import (
"os"
log "github.com/sirupsen/logrus"
)
func main() {
log.SetLevel(log.DebugLevel)
//franklin()
if len(os.Args) < 2 {
log.Errorln("Usage: " + os.Args[0] + " COMMAND [options]")
}
err := ytsync()
if err != nil {
panic(err)
switch os.Args[1] {
case "ytsync":
ytsync()
case "franklin":
franklin()
default:
log.Errorln("Unknown command: " + os.Args[1])
}
}

View file

@ -50,9 +50,8 @@ var (
redisPool *redis.Pool
)
func ytsync() error {
func ytsync() {
var err error
flag.StringVar(&ytAPIKey, "ytApiKey", "", "Youtube API key (required)")
flag.StringVar(&channelID, "channelID", "", "ID of the youtube channel to sync (required)")
flag.StringVar(&lbryChannelName, "lbryChannel", "", "Publish videos into this channel")
@ -60,7 +59,7 @@ func ytsync() error {
if channelID == "" || ytAPIKey == "" {
flag.Usage()
return nil
return
}
redisPool = &redis.Pool{
@ -82,25 +81,25 @@ func ytsync() error {
daemon = jsonrpc.NewClient("")
videoDirectory, err = ioutil.TempDir("", "ytsync")
if err != nil {
return err
panic(err)
}
if lbryChannelName != "" {
err = ensureChannelOwnership()
if err != nil {
return err
panic(err)
}
}
addresses, err := daemon.WalletList()
if err != nil {
return err
panic(err)
} else if addresses == nil || len(*addresses) == 0 {
return fmt.Errorf("Could not find an address in wallet")
panic(fmt.Errorf("Could not find an address in wallet"))
}
claimAddress = (*addresses)[0]
if claimAddress == "" {
return fmt.Errorf("Found blank claim address")
panic(fmt.Errorf("Found blank claim address"))
}
for i := 0; i < concurrentVideos; i++ {
@ -123,12 +122,11 @@ func ytsync() error {
err = enqueueVideosFromChannel(channelID, &videoQueue)
if err != nil {
return err
panic(err)
}
close(videoQueue)
wg.Wait()
return nil
}
func ensureChannelOwnership() error {