Fix download links when using custom port #43

This commit is contained in:
Maksym Pavlenko
2019-11-15 10:57:55 -08:00
parent 18fd306823
commit d09271096b
2 changed files with 15 additions and 3 deletions
+2 -2
View File
@@ -37,7 +37,7 @@ In order to query YouTube or Vimeo API you have to obtain an API token first.
[server]
port = 8080
data_dir = "/path/to/data/directory"
hostname = "http://hostname"
hostname = "hostname"
[tokens]
youtube = "{YOUTUBE_API_TOKEN}"
@@ -54,7 +54,7 @@ vimeo = "{VIMEO_API_TOKEN}"
Episodes files will be kept at: `/path/to/data/directory/ID1`
Feed will be accessible from: `http://hostname/ID1.xml`
Feed will be accessible from: `http://hostname:8080/ID1.xml`
## How to run
+13 -1
View File
@@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"time"
itunes "github.com/mxpv/podcast"
@@ -216,7 +217,18 @@ func (u *Updater) makeEnclosure(feed *model.Feed, episode *model.Episode, cfg *c
contentType = itunes.MP3
}
url := fmt.Sprintf("%s/%s/%s.%s", u.config.Server.Hostname, cfg.ID, episode.ID, ext)
// Make sure there is no http:// prefix
hostname := strings.TrimPrefix(u.config.Server.Hostname, "http://")
url := fmt.Sprintf(
"http://%s:%d/%s/%s.%s",
hostname,
u.config.Server.Port,
cfg.ID,
episode.ID,
ext,
)
return url, contentType, episode.Size
}