Add Artist link
This commit is contained in:
28
handlers.go
28
handlers.go
@@ -115,9 +115,10 @@ func downloadPostHandler(c echo.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Meta struct {
|
type Meta struct {
|
||||||
title string
|
title string
|
||||||
artist string
|
artist string
|
||||||
uploadDate time.Time
|
uploadDate time.Time
|
||||||
|
uploaderUrl string
|
||||||
}
|
}
|
||||||
|
|
||||||
func getYtdlpTitle(url string, args []string) (string, error) {
|
func getYtdlpTitle(url string, args []string) (string, error) {
|
||||||
@@ -191,6 +192,16 @@ func getYtdlpUploadDate(url string, args []string) (time.Time, error) {
|
|||||||
return uploadDate, nil
|
return uploadDate, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getYtdlpUploaderUrl(url string, args []string) (string, error) {
|
||||||
|
args = append(args, "--simulate", "--print", "%(uploader_url)s", url)
|
||||||
|
stdout, _, err := ytdlp.Run(args...)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln(err)
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return strings.TrimSpace(string(stdout)), nil
|
||||||
|
}
|
||||||
|
|
||||||
func getYtdlpMeta(url string, args []string) (Meta, error) {
|
func getYtdlpMeta(url string, args []string) (Meta, error) {
|
||||||
|
|
||||||
meta := Meta{}
|
meta := Meta{}
|
||||||
@@ -208,6 +219,10 @@ func getYtdlpMeta(url string, args []string) (Meta, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return meta, err
|
return meta, err
|
||||||
}
|
}
|
||||||
|
meta.uploaderUrl, err = getYtdlpUploaderUrl(url, args)
|
||||||
|
if err != nil {
|
||||||
|
return meta, err
|
||||||
|
}
|
||||||
|
|
||||||
return meta, nil
|
return meta, nil
|
||||||
}
|
}
|
||||||
@@ -569,9 +584,10 @@ func startDownload(originalID uint, videoURL string, audioOnly bool) {
|
|||||||
}
|
}
|
||||||
log.Debugf("original metadata %v", origMeta)
|
log.Debugf("original metadata %v", origMeta)
|
||||||
err = db.Model(&originals.Original{}).Where("id = ?", originalID).Updates(map[string]interface{}{
|
err = db.Model(&originals.Original{}).Where("id = ?", originalID).Updates(map[string]interface{}{
|
||||||
"title": origMeta.title,
|
"title": origMeta.title,
|
||||||
"artist": origMeta.artist,
|
"artist": origMeta.artist,
|
||||||
"upload_date": origMeta.uploadDate,
|
"upload_date": origMeta.uploadDate,
|
||||||
|
"uploader_url": origMeta.uploaderUrl,
|
||||||
}).Error
|
}).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("couldn't store metadata:", err)
|
log.Errorln("couldn't store metadata:", err)
|
||||||
|
@@ -24,16 +24,17 @@ const (
|
|||||||
|
|
||||||
type Original struct {
|
type Original struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
UserID uint
|
UserID uint
|
||||||
URL string
|
URL string
|
||||||
Title string
|
Title string
|
||||||
Artist string
|
Artist string
|
||||||
UploadDate time.Time
|
UploadDate time.Time
|
||||||
Status Status
|
UploaderUrl string
|
||||||
Audio bool // video download requested
|
Status Status
|
||||||
Video bool // audio download requested
|
Audio bool // video download requested
|
||||||
Watched bool
|
Video bool // audio download requested
|
||||||
Timestamp float64
|
Watched bool
|
||||||
|
Timestamp float64
|
||||||
|
|
||||||
Playlist bool // part of a playlist
|
Playlist bool // part of a playlist
|
||||||
PlaylistID uint // Playlist.ID (if part of a playlist)
|
PlaylistID uint // Playlist.ID (if part of a playlist)
|
||||||
|
@@ -10,4 +10,12 @@
|
|||||||
.video-list {
|
.video-list {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-artist-link {
|
||||||
|
|
||||||
|
a,
|
||||||
|
a:visited {
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -35,7 +35,11 @@
|
|||||||
<div class="video-title video-title-bare {{$bareHidden}}">
|
<div class="video-title video-title-bare {{$bareHidden}}">
|
||||||
{{.Title}}
|
{{.Title}}
|
||||||
</div>
|
</div>
|
||||||
<div class="video-info">{{.Artist}}</div>
|
{{if (eq .UploaderUrl "")}}
|
||||||
|
<div class="video-info video-artist-bare">{{.Artist}}</div>
|
||||||
|
{{else}}
|
||||||
|
<div class="video-info video-artist-link"><a href="{{.UploaderUrl}}">{{.Artist}}</a></div>
|
||||||
|
{{end}}
|
||||||
<div class="video-info"><a href="{{.URL}}">{{.URL}}</a></div>
|
<div class="video-info"><a href="{{.URL}}">{{.URL}}</a></div>
|
||||||
<div class="video-info video-status">{{.Status}}</div>
|
<div class="video-info video-status">{{.Status}}</div>
|
||||||
<div class="video-info">
|
<div class="video-info">
|
||||||
|
Reference in New Issue
Block a user