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>
|
<time>{{ formatDate(itemSelectedDetails.date) }}</time>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
|
<audio class="w-100" controls v-if="itemSelectedDetails.podcast_url" :src="itemSelectedDetails.podcast_url"></audio>
|
||||||
<div v-html="itemSelectedContent"></div>
|
<div v-html="itemSelectedContent"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -237,6 +238,14 @@ func convertItems(items []*gofeed.Item, feed storage.Feed) []storage.Item {
|
|||||||
if item.Author != nil {
|
if item.Author != nil {
|
||||||
author = item.Author.Name
|
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{
|
result[i] = storage.Item{
|
||||||
GUID: item.GUID,
|
GUID: item.GUID,
|
||||||
FeedId: feed.Id,
|
FeedId: feed.Id,
|
||||||
@ -249,6 +258,7 @@ func convertItems(items []*gofeed.Item, feed storage.Feed) []storage.Item {
|
|||||||
DateUpdated: item.UpdatedParsed,
|
DateUpdated: item.UpdatedParsed,
|
||||||
Status: storage.UNREAD,
|
Status: storage.UNREAD,
|
||||||
Image: imageURL,
|
Image: imageURL,
|
||||||
|
PodcastURL: podcastUrl,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
@ -55,6 +55,7 @@ type Item struct {
|
|||||||
DateUpdated *time.Time `json:"date_updated"`
|
DateUpdated *time.Time `json:"date_updated"`
|
||||||
Status ItemStatus `json:"status"`
|
Status ItemStatus `json:"status"`
|
||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
|
PodcastURL string `json:"podcast_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ItemFilter struct {
|
type ItemFilter struct {
|
||||||
@ -91,15 +92,15 @@ func (s *Storage) CreateItems(items []Item) bool {
|
|||||||
guid, feed_id, title, link, description,
|
guid, feed_id, title, link, description,
|
||||||
content, author,
|
content, author,
|
||||||
date, date_updated, date_arrived,
|
date, date_updated, date_arrived,
|
||||||
status, image
|
status, image, podcast_url
|
||||||
)
|
)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
on conflict (feed_id, guid) do update set
|
on conflict (feed_id, guid) do update set
|
||||||
date_updated = ?, date_arrived = ?`,
|
date_updated = ?, date_arrived = ?`,
|
||||||
item.GUID, item.FeedId, html.UnescapeString(item.Title), item.Link, item.Description,
|
item.GUID, item.FeedId, html.UnescapeString(item.Title), item.Link, item.Description,
|
||||||
item.Content, item.Author,
|
item.Content, item.Author,
|
||||||
item.Date, item.DateUpdated, now,
|
item.Date, item.DateUpdated, now,
|
||||||
UNREAD, item.Image,
|
UNREAD, item.Image, item.PodcastURL,
|
||||||
// upsert values
|
// upsert values
|
||||||
item.DateUpdated, now,
|
item.DateUpdated, now,
|
||||||
)
|
)
|
||||||
@ -165,7 +166,7 @@ func (s *Storage) ListItems(filter ItemFilter, offset, limit int, newestFirst bo
|
|||||||
query := fmt.Sprintf(`
|
query := fmt.Sprintf(`
|
||||||
select
|
select
|
||||||
i.id, i.guid, i.feed_id, i.title, i.link, i.description,
|
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
|
from items i
|
||||||
join feeds f on f.id = i.feed_id
|
join feeds f on f.id = i.feed_id
|
||||||
where %s
|
where %s
|
||||||
@ -192,6 +193,7 @@ func (s *Storage) ListItems(filter ItemFilter, offset, limit int, newestFirst bo
|
|||||||
&x.DateUpdated,
|
&x.DateUpdated,
|
||||||
&x.Status,
|
&x.Status,
|
||||||
&x.Image,
|
&x.Image,
|
||||||
|
&x.PodcastURL,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log.Print(err)
|
s.log.Print(err)
|
||||||
|
@ -10,13 +10,14 @@ var migrations = []func(*sql.Tx)error{
|
|||||||
m00_initial,
|
m00_initial,
|
||||||
m01_feed_states_and_errors,
|
m01_feed_states_and_errors,
|
||||||
m02_on_delete_actions,
|
m02_on_delete_actions,
|
||||||
|
m03_item_podcasturl,
|
||||||
}
|
}
|
||||||
|
|
||||||
var maxVersion = int64(len(migrations))
|
var maxVersion = int64(len(migrations))
|
||||||
|
|
||||||
func migrate(db *sql.DB, log *log.Logger) error {
|
func migrate(db *sql.DB, log *log.Logger) error {
|
||||||
var version int64
|
var version int64
|
||||||
db.QueryRow("pragma user_version").Scan(&version);
|
db.QueryRow("pragma user_version").Scan(&version);
|
||||||
|
|
||||||
if version >= maxVersion {
|
if version >= maxVersion {
|
||||||
return nil
|
return nil
|
||||||
@ -37,7 +38,7 @@ func migrate(db *sql.DB, log *log.Logger) error {
|
|||||||
if err = migratefunc(tx); err != nil {
|
if err = migratefunc(tx); err != nil {
|
||||||
log.Printf("[migration:%d] failed to migrate", v)
|
log.Printf("[migration:%d] failed to migrate", v)
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if _, err = tx.Exec(fmt.Sprintf("pragma user_version = %d", v + 1)); err != nil {
|
if _, err = tx.Exec(fmt.Sprintf("pragma user_version = %d", v + 1)); err != nil {
|
||||||
log.Printf("[migration:%d] failed to bump version", v)
|
log.Printf("[migration:%d] failed to bump version", v)
|
||||||
@ -109,7 +110,7 @@ func m00_initial(tx *sql.Tx) error {
|
|||||||
delete from search where rowid = old.search_rowid;
|
delete from search where rowid = old.search_rowid;
|
||||||
end;
|
end;
|
||||||
`
|
`
|
||||||
_, err := tx.Exec(sql)
|
_, err := tx.Exec(sql)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,3 +211,11 @@ func m02_on_delete_actions(tx *sql.Tx) error {
|
|||||||
_, err := tx.Exec(sql)
|
_, err := tx.Exec(sql)
|
||||||
return err
|
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