This repository has been archived by the owner on Jul 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Video Import Command Co-authored-by: Dirk Kelly <github@dirkkelly.com>
- Loading branch information
Showing
6 changed files
with
202 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// importRootCmd represents the importRoot command | ||
var importRootCmd = &cobra.Command{ | ||
Use: "import", | ||
Short: "Import resources, currently works with video", | ||
Long: `Command to import resources. Not to be confused with the channel import command. | ||
Currently the only valid resource for import is the video resource. However, | ||
this command will later form the basis for importing all resources.`, | ||
ValidArgs: []string{"video"}, | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(importRootCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package cmd | ||
|
||
import ( | ||
"log" | ||
"os" | ||
|
||
"github.com/breadtubetv/bake/providers" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
// videoCmd represents the video command | ||
var videoCmd = &cobra.Command{ | ||
Use: "video", | ||
Short: "Import a video by ID", | ||
Long: `Import a YouTube video by ID and assign it to a creator.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := providers.ImportVideo(id, creator, os.ExpandEnv(viper.GetString("projectRoot"))) | ||
if err != nil { | ||
log.Fatalf("could not import video: %v", err) | ||
} | ||
}, | ||
} | ||
|
||
var ( | ||
id string | ||
creator string | ||
provider string | ||
) | ||
|
||
func init() { | ||
importRootCmd.AddCommand(videoCmd) | ||
|
||
videoCmd.Flags().StringVar(&id, "id", "", "ID of the video, e.g. xspEtjnSfQA is the ID for https://www.youtube.com/watch?v=xspEtjnSfQA") | ||
videoCmd.Flags().StringVarP(&creator, "creator", "c", "", "Creator slug for the imported video") | ||
videoCmd.Flags().StringVarP(&provider, "provider", "p", "", "Video provider to import from - e.g. youtube") | ||
|
||
videoCmd.MarkFlagRequired("id") | ||
videoCmd.MarkFlagRequired("creator") | ||
videoCmd.MarkFlagRequired("provider") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters