Skip to content

Commit

Permalink
fix: when jpg is used as an enclosure reference
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdoiel committed Oct 11, 2024
1 parent 62c68ee commit fac8e73
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions skim2md.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand All @@ -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
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
}
Expand All @@ -197,13 +196,16 @@ func enclosuresToAudioElement(enclosures string) (string, error) {
}
parts := []string{}
for _, elem := range elements {
parts = append(parts, fmt.Sprintf(`<source type="%s" src="%s"></source>`, elem.Type, elem.URL))
}
if len(elements) > 0 {
parts = append(parts, `<p>Your browser does not support the audio element.</p>`)
if strings.Contains(elem.Type, "audio") {
parts = append(parts, fmt.Sprintf(`<source type="%s" src="%s"></source>`, elem.Type, elem.URL))
}
}
if len(parts) > 0 {
parts = append(parts, `<p>Your browser doesn't support this type of audio file</p>`)

return fmt.Sprintf(`<audio controls="controls">
return fmt.Sprintf(`<audio controls="controls">
%s
</audio>`, strings.Join(parts, "\n\t")), nil
}
return "", nil
}

0 comments on commit fac8e73

Please sign in to comment.