mirror of
https://github.com/miniflux/v2.git
synced 2025-07-27 17:28:38 +00:00
feat: support for custom youtube embed URL
This commit is contained in:
parent
f286c3c1c9
commit
9b42d0e25e
8 changed files with 109 additions and 11 deletions
|
@ -4,10 +4,12 @@
|
|||
package rewrite // import "miniflux.app/reader/rewrite"
|
||||
|
||||
import (
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"miniflux.app/config"
|
||||
"miniflux.app/model"
|
||||
)
|
||||
|
||||
|
@ -63,6 +65,8 @@ func TestRewriteWithNoMatchingRule(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRewriteWithYoutubeLink(t *testing.T) {
|
||||
config.Opts = config.NewOptions()
|
||||
|
||||
controlEntry := &model.Entry{
|
||||
Title: `A title`,
|
||||
Content: `<iframe width="650" height="350" frameborder="0" src="https://www.youtube-nocookie.com/embed/1234" allowfullscreen></iframe><br>Video Description`,
|
||||
|
@ -78,6 +82,33 @@ func TestRewriteWithYoutubeLink(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRewriteWithYoutubeLinkAndCustomEmbedURL(t *testing.T) {
|
||||
os.Clearenv()
|
||||
os.Setenv("YOUTUBE_EMBED_URL_OVERRIDE", "https://invidious.custom/embed/")
|
||||
|
||||
var err error
|
||||
parser := config.NewParser()
|
||||
config.Opts, err = parser.ParseEnvironmentVariables()
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf(`Parsing failure: %v`, err)
|
||||
}
|
||||
|
||||
controlEntry := &model.Entry{
|
||||
Title: `A title`,
|
||||
Content: `<iframe width="650" height="350" frameborder="0" src="https://invidious.custom/embed/1234" allowfullscreen></iframe><br>Video Description`,
|
||||
}
|
||||
testEntry := &model.Entry{
|
||||
Title: `A title`,
|
||||
Content: `Video Description`,
|
||||
}
|
||||
Rewriter("https://www.youtube.com/watch?v=1234", testEntry, ``)
|
||||
|
||||
if !reflect.DeepEqual(testEntry, controlEntry) {
|
||||
t.Errorf(`Not expected output: got "%+v" instead of "%+v"`, testEntry, controlEntry)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRewriteWithInexistingCustomRule(t *testing.T) {
|
||||
controlEntry := &model.Entry{
|
||||
Title: `A title`,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue