Add Artist link
This commit is contained in:
16
handlers.go
16
handlers.go
@@ -118,6 +118,7 @@ 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
|
||||||
}
|
}
|
||||||
@@ -572,6 +587,7 @@ func startDownload(originalID uint, videoURL string, audioOnly bool) {
|
|||||||
"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)
|
||||||
|
@@ -29,6 +29,7 @@ type Original struct {
|
|||||||
Title string
|
Title string
|
||||||
Artist string
|
Artist string
|
||||||
UploadDate time.Time
|
UploadDate time.Time
|
||||||
|
UploaderUrl string
|
||||||
Status Status
|
Status Status
|
||||||
Audio bool // video download requested
|
Audio bool // video download requested
|
||||||
Video bool // audio download requested
|
Video bool // audio download requested
|
||||||
|
@@ -11,3 +11,11 @@
|
|||||||
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