-
Notifications
You must be signed in to change notification settings - Fork 0
/
lambda.go
119 lines (102 loc) · 3.76 KB
/
lambda.go
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package lambda
import (
"fmt"
"io"
"net/url"
"strings"
"github.com/mweagle/SpartaCast/markson"
"github.com/sirupsen/logrus"
)
const (
// PublicKeyPath is the root of files that are
// public
PublicKeyPath = "public"
// KeyComponentFeed is the component for the mp3 output
KeyComponentFeed = "feed"
// KeyComponentMetadata is the component for the metadata JSON output
KeyComponentMetadata = "metadata"
// FeedConfigName is the name of the feed
FeedConfigName = "feed.md"
// KeyProperties is the property name that's in the header
KeyProperties = "properties"
// ContentTypeMP3 is the IANA media type for MP3
ContentTypeMP3 = "audio/mpeg"
)
func manifestKeyPath(baseKeyName string) string {
return fmt.Sprintf("%s/%s/%s.json",
PublicKeyPath,
KeyComponentMetadata,
baseKeyName)
}
// ParseSpartaConfigSpec returns an EpisodeSpec input
// and returns the data
func ParseSpartaConfigSpec(input io.Reader,
configEntry interface{},
logger *logrus.Logger) error {
return markson.UnmarshalMarkson(input,
KeyProperties,
configEntry,
logger)
}
// Feed represents the feed information from a Markdown file.
type Feed struct {
Title string `json:"title,omitempty"`
AuthorName string `json:"authorname"`
AuthorEmail string `json:"authoremail"`
Image string `json:"image,omitempty"`
Link string `json:"link,omitempty"`
Description string `json:"description,omitempty"`
Category string `json:"category,omitempty"`
Subcategory string `json:"subcategory,omitempty"`
Cloud string `json:"cloud,omitempty"`
Copyright string `json:"copyright,omitempty"`
Docs string `json:"docs,omitempty"`
Generator string `json:"generator,omitempty"`
Language string `json:"language,omitempty"`
LastBuildDate string `json:"lastBuildDate,omitempty"`
ManagingEditor string `json:"managingEditor,omitempty"`
PubDate string `json:"pubDate,omitempty"`
Rating string `json:"rating,omitempty"`
SkipHours string `json:"skipHours,omitempty"`
SkipDays string `json:"skipDays,omitempty"`
SubTitle string `json:"subtitle"`
TTL string `json:"ttl,omitempty"`
WebMaster string `json:"webMaster,omitempty"`
IAuthor string `json:"itunes:author,omitempty"`
IExplicit string `json:"itunes:explicit,omitempty"`
IComplete string `json:"itunes:complete,omitempty"`
}
// Item represents an item
type Item struct {
SelfLink string `json:"selfLink"`
Image string `json:"image,omitempty"`
GUID string `json:"guid"`
Title string `json:"title"`
Link string `json:"link"`
EnclosureLink string `json:"enclosureLink"`
EnclosureByteLength int64 `json:"enclosureByteLength"`
Description string `json:"description"`
AuthorName string `json:"authorname"`
AuthorEmail string `json:"authoremail"`
Category string `json:"category"`
Comments string `json:"comments"`
Source string `json:"source"`
PubDate string `json:"pubDate"`
SubTitle string `json:"subtitle"`
IExplicit string `json:"itunes:explicit"`
IIsClosedCaptioned string `json:"itunes:isClosedCaptioned"`
IOrder string `json:"itunes:order"`
PollyVoiceID string `json:"polly:voiceID"`
PollyEngineType string `json:"polly:engineType"`
PollyLanguageCode string `json:"polly:languageCode"`
Episode string `json:"episode"`
}
func keyPathFromS3URI(s3URI string, bucketName string) (string, error) {
parsedURI, parsedURIErr := url.Parse(s3URI)
if parsedURIErr != nil {
return "", parsedURIErr
}
strippedPath := strings.TrimPrefix(parsedURI.Path,
fmt.Sprintf("/%s/", bucketName))
return strippedPath, nil
}