mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
Make add_invidious_video rule applicable for different invidious instances
This commit is contained in:
parent
bf2f7d1e16
commit
0f258fd55b
3 changed files with 11 additions and 7 deletions
|
@ -16,7 +16,7 @@ import (
|
|||
|
||||
var (
|
||||
youtubeRegex = regexp.MustCompile(`youtube\.com/watch\?v=(.*)`)
|
||||
invidioRegex = regexp.MustCompile(`invidio\.us\/watch\?v=(.*)`)
|
||||
invidioRegex = regexp.MustCompile(`https?:\/\/(.*)\/watch\?v=(.*)`)
|
||||
imgRegex = regexp.MustCompile(`<img [^>]+>`)
|
||||
textLinkRegex = regexp.MustCompile(`(?mi)(\bhttps?:\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])`)
|
||||
)
|
||||
|
@ -161,9 +161,8 @@ func addYoutubeVideoUsingInvidiousPlayer(entryURL, entryContent string) string {
|
|||
|
||||
func addInvidiousVideo(entryURL, entryContent string) string {
|
||||
matches := invidioRegex.FindStringSubmatch(entryURL)
|
||||
fmt.Println(matches)
|
||||
if len(matches) == 2 {
|
||||
video := `<iframe width="650" height="350" frameborder="0" src="https://invidio.us/embed/` + matches[1] + `" allowfullscreen></iframe>`
|
||||
if len(matches) == 3 {
|
||||
video := `<iframe width="650" height="350" frameborder="0" src="https://` + matches[1] + `/embed/` + matches[2] + `" allowfullscreen></iframe>`
|
||||
return video + `<br>` + entryContent
|
||||
}
|
||||
return entryContent
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue