mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 00:33:14 +00:00
podcasts
This commit is contained in:
parent
4accfad266
commit
e1cfb04f98
@ -272,6 +272,7 @@
|
||||
<time>{{ formatDate(itemSelectedDetails.date) }}</time>
|
||||
</div>
|
||||
<hr>
|
||||
<audio class="w-100" controls v-if="itemSelectedDetails.podcast_url" :src="itemSelectedDetails.podcast_url"></audio>
|
||||
<div v-html="itemSelectedContent"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -237,6 +238,14 @@ func convertItems(items []*gofeed.Item, feed storage.Feed) []storage.Item {
|
||||
if item.Author != nil {
|
||||
author = item.Author.Name
|
||||
}
|
||||
podcastUrl := ""
|
||||
if item.Enclosures != nil {
|
||||
for _, enclosure := range item.Enclosures {
|
||||
if strings.ToLower(enclosure.Type) == "audio/mpeg" {
|
||||
podcastUrl = enclosure.URL
|
||||
}
|
||||
}
|
||||
}
|
||||
result[i] = storage.Item{
|
||||
GUID: item.GUID,
|
||||
FeedId: feed.Id,
|
||||
@ -249,6 +258,7 @@ func convertItems(items []*gofeed.Item, feed storage.Feed) []storage.Item {
|
||||
DateUpdated: item.UpdatedParsed,
|
||||
Status: storage.UNREAD,
|
||||
Image: imageURL,
|
||||
PodcastURL: podcastUrl,
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
@ -55,6 +55,7 @@ type Item struct {
|
||||
DateUpdated *time.Time `json:"date_updated"`
|
||||
Status ItemStatus `json:"status"`
|
||||
Image string `json:"image"`
|
||||
PodcastURL string `json:"podcast_url"`
|
||||
}
|
||||
|
||||
type ItemFilter struct {
|
||||
@ -91,15 +92,15 @@ func (s *Storage) CreateItems(items []Item) bool {
|
||||
guid, feed_id, title, link, description,
|
||||
content, author,
|
||||
date, date_updated, date_arrived,
|
||||
status, image
|
||||
status, image, podcast_url
|
||||
)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
on conflict (feed_id, guid) do update set
|
||||
date_updated = ?, date_arrived = ?`,
|
||||
item.GUID, item.FeedId, html.UnescapeString(item.Title), item.Link, item.Description,
|
||||
item.Content, item.Author,
|
||||
item.Date, item.DateUpdated, now,
|
||||
UNREAD, item.Image,
|
||||
UNREAD, item.Image, item.PodcastURL,
|
||||
// upsert values
|
||||
item.DateUpdated, now,
|
||||
)
|
||||
@ -165,7 +166,7 @@ func (s *Storage) ListItems(filter ItemFilter, offset, limit int, newestFirst bo
|
||||
query := fmt.Sprintf(`
|
||||
select
|
||||
i.id, i.guid, i.feed_id, i.title, i.link, i.description,
|
||||
i.content, i.author, i.date, i.date_updated, i.status, i.image
|
||||
i.content, i.author, i.date, i.date_updated, i.status, i.image, i.podcast_url
|
||||
from items i
|
||||
join feeds f on f.id = i.feed_id
|
||||
where %s
|
||||
@ -192,6 +193,7 @@ func (s *Storage) ListItems(filter ItemFilter, offset, limit int, newestFirst bo
|
||||
&x.DateUpdated,
|
||||
&x.Status,
|
||||
&x.Image,
|
||||
&x.PodcastURL,
|
||||
)
|
||||
if err != nil {
|
||||
s.log.Print(err)
|
||||
|
@ -10,6 +10,7 @@ var migrations = []func(*sql.Tx)error{
|
||||
m00_initial,
|
||||
m01_feed_states_and_errors,
|
||||
m02_on_delete_actions,
|
||||
m03_item_podcasturl,
|
||||
}
|
||||
|
||||
var maxVersion = int64(len(migrations))
|
||||
@ -210,3 +211,11 @@ func m02_on_delete_actions(tx *sql.Tx) error {
|
||||
_, err := tx.Exec(sql)
|
||||
return err
|
||||
}
|
||||
|
||||
func m03_item_podcasturl(tx *sql.Tx) error {
|
||||
sql := `
|
||||
alter table items add column podcast_url text
|
||||
`
|
||||
_, err := tx.Exec(sql)
|
||||
return err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user