summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.json2
-rw-r--r--pkg/app/app.go17
-rw-r--r--pkg/media/video.go3
3 files changed, 20 insertions, 2 deletions
diff --git a/config.json b/config.json
index 76ba6cd..c0dff2b 100644
--- a/config.json
+++ b/config.json
@@ -5,7 +5,7 @@
"port": 0
},
"feed": {
- "external_url": "http://your-url.example",
+ "external_url": "",
"title": "Feed Title",
"link": "http://your-url.example/about",
"description": "Feed Description",
diff --git a/pkg/app/app.go b/pkg/app/app.go
index d13a888..e423359 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -1,12 +1,14 @@
package app
import (
+ "fmt"
"html/template"
"log"
"net"
"net/http"
"net/url"
"path"
+ "strconv"
"time"
"github.com/fsnotify/fsnotify"
@@ -179,8 +181,16 @@ func (a *App) rssHandler(w http.ResponseWriter, r *http.Request) {
Created: now,
Copyright: cfg.Copyright,
}
+ var externalURL string
+ if len(cfg.ExternalURL) > 0 {
+ externalURL = cfg.ExternalURL
+ } else {
+ host := a.Config.Server.Host
+ port := a.Config.Server.Port
+ externalURL = fmt.Sprintf("http://%s:%d", host, port)
+ }
for _, v := range a.Library.Playlist() {
- u, err := url.Parse(cfg.ExternalURL)
+ u, err := url.Parse(externalURL)
if err != nil {
return
}
@@ -191,6 +201,11 @@ func (a *App) rssHandler(w http.ResponseWriter, r *http.Request) {
Title: v.Title,
Link: &feeds.Link{Href: id},
Description: v.Description,
+ Enclosure: &feeds.Enclosure{
+ Url: id + ".mp4",
+ Length: strconv.FormatInt(v.Size, 10),
+ Type: "video/mp4",
+ },
Author: &feeds.Author{
Name: cfg.Author.Name,
Email: cfg.Author.Email,
diff --git a/pkg/media/video.go b/pkg/media/video.go
index 7fddbee..2499433 100644
--- a/pkg/media/video.go
+++ b/pkg/media/video.go
@@ -16,6 +16,7 @@ type Video struct {
Thumb []byte
ThumbType string
Modified string
+ Size int64
Timestamp time.Time
}
@@ -28,6 +29,7 @@ func ParseVideo(path string) (*Video, error) {
if err != nil {
return nil, err
}
+ size := info.Size()
timestamp := info.ModTime()
modified := timestamp.Format("2006-01-02 03:04 PM")
name := info.Name()
@@ -52,6 +54,7 @@ func ParseVideo(path string) (*Video, error) {
Album: m.Album(),
Description: m.Comment(),
Modified: modified,
+ Size: size,
Timestamp: timestamp,
}
// Add thumbnail (if exists)