Add option to not wait for reflection. Add instructions for getting a YouTube API key. Fix some minor issues.
This commit is contained in:
parent
9f6b15e841
commit
ce901f6b01
3 changed files with 46 additions and 18 deletions
|
@ -19,6 +19,7 @@ import (
|
|||
type SyncContext struct {
|
||||
DryRun bool
|
||||
KeepCache bool
|
||||
ReflectStreams bool
|
||||
TempDir string
|
||||
LbrynetAddr string
|
||||
ChannelID string
|
||||
|
@ -57,6 +58,7 @@ func AddCommand(rootCmd *cobra.Command) {
|
|||
}
|
||||
cmd.Flags().BoolVar(&syncContext.DryRun, "dry-run", false, "Display information about the stream publishing, but do not publish the stream")
|
||||
cmd.Flags().BoolVar(&syncContext.KeepCache, "keep-cache", false, "Don't delete local files after publishing.")
|
||||
cmd.Flags().BoolVar(&syncContext.ReflectStreams, "reflect-streams", true, "Require published streams to be reflected.")
|
||||
cmd.Flags().StringVar(&syncContext.TempDir, "temp-dir", getEnvDefault("TEMP_DIR", ""), "directory to use for temporary files")
|
||||
cmd.Flags().Float64Var(&syncContext.PublishBid, "publish-bid", 0.01, "Bid amount for the stream claim")
|
||||
cmd.Flags().StringVar(&syncContext.LbrynetAddr, "lbrynet-address", getEnvDefault("LBRYNET_ADDRESS", ""), "JSONRPC address of the local LBRYNet daemon")
|
||||
|
@ -119,16 +121,20 @@ func localCmd(cmd *cobra.Command, args []string) {
|
|||
log.Debugf("Object to be published: %v", processedVideo)
|
||||
|
||||
} else {
|
||||
done, err := publisher.Publish(*processedVideo)
|
||||
doneReflectingCh, err := publisher.Publish(*processedVideo, syncContext.ReflectStreams)
|
||||
if err != nil {
|
||||
log.Errorf("Error publishing video: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = <-done
|
||||
if syncContext.ReflectStreams {
|
||||
err = <-doneReflectingCh
|
||||
if err != nil {
|
||||
log.Errorf("Error while wating for stream to reflect: %v", err)
|
||||
}
|
||||
} else {
|
||||
log.Debugln("Not waiting for stream to reflect.")
|
||||
}
|
||||
}
|
||||
|
||||
if !syncContext.KeepCache {
|
||||
|
@ -227,13 +233,14 @@ func getAbbrevDescription(v SourceVideo) string {
|
|||
return v.SourceURL
|
||||
}
|
||||
|
||||
maxLength := 2800
|
||||
additionalDescription := "\n...\n" + v.SourceURL
|
||||
maxLength := 2800 - len(additionalDescription)
|
||||
|
||||
description := strings.TrimSpace(*v.Description)
|
||||
additionalDescription := "\n" + v.SourceURL
|
||||
if len(description) > maxLength {
|
||||
description = description[:maxLength]
|
||||
}
|
||||
return description + "\n..." + additionalDescription
|
||||
return description + additionalDescription
|
||||
}
|
||||
|
||||
type VideoSource interface {
|
||||
|
@ -242,5 +249,5 @@ type VideoSource interface {
|
|||
}
|
||||
|
||||
type VideoPublisher interface {
|
||||
Publish(video PublishableVideo) (chan error, error)
|
||||
Publish(video PublishableVideo, reflectStream bool) (chan error, error)
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ func NewLocalSDKPublisher(sdkAddr, channelID string, publishBid float64) (*Local
|
|||
return &publisher, nil
|
||||
}
|
||||
|
||||
func (p *LocalSDKPublisher) Publish(video PublishableVideo) (chan error, error) {
|
||||
func (p *LocalSDKPublisher) Publish(video PublishableVideo, reflectStream bool) (chan error, error) {
|
||||
streamCreateOptions := jsonrpc.StreamCreateOptions {
|
||||
ClaimCreateOptions: jsonrpc.ClaimCreateOptions {
|
||||
Title: &video.Title,
|
||||
|
@ -67,6 +67,10 @@ func (p *LocalSDKPublisher) Publish(video PublishableVideo) (chan error, error)
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if !reflectStream {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
done := make(chan error, 1)
|
||||
go func() {
|
||||
for {
|
||||
|
@ -88,8 +92,9 @@ func (p *LocalSDKPublisher) Publish(video PublishableVideo) (chan error, error)
|
|||
break
|
||||
}
|
||||
if !fileStatus.UploadingToReflector {
|
||||
log.Warn("Stream is not being uploaded to a reflector. Check your lbrynet settings if this is a mistake.")
|
||||
break
|
||||
log.Error("Stream is not being uploaded to a reflector. Check your lbrynet settings if this is a mistake.")
|
||||
done <- errors.New("Stream is not being reflected (check lbrynet settings).")
|
||||
return
|
||||
}
|
||||
log.Infof("Stream reflector progress: %d%%", fileStatus.ReflectorProgress)
|
||||
time.Sleep(5 * time.Second)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
- LBRY SDK (what do we actually need this for?)
|
||||
- youtube-dl
|
||||
- enough space to cache stuff
|
||||
- YouTube data API key
|
||||
|
||||
|
||||
## Process
|
||||
|
@ -15,6 +16,21 @@
|
|||
- or easier, just error if no channel
|
||||
- enough lbc in wallet?
|
||||
|
||||
### Getting a YouTube API key
|
||||
|
||||
To access the YouTube data API, you will first need some kind of google account.
|
||||
|
||||
The API has two methods of authentication, OAuth2 and API keys. This application uses API keys.
|
||||
These API keys are basically like passwords, and so once obtained, they should not be shared.
|
||||
|
||||
The instructions for obtaining an API key are copied below from [here](https://developers.google.com/youtube/registering_an_application):
|
||||
|
||||
|
||||
1. Open the [Credentials page](https://console.developers.google.com/apis/credentials) in the API Console.
|
||||
2. Create an API key in the Console by clicking **Create credentials > API key**. You can restrict the key before using it in production by clicking **Restrict key** and selecting one of the **Restrictions**.
|
||||
|
||||
To keep your API keys secure, follow the [best practices for securely using API keys](https://cloud.google.com/docs/authentication/api-keys).
|
||||
|
||||
### Options to figure out what's already synced
|
||||
|
||||
- simplest: assume nothing is synced yet
|
||||
|
|
Loading…
Reference in a new issue