blob: 61501ee992c52410d888b3dcb6521f4712dcb475 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright 2019 Frédéric Guillot. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package rss // import "miniflux.app/reader/rss"
import "strings"
// PodcastFeedElement represents iTunes and GooglePlay feed XML elements.
// Specs:
// - https://github.com/simplepie/simplepie-ng/wiki/Spec:-iTunes-Podcast-RSS
// - https://developers.google.com/search/reference/podcast/rss-feed
type PodcastFeedElement struct {
ItunesAuthor string `xml:"http://www.itunes.com/dtds/podcast-1.0.dtd channel>author"`
Subtitle string `xml:"http://www.itunes.com/dtds/podcast-1.0.dtd channel>subtitle"`
Summary string `xml:"http://www.itunes.com/dtds/podcast-1.0.dtd channel>summary"`
PodcastOwner PodcastOwner `xml:"http://www.itunes.com/dtds/podcast-1.0.dtd channel>owner"`
GooglePlayAuthor string `xml:"http://www.google.com/schemas/play-podcasts/1.0 channel>author"`
}
// PodcastEntryElement represents iTunes and GooglePlay entry XML elements.
type PodcastEntryElement struct {
Subtitle string `xml:"http://www.itunes.com/dtds/podcast-1.0.dtd subtitle"`
Summary string `xml:"http://www.itunes.com/dtds/podcast-1.0.dtd summary"`
GooglePlayDescription string `xml:"http://www.google.com/schemas/play-podcasts/1.0 description"`
}
// PodcastOwner represents contact information for the podcast owner.
type PodcastOwner struct {
Name string `xml:"http://www.itunes.com/dtds/podcast-1.0.dtd name"`
Email string `xml:"http://www.itunes.com/dtds/podcast-1.0.dtd email"`
}
// Image represents podcast artwork.
type Image struct {
URL string `xml:"href,attr"`
}
// PodcastAuthor returns the author of the podcast.
func (e *PodcastFeedElement) PodcastAuthor() string {
author := ""
switch {
case e.ItunesAuthor != "":
author = e.ItunesAuthor
case e.GooglePlayAuthor != "":
author = e.GooglePlayAuthor
case e.PodcastOwner.Name != "":
author = e.PodcastOwner.Name
case e.PodcastOwner.Email != "":
author = e.PodcastOwner.Email
}
return strings.TrimSpace(author)
}
// PodcastDescription returns the description of the podcast.
func (e *PodcastEntryElement) PodcastDescription() string {
description := ""
switch {
case e.GooglePlayDescription != "":
description = e.GooglePlayDescription
case e.Summary != "":
description = e.Summary
case e.Subtitle != "":
description = e.Subtitle
}
return strings.TrimSpace(description)
}
|