mirror of
https://github.com/miniflux/v2.git
synced 2025-08-31 18:31:01 +00:00
Make Invidious instance configurable
This commit is contained in:
parent
5879404fd2
commit
8329e9b46c
6 changed files with 26 additions and 4 deletions
|
@ -11,6 +11,8 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"miniflux.app/config"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
)
|
||||
|
||||
|
@ -214,7 +216,7 @@ func addYoutubeVideoUsingInvidiousPlayer(entryURL, entryContent string) string {
|
|||
matches := youtubeRegex.FindStringSubmatch(entryURL)
|
||||
|
||||
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 entryContent
|
||||
|
|
|
@ -16,7 +16,6 @@ var predefinedRules = map[string]string{
|
|||
"framatube.org": "nl2br,convert_text_link",
|
||||
"happletea.com": "add_image_title",
|
||||
"imogenquest.net": "add_image_title",
|
||||
"invidio.us": "add_invidious_video",
|
||||
"lukesurl.com": "add_image_title",
|
||||
"medium.com": "fix_medium_images",
|
||||
"mercworks.net": "add_image_title",
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"miniflux.app/config"
|
||||
"miniflux.app/url"
|
||||
|
||||
"golang.org/x/net/html"
|
||||
|
@ -308,7 +309,6 @@ func isBlockedResource(src string) bool {
|
|||
|
||||
func isValidIframeSource(baseURL, src string) bool {
|
||||
whitelist := []string{
|
||||
"https://invidio.us",
|
||||
"//www.youtube.com",
|
||||
"http://www.youtube.com",
|
||||
"https://www.youtube.com",
|
||||
|
@ -334,6 +334,11 @@ func isValidIframeSource(baseURL, src string) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// allow iframe from custom invidious instance
|
||||
if config.Opts != nil && config.Opts.InvidiousInstance() == url.Domain(src) {
|
||||
return true
|
||||
}
|
||||
|
||||
for _, prefix := range whitelist {
|
||||
if strings.HasPrefix(src, prefix) {
|
||||
return true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue