Add a rewrite rule for castopod episodes
This commit is contained in:
parent
7a1429bcc1
commit
808635e314
3 changed files with 17 additions and 0 deletions
|
@ -282,3 +282,9 @@ func removeCustom(entryContent string, selector string) string {
|
|||
output, _ := doc.Find("body").First().Html()
|
||||
return output
|
||||
}
|
||||
|
||||
func addCastopodEpisode(entryURL, entryContent string) string {
|
||||
player := `<iframe width="650" frameborder="0" src="` + entryURL + `/embed/light"></iframe>`
|
||||
|
||||
return player + `<br>` + entryContent
|
||||
}
|
||||
|
|
|
@ -100,6 +100,8 @@ func applyRule(entryURL, entryContent string, rule rule) string {
|
|||
} else {
|
||||
logger.Debug("[Rewrite] Cannot find selector for remove rule %s", rule)
|
||||
}
|
||||
case "add_castopod_episode":
|
||||
entryContent = addCastopodEpisode(entryURL, entryContent)
|
||||
}
|
||||
|
||||
return entryContent
|
||||
|
|
|
@ -286,3 +286,12 @@ func TestRewriteRemoveCustom(t *testing.T) {
|
|||
t.Errorf(`Not expected output: %s`, output)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRewriteAddCastopodEpisode(t *testing.T) {
|
||||
output := Rewriter("https://podcast.demo/@demo/episodes/test", "Episode Description", `add_castopod_episode`)
|
||||
expected := `<iframe width="650" frameborder="0" src="https://podcast.demo/@demo/episodes/test/embed/light"></iframe><br>Episode Description`
|
||||
|
||||
if expected != output {
|
||||
t.Errorf(`Not expected output: got "%s" instead of "%s"`, output, expected)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue