From fac8e73c963fc3438d589f28bc884ccfce90c20a Mon Sep 17 00:00:00 2001 From: "R. S. Doiel" Date: Thu, 10 Oct 2024 20:33:14 -0700 Subject: [PATCH] fix: when jpg is used as an enclosure reference --- skim2md.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/skim2md.go b/skim2md.go index ceb0562..a9e75a3 100644 --- a/skim2md.go +++ b/skim2md.go @@ -1,13 +1,13 @@ package skimmer import ( - "io" + "database/sql" "encoding/json" "fmt" - "database/sql" + "io" "strings" "time" - + // 3rd Party Packages "github.com/mmcdole/gofeed" ) @@ -30,7 +30,7 @@ type Skim2Md struct { // PocketButton, if true insert a "save to pocket" button for each RSS item output PocketButton bool - out io.Writer + out io.Writer eout io.Writer } @@ -63,7 +63,7 @@ func (app *Skim2Md) DisplayItem(link string, title string, description string, e } var ( audioElement string - err error + err error ) if enclosures != "" { audioElement, err = enclosuresToAudioElement(enclosures) @@ -104,7 +104,6 @@ func (app *Skim2Md) DisplayItem(link string, title string, description string, e return nil } - // Write, display the contents from database func (app *Skim2Md) Write(db *sql.DB) error { timestamp := time.Now().Format("2006-01-02 15:04:05") @@ -185,7 +184,7 @@ func (app *Skim2Md) Run(out io.Writer, eout io.Writer, args []string, frontMatte defer db.Close() if err := app.Write(db); err != nil { - return err + return err } return nil } @@ -197,13 +196,16 @@ func enclosuresToAudioElement(enclosures string) (string, error) { } parts := []string{} for _, elem := range elements { - parts = append(parts, fmt.Sprintf(``, elem.Type, elem.URL)) - } - if len(elements) > 0 { - parts = append(parts, `

Your browser does not support the audio element.

`) + if strings.Contains(elem.Type, "audio") { + parts = append(parts, fmt.Sprintf(``, elem.Type, elem.URL)) + } } + if len(parts) > 0 { + parts = append(parts, `

Your browser doesn't support this type of audio file

`) - return fmt.Sprintf(`