Make Invidious instance configurable
This commit is contained in:
parent
5879404fd2
commit
8329e9b46c
6 changed files with 26 additions and 4 deletions
|
@ -68,6 +68,7 @@ const (
|
||||||
defaultMetricsRefreshInterval = 60
|
defaultMetricsRefreshInterval = 60
|
||||||
defaultMetricsAllowedNetworks = "127.0.0.1/8"
|
defaultMetricsAllowedNetworks = "127.0.0.1/8"
|
||||||
defaultWatchdog = true
|
defaultWatchdog = true
|
||||||
|
defaultInvidiousInstance = "yewtu.be"
|
||||||
)
|
)
|
||||||
|
|
||||||
var defaultHTTPClientUserAgent = "Mozilla/5.0 (compatible; Miniflux/" + version.Version + "; +https://miniflux.app)"
|
var defaultHTTPClientUserAgent = "Mozilla/5.0 (compatible; Miniflux/" + version.Version + "; +https://miniflux.app)"
|
||||||
|
@ -135,6 +136,7 @@ type Options struct {
|
||||||
metricsRefreshInterval int
|
metricsRefreshInterval int
|
||||||
metricsAllowedNetworks []string
|
metricsAllowedNetworks []string
|
||||||
watchdog bool
|
watchdog bool
|
||||||
|
invidiousInstance string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOptions returns Options with default values.
|
// NewOptions returns Options with default values.
|
||||||
|
@ -193,6 +195,7 @@ func NewOptions() *Options {
|
||||||
metricsRefreshInterval: defaultMetricsRefreshInterval,
|
metricsRefreshInterval: defaultMetricsRefreshInterval,
|
||||||
metricsAllowedNetworks: []string{defaultMetricsAllowedNetworks},
|
metricsAllowedNetworks: []string{defaultMetricsAllowedNetworks},
|
||||||
watchdog: defaultWatchdog,
|
watchdog: defaultWatchdog,
|
||||||
|
invidiousInstance: defaultInvidiousInstance,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,6 +485,11 @@ func (o *Options) HasWatchdog() bool {
|
||||||
return o.watchdog
|
return o.watchdog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InvidiousInstance returns the invidious instance used by miniflux
|
||||||
|
func (o *Options) InvidiousInstance() string {
|
||||||
|
return o.invidiousInstance
|
||||||
|
}
|
||||||
|
|
||||||
// SortedOptions returns options as a list of key value pairs, sorted by keys.
|
// SortedOptions returns options as a list of key value pairs, sorted by keys.
|
||||||
func (o *Options) SortedOptions(redactSecret bool) []*Option {
|
func (o *Options) SortedOptions(redactSecret bool) []*Option {
|
||||||
var keyValues = map[string]interface{}{
|
var keyValues = map[string]interface{}{
|
||||||
|
@ -516,6 +524,7 @@ func (o *Options) SortedOptions(redactSecret bool) []*Option {
|
||||||
"HTTP_CLIENT_USER_AGENT": o.httpClientUserAgent,
|
"HTTP_CLIENT_USER_AGENT": o.httpClientUserAgent,
|
||||||
"HTTP_SERVICE": o.httpService,
|
"HTTP_SERVICE": o.httpService,
|
||||||
"KEY_FILE": o.certKeyFile,
|
"KEY_FILE": o.certKeyFile,
|
||||||
|
"INVIDIOUS_INSTANCE": o.invidiousInstance,
|
||||||
"LISTEN_ADDR": o.listenAddr,
|
"LISTEN_ADDR": o.listenAddr,
|
||||||
"LOG_DATE_TIME": o.logDateTime,
|
"LOG_DATE_TIME": o.logDateTime,
|
||||||
"MAINTENANCE_MESSAGE": o.maintenanceMessage,
|
"MAINTENANCE_MESSAGE": o.maintenanceMessage,
|
||||||
|
|
|
@ -195,6 +195,8 @@ func (p *Parser) parseLines(lines []string) (err error) {
|
||||||
p.opts.fetchYouTubeWatchTime = parseBool(value, defaultFetchYouTubeWatchTime)
|
p.opts.fetchYouTubeWatchTime = parseBool(value, defaultFetchYouTubeWatchTime)
|
||||||
case "WATCHDOG":
|
case "WATCHDOG":
|
||||||
p.opts.watchdog = parseBool(value, defaultWatchdog)
|
p.opts.watchdog = parseBool(value, defaultWatchdog)
|
||||||
|
case "INVIDIOUS_INSTANCE":
|
||||||
|
p.opts.invidiousInstance = parseString(value, defaultInvidiousInstance)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.\" Manpage for miniflux.
|
.\" Manpage for miniflux.
|
||||||
.TH "MINIFLUX" "1" "May 23, 2021" "\ \&" "\ \&"
|
.TH "MINIFLUX" "1" "January 5, 2022" "\ \&" "\ \&"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
miniflux \- Minimalist and opinionated feed reader
|
miniflux \- Minimalist and opinionated feed reader
|
||||||
|
@ -416,6 +416,11 @@ Default is "Miniflux is currently under maintenance"\&.
|
||||||
Enable or disable Systemd watchdog\&.
|
Enable or disable Systemd watchdog\&.
|
||||||
.br
|
.br
|
||||||
Enabled by default\&.
|
Enabled by default\&.
|
||||||
|
.TP
|
||||||
|
.B INVIDIOUS_INSTANCE
|
||||||
|
Set a custom invidious instance to use\&.
|
||||||
|
.br
|
||||||
|
Default is yewtu.be\&.
|
||||||
|
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
.P
|
.P
|
||||||
|
|
|
@ -11,6 +11,8 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"miniflux.app/config"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -214,7 +216,7 @@ func addYoutubeVideoUsingInvidiousPlayer(entryURL, entryContent string) string {
|
||||||
matches := youtubeRegex.FindStringSubmatch(entryURL)
|
matches := youtubeRegex.FindStringSubmatch(entryURL)
|
||||||
|
|
||||||
if len(matches) == 2 {
|
if len(matches) == 2 {
|
||||||
video := `<iframe width="650" height="350" frameborder="0" src="https://invidio.us/embed/` + matches[1] + `" allowfullscreen></iframe>`
|
video := `<iframe width="650" height="350" frameborder="0" src="https://` + config.Opts.InvidiousInstance() + `/embed/` + matches[1] + `" allowfullscreen></iframe>`
|
||||||
return video + `<br>` + entryContent
|
return video + `<br>` + entryContent
|
||||||
}
|
}
|
||||||
return entryContent
|
return entryContent
|
||||||
|
|
|
@ -16,7 +16,6 @@ var predefinedRules = map[string]string{
|
||||||
"framatube.org": "nl2br,convert_text_link",
|
"framatube.org": "nl2br,convert_text_link",
|
||||||
"happletea.com": "add_image_title",
|
"happletea.com": "add_image_title",
|
||||||
"imogenquest.net": "add_image_title",
|
"imogenquest.net": "add_image_title",
|
||||||
"invidio.us": "add_invidious_video",
|
|
||||||
"lukesurl.com": "add_image_title",
|
"lukesurl.com": "add_image_title",
|
||||||
"medium.com": "fix_medium_images",
|
"medium.com": "fix_medium_images",
|
||||||
"mercworks.net": "add_image_title",
|
"mercworks.net": "add_image_title",
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"miniflux.app/config"
|
||||||
"miniflux.app/url"
|
"miniflux.app/url"
|
||||||
|
|
||||||
"golang.org/x/net/html"
|
"golang.org/x/net/html"
|
||||||
|
@ -308,7 +309,6 @@ func isBlockedResource(src string) bool {
|
||||||
|
|
||||||
func isValidIframeSource(baseURL, src string) bool {
|
func isValidIframeSource(baseURL, src string) bool {
|
||||||
whitelist := []string{
|
whitelist := []string{
|
||||||
"https://invidio.us",
|
|
||||||
"//www.youtube.com",
|
"//www.youtube.com",
|
||||||
"http://www.youtube.com",
|
"http://www.youtube.com",
|
||||||
"https://www.youtube.com",
|
"https://www.youtube.com",
|
||||||
|
@ -334,6 +334,11 @@ func isValidIframeSource(baseURL, src string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// allow iframe from custom invidious instance
|
||||||
|
if config.Opts != nil && config.Opts.InvidiousInstance() == url.Domain(src) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
for _, prefix := range whitelist {
|
for _, prefix := range whitelist {
|
||||||
if strings.HasPrefix(src, prefix) {
|
if strings.HasPrefix(src, prefix) {
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in a new issue