diff options
| author | James Mills <prologic@shortcircuit.net.au> | 2020-03-21 09:55:06 +1000 |
|---|---|---|
| committer | James Mills <prologic@shortcircuit.net.au> | 2020-03-21 09:55:06 +1000 |
| commit | 4dae45a68ff1ff32a251a5835b2a2723ae125d1c (patch) | |
| tree | b3abe641f39f50ac444aee2bb617d7b4ab44187d /pkg/app/feed.go | |
| parent | 76fa613b7eaf1c8626d2a51901c623af7bf1a665 (diff) | |
Restructured source code layout, Added rice support for templates and static assets
Diffstat (limited to 'pkg/app/feed.go')
| -rw-r--r-- | pkg/app/feed.go | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/pkg/app/feed.go b/pkg/app/feed.go deleted file mode 100644 index e4c1ce2..0000000 --- a/pkg/app/feed.go +++ /dev/null @@ -1,77 +0,0 @@ -package app - -import ( - "fmt" - "net/url" - "os" - "path" - "strconv" - "time" - - "github.com/wybiral/feeds" -) - -// buildFeed creates RSS feed attribute for App based on Library contents. -func buildFeed(a *App) { - cfg := a.Config.Feed - now := time.Now() - f := &feeds.Feed{ - Title: cfg.Title, - Link: &feeds.Link{Href: cfg.Link}, - Description: cfg.Description, - Author: &feeds.Author{ - Name: cfg.Author.Name, - Email: cfg.Author.Email, - }, - Created: now, - Copyright: cfg.Copyright, - } - var externalURL string - if len(cfg.ExternalURL) > 0 { - externalURL = cfg.ExternalURL - } else if a.Tor != nil { - onion, err := a.Tor.OnionKey.Onion() - if err != nil { - return - } - externalURL = fmt.Sprintf("http://%s.onion", onion.ServiceID) - } else { - hostname, err := os.Hostname() - if err != nil { - host := a.Config.Server.Host - port := a.Config.Server.Port - externalURL = fmt.Sprintf("http://%s:%d", host, port) - } else { - externalURL = fmt.Sprintf("http://%s", hostname) - } - } - for _, v := range a.Library.Playlist() { - u, err := url.Parse(externalURL) - if err != nil { - return - } - u.Path = path.Join(u.Path, "v", v.ID) - id := u.String() - f.Items = append(f.Items, &feeds.Item{ - Id: id, - 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, - }, - Created: v.Timestamp, - }) - } - feed, err := f.ToRss() - if err != nil { - return - } - a.Feed = []byte(feed) -} |
