Add UUID to episodes rather than just a URL

This commit is contained in:
Ismael Arenzana 2020-11-20 14:35:35 -05:00
parent 6968a773a8
commit 843e320fef
Signed by: isma
GPG Key ID: D5586DE2A32CBC3C
7 changed files with 41 additions and 26 deletions

View File

@ -10,6 +10,7 @@ import (
"time"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/google/uuid"
"github.com/mikkyang/id3-go"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@ -59,13 +60,14 @@ var addCmd = &cobra.Command{
os.Exit(-1)
}
uuidWithHyphen := uuid.New()
newEpisode := objects.Episode{
Title: source.Title(),
Summary: summary,
PubDate: pubTime.Format(layout),
Bytes: int64(source.Size()),
Duration: fmt.Sprintf("%v", durationInSeconds),
GUID: strings.Replace(uuidWithHyphen.String(), "-", "", -1),
}
if verbose {

View File

@ -128,17 +128,17 @@ var generateCmd = &cobra.Command{
log.WithFields(log.Fields{"payload": err}).Error("Error rendering HTML.")
os.Exit(-1)
}
}
if upload {
indexURL, err := uploadFile(s, "index.html", "index.html")
if err != nil {
log.WithFields(log.Fields{"payload": err}).Error("Error uploading HTML to S3")
os.Exit(-1)
}
if renderWeb && upload {
indexURL, err := uploadFile(s, "index.html", "index.html")
if err != nil {
log.WithFields(log.Fields{"payload": err}).Error("Error uploading HTML to S3")
os.Exit(-1)
}
if verbose {
log.WithFields(log.Fields{"payload": indexURL}).Info("HTML successfully uploaded to S3")
}
if verbose {
log.WithFields(log.Fields{"payload": indexURL}).Info("HTML successfully uploaded to S3")
}
}

View File

@ -1,5 +1,19 @@
{
"items": [
{
"title": "36: El Del Queso y Las Croquetas",
"link": "https://elmentidero.net/podcast/36.html",
"description": "Sam nos cuenta la transición a un nuevo trabajo. Consideramos lo importante que es que los trabajadores tengan buenas condiciones para mejorar el rendimiento. Hablamos de las ventajas e inconvenientes de trabajar desde casa y la alternativa del co-working.\nEn el programa de hoy hablamos de la polémica campaña de prevención del coronavirus dirigida a los jóvenes en el metro de Madrid.\nAnalizamos dos aspectos de esta campaña: el hecho de que esté dirigida exclusivamente a los jóvenes y la crudeza del mensaje. ¿Justifica el ambicioso fin los medios? ¿El que la campaña esté dirigida a un grupo específico de la población hace que caiga en saco roto?\nDedicamos los últimos minutos a comentar las campañas de información y prevención del virus en nuestros países.\nHoy dialogamos sobre campañas polémicas en El Mentidero. ¿Nos acompañas?",
"summary": "Hoy en el Mentidero debatimos sobre la publicidad un tanto agresiva anti-Covid de la Comunidad de Madrid y la esperanza de la vacuna.",
"is_explicit": false,
"duration": "2040",
"episode": 36,
"file_url": "https://s3.amazonaws.com/cdn.elmentidero.net/episodes/elmentidero36.mp3",
"pubdate": "2020-11-19T19:06:10 EST",
"subtitle": "Hoy en el Mentidero debatimos sobre la publicidad un tanto agresiva anti-Covid de la Comunidad de Madrid y la esperanza de la vacuna.",
"bytes": 177222,
"guid": "https://cdn.elmentidero.net/episodes/elmentidero36.mp3"
},
{
"title": "35: Casi Muero Dos Veces",
"link": "https://elmentidero.net/podcast/35.html",

1
go.mod
View File

@ -10,6 +10,7 @@ require (
github.com/cpuguy83/go-md2man v1.0.10 // indirect
github.com/djimenez/iconv-go v0.0.0-20160305225143-8960e66bd3da // indirect
github.com/faiface/beep v1.0.2 // indirect
github.com/google/uuid v1.1.2
github.com/gorilla/mux v1.7.2 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/magiconair/properties v1.8.1 // indirect

2
go.sum
View File

@ -50,6 +50,8 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v0.0.0-20180628210949-0892b62f0d9f/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherwasm v0.1.1/go.mod h1:kx4n9a+MzHH0BJJhvlsQ65hqLFXDO/m256AsaDPQ+/4=

View File

@ -52,8 +52,8 @@ type Podcast struct {
INewFeedURL string `xml:"itunes:new-feed-url,omitempty"`
IOwner *Author // Author is formatted for itunes as-is
ICategories []*ICategory
IType string `xml:"itunes:type,omitempty"`
Items []*Item
IType string `xml:"itunes:type,omitempty"`
Items []*Item
encode func(w io.Writer, o interface{}) error
}
@ -68,11 +68,11 @@ func New(title, link, description string,
Title: title,
Link: link,
Description: description,
Generator: "feeder (github.com/arenzana/podcast)",
Generator: fmt.Sprintf("feeder v%s (gitlab.com/iarenzana/feeder)", pVersion),
PubDate: parseDateRFC1123Z(pubDate),
LastBuildDate: parseDateRFC1123Z(lastBuildDate),
Language: "es",
IType: "episodic",
Language: "es-es",
IType: "episodic",
// setup dependency (could inject later)
encode: encoder,
}
@ -88,14 +88,6 @@ func (p *Podcast) AddAuthor(name, email string) {
Email: email,
})
p.IAuthor = p.ManagingEditor
fmt.Printf("%v ---- %v\n", email, name)
p.IOwner = &Author{
Email: email,
Name: name,
}
p.IOwner.Email = email
p.IOwner.Name = name
fmt.Printf("---- PETO!!!\n")
}
// AddAtomLink adds a FQDN reference to an atom feed.
@ -339,9 +331,9 @@ func (p *Podcast) AddItem(i Item) (int, error) {
//if episode number is not passed; we will just increase the items by one
if i.IEpisode == 0 && p.IType == "episodic" {
i.IEpisode = len(p.Items) + 1
i.IEpisode = len(p.Items) + 1
}
return len(p.Items), nil
}
@ -401,7 +393,7 @@ func (p *Podcast) AddIType(iType string) {
if len(iType) == 0 {
return
}
if iType == "serial" {
p.IType = "serial"
return
@ -475,6 +467,7 @@ var parseAuthorNameEmail = func(a *Author) string {
var author string
if a != nil {
author = a.Email
if len(a.Name) > 0 {
author = fmt.Sprintf("%s", a.Name)
}

3
vendor/modules.txt vendored
View File

@ -56,6 +56,9 @@ github.com/djimenez/iconv-go
## explicit
# github.com/fsnotify/fsnotify v1.4.7
github.com/fsnotify/fsnotify
# github.com/google/uuid v1.1.2
## explicit
github.com/google/uuid
# github.com/gorilla/mux v1.7.2
## explicit
# github.com/hashicorp/hcl v1.0.0