added rss enclosures
This commit is contained in:
parent
0b87a1137f
commit
0979457d75
3 changed files with 20 additions and 2 deletions
|
@ -5,7 +5,7 @@
|
||||||
"port": 0
|
"port": 0
|
||||||
},
|
},
|
||||||
"feed": {
|
"feed": {
|
||||||
"external_url": "http://your-url.example",
|
"external_url": "",
|
||||||
"title": "Feed Title",
|
"title": "Feed Title",
|
||||||
"link": "http://your-url.example/about",
|
"link": "http://your-url.example/about",
|
||||||
"description": "Feed Description",
|
"description": "Feed Description",
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
|
@ -179,8 +181,16 @@ func (a *App) rssHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
Created: now,
|
Created: now,
|
||||||
Copyright: cfg.Copyright,
|
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() {
|
for _, v := range a.Library.Playlist() {
|
||||||
u, err := url.Parse(cfg.ExternalURL)
|
u, err := url.Parse(externalURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -191,6 +201,11 @@ func (a *App) rssHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
Title: v.Title,
|
Title: v.Title,
|
||||||
Link: &feeds.Link{Href: id},
|
Link: &feeds.Link{Href: id},
|
||||||
Description: v.Description,
|
Description: v.Description,
|
||||||
|
Enclosure: &feeds.Enclosure{
|
||||||
|
Url: id + ".mp4",
|
||||||
|
Length: strconv.FormatInt(v.Size, 10),
|
||||||
|
Type: "video/mp4",
|
||||||
|
},
|
||||||
Author: &feeds.Author{
|
Author: &feeds.Author{
|
||||||
Name: cfg.Author.Name,
|
Name: cfg.Author.Name,
|
||||||
Email: cfg.Author.Email,
|
Email: cfg.Author.Email,
|
||||||
|
|
|
@ -16,6 +16,7 @@ type Video struct {
|
||||||
Thumb []byte
|
Thumb []byte
|
||||||
ThumbType string
|
ThumbType string
|
||||||
Modified string
|
Modified string
|
||||||
|
Size int64
|
||||||
Timestamp time.Time
|
Timestamp time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +29,7 @@ func ParseVideo(path string) (*Video, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
size := info.Size()
|
||||||
timestamp := info.ModTime()
|
timestamp := info.ModTime()
|
||||||
modified := timestamp.Format("2006-01-02 03:04 PM")
|
modified := timestamp.Format("2006-01-02 03:04 PM")
|
||||||
name := info.Name()
|
name := info.Name()
|
||||||
|
@ -52,6 +54,7 @@ func ParseVideo(path string) (*Video, error) {
|
||||||
Album: m.Album(),
|
Album: m.Album(),
|
||||||
Description: m.Comment(),
|
Description: m.Comment(),
|
||||||
Modified: modified,
|
Modified: modified,
|
||||||
|
Size: size,
|
||||||
Timestamp: timestamp,
|
Timestamp: timestamp,
|
||||||
}
|
}
|
||||||
// Add thumbnail (if exists)
|
// Add thumbnail (if exists)
|
||||||
|
|
Loading…
Reference in a new issue