Compare commits
3 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dd54e8cc49 | |||
| 9f32aedc3b | |||
| c52290392d |
3 changed files with 42 additions and 18 deletions
16
README.md
16
README.md
|
|
@ -14,8 +14,13 @@ I built this to greatly simplify the process of getting my full-quality livestre
|
||||||
$ vodular
|
$ vodular
|
||||||
New config file created (config.toml). Please edit this file before running again!
|
New config file created (config.toml). Please edit this file before running again!
|
||||||
```
|
```
|
||||||
|
The directory which holds your configuration file and templates varies,
|
||||||
|
depending on platform:
|
||||||
|
- **Linux:** `~/.config/vodular/templates`
|
||||||
|
- **macOS:** `~/Library/Application Support/vodular/templates`
|
||||||
|
- **Windows:** `%AppData%/vodular/templates`
|
||||||
|
|
||||||
2. Edit configuration file as necessary (You will need to create a [YouTube Data API v3](https://developers.google.com/youtube/v3) service and provide its credentials here).
|
2. Edit your configuration file as necessary (You will need to create a [YouTube Data API v3](https://developers.google.com/youtube/v3) service and provide its credentials here).
|
||||||
**IMPORTANT:** `config.toml` contains very sensitive credentials. Do not share this file with anyone.
|
**IMPORTANT:** `config.toml` contains very sensitive credentials. Do not share this file with anyone.
|
||||||
|
|
||||||
3. Initialise a VOD directory:
|
3. Initialise a VOD directory:
|
||||||
|
|
@ -63,10 +68,11 @@ url = 'https://example.org'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Templates
|
## Templates
|
||||||
Template files can be created at `templates/title.txt`,
|
There are three template files, `title.txt`, `description.txt`, and `tags.txt`,
|
||||||
`template/description.txt`, and `templates/tags.txt` respectively. These
|
which can be created in `/path/to/vodular/templates`. These templates can be
|
||||||
files can use Go's [text template format](https://pkg.go.dev/text/template) to
|
created and tweaked to customise your VOD metadata on upload. They are enhanced
|
||||||
customise VOD metadata on upload.
|
with Go's [template format](https://pkg.go.dev/text/template) to inject
|
||||||
|
information provided in `metadata.toml`, and other neat functionality!
|
||||||
|
|
||||||
You can use the following data in templates:
|
You can use the following data in templates:
|
||||||
- **`.Title`:** The title of the stream.
|
- **`.Title`:** The title of the stream.
|
||||||
|
|
|
||||||
33
main.go
33
main.go
|
|
@ -26,7 +26,9 @@ import (
|
||||||
//go:embed res/help.txt
|
//go:embed res/help.txt
|
||||||
var helpText string
|
var helpText string
|
||||||
|
|
||||||
const segmentExtension = "mkv"
|
const SEGMENT_EXTENSION = "mkv"
|
||||||
|
const MAX_TITLE_LEN = 100
|
||||||
|
const MAX_DESCRIPTION_LEN = 5000
|
||||||
|
|
||||||
func showHelp() {
|
func showHelp() {
|
||||||
fmt.Println(helpText)
|
fmt.Println(helpText)
|
||||||
|
|
@ -194,7 +196,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// scan for VOD segments
|
// scan for VOD segments
|
||||||
vodFiles, err := scanner.ScanSegments(metadata.FootageDir, segmentExtension)
|
vodFiles, err := scanner.ScanSegments(metadata.FootageDir, SEGMENT_EXTENSION)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to fetch VOD filenames: %v", err)
|
log.Fatalf("Failed to fetch VOD filenames: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
@ -202,7 +204,7 @@ func main() {
|
||||||
if len(vodFiles) == 0 {
|
if len(vodFiles) == 0 {
|
||||||
log.Fatalf(
|
log.Fatalf(
|
||||||
"Directory contained no VOD files (expecting .%s)",
|
"Directory contained no VOD files (expecting .%s)",
|
||||||
segmentExtension,
|
SEGMENT_EXTENSION,
|
||||||
)
|
)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
@ -221,11 +223,6 @@ func main() {
|
||||||
log.Fatalf("Failed to build video template: %v", err)
|
log.Fatalf("Failed to build video template: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if verbose {
|
|
||||||
enc := json.NewEncoder(os.Stdout)
|
|
||||||
fmt.Printf("\nVideo template: ")
|
|
||||||
enc.Encode(video)
|
|
||||||
|
|
||||||
title, err := yt.BuildTemplate(video, templates.Title)
|
title, err := yt.BuildTemplate(video, templates.Title)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to build video title: %v", err)
|
log.Fatalf("Failed to build video title: %v", err)
|
||||||
|
|
@ -236,6 +233,25 @@ func main() {
|
||||||
log.Fatalf("Failed to build video description: %v", err)
|
log.Fatalf("Failed to build video description: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
if len(title) > 100 {
|
||||||
|
log.Fatalf(
|
||||||
|
"Video title length exceeds %d characters (%d). YouTube may reject this!",
|
||||||
|
MAX_TITLE_LEN,
|
||||||
|
len(video.Title),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if len(description) > 5000 {
|
||||||
|
log.Fatalf(
|
||||||
|
"Video description length exceeds %d characters (%d). YouTube may reject this!",
|
||||||
|
MAX_DESCRIPTION_LEN,
|
||||||
|
len(description),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if verbose {
|
||||||
|
enc := json.NewEncoder(os.Stdout)
|
||||||
|
fmt.Printf("\nVideo template: ")
|
||||||
|
enc.Encode(video)
|
||||||
|
|
||||||
fmt.Printf(
|
fmt.Printf(
|
||||||
"\n================================\n\n" +
|
"\n================================\n\n" +
|
||||||
"< TITLE >\n%s\n\n" +
|
"< TITLE >\n%s\n\n" +
|
||||||
|
|
@ -317,6 +333,7 @@ func main() {
|
||||||
log.Print("Video uploaded successfully!")
|
log.Print("Video uploaded successfully!")
|
||||||
|
|
||||||
// update metadata to reflect VOD is uploaded
|
// update metadata to reflect VOD is uploaded
|
||||||
|
// TODO: rather than a boolean flag, link to actual video
|
||||||
metadata.Uploaded = true
|
metadata.Uploaded = true
|
||||||
err = scanner.WriteMetadata(directory, metadata)
|
err = scanner.WriteMetadata(directory, metadata)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ func ScanSegments(directory string, extension string) ([]string, error) {
|
||||||
|
|
||||||
for _, item := range entries {
|
for _, item := range entries {
|
||||||
if item.IsDir() { continue }
|
if item.IsDir() { continue }
|
||||||
|
if strings.HasPrefix(item.Name(), ".") { continue }
|
||||||
if !strings.HasSuffix(item.Name(), "." + extension) { continue }
|
if !strings.HasSuffix(item.Name(), "." + extension) { continue }
|
||||||
if strings.HasSuffix(item.Name(), "-fullvod." + extension) { continue }
|
if strings.HasSuffix(item.Name(), "-fullvod." + extension) { continue }
|
||||||
files = append(files, item.Name())
|
files = append(files, item.Name())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue