mirror of
https://github.com/miniflux/v2.git
synced 2025-08-16 18:01:37 +00:00
Add support for Invidious
- Embed Invidious player for invidio.us feeds - Add new rewrite rule to use Invidious player for Youtube feeds
This commit is contained in:
parent
e494d6e381
commit
592151bdb6
4 changed files with 27 additions and 1 deletions
|
@ -16,6 +16,7 @@ import (
|
|||
|
||||
var (
|
||||
youtubeRegex = regexp.MustCompile(`youtube\.com/watch\?v=(.*)`)
|
||||
invidioRegex = regexp.MustCompile(`invidio\.us\/watch\?v=(.*)`)
|
||||
imgRegex = regexp.MustCompile(`<img [^>]+>`)
|
||||
textLinkRegex = regexp.MustCompile(`(?mi)(\bhttps?:\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])`)
|
||||
)
|
||||
|
@ -148,6 +149,26 @@ func addYoutubeVideo(entryURL, entryContent string) string {
|
|||
return entryContent
|
||||
}
|
||||
|
||||
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>`
|
||||
return video + `<br>` + entryContent
|
||||
}
|
||||
return entryContent
|
||||
}
|
||||
|
||||
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>`
|
||||
return video + `<br>` + entryContent
|
||||
}
|
||||
return entryContent
|
||||
}
|
||||
|
||||
func addPDFLink(entryURL, entryContent string) string {
|
||||
if strings.HasSuffix(entryURL, ".pdf") {
|
||||
return fmt.Sprintf(`<a href="%s">PDF</a><br>%s`, entryURL, entryContent)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue