mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2026-01-07 19:39:40 +05:00
view what albums/playlists track is in, related tracks
This commit is contained in:
@@ -10,24 +10,40 @@ import (
|
||||
|
||||
func toExt(audio string) string {
|
||||
switch audio {
|
||||
case cfg.AudioAAC:
|
||||
return "m4a"
|
||||
case cfg.AudioOpus:
|
||||
return "ogg"
|
||||
case cfg.AudioMP3:
|
||||
return "mp3"
|
||||
case cfg.AudioAAC:
|
||||
return "m4a"
|
||||
case cfg.AudioOpus:
|
||||
return "ogg"
|
||||
case cfg.AudioMP3:
|
||||
return "mp3"
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
templ TrackHeader(prefs cfg.Preferences, t sc.Track) {
|
||||
templ TrackButtons(current string, track sc.Track) {
|
||||
<div class="btns">
|
||||
for _, b := range [...]btn{{"related tracks", "/recommended", false},{"in albums", "/albums", false},{"in playlists", "/sets", false},{"view on soundcloud", "https://soundcloud.com"+track.Href(), true}} {
|
||||
if b.text == current {
|
||||
<a class="btn active">{ b.text }</a>
|
||||
} else {
|
||||
if b.external {
|
||||
<a class="btn" href={ templ.URL(b.href) } referrerpolicy="no-referrer" rel="external nofollow noopener noreferrer" target="_blank">{ b.text }</a>
|
||||
} else {
|
||||
<a class="btn" href={ templ.URL(track.Href() + b.href) }>{ b.text }</a>
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
templ TrackHeader(prefs cfg.Preferences, t sc.Track, needPlayer bool) {
|
||||
<meta name="og:site_name" content={ t.Author.Username + " ~ soundcloak" }/>
|
||||
<meta name="og:title" content={ t.Title }/>
|
||||
<meta name="og:description" content={ t.FormatDescription() }/>
|
||||
<meta name="og:image" content={ t.Artwork }/>
|
||||
<link rel="icon" type="image/x-icon" href={ t.Artwork }/>
|
||||
if *prefs.Player == cfg.HLSPlayer {
|
||||
if needPlayer && *prefs.Player == cfg.HLSPlayer {
|
||||
<script src="/js/hls.js/hls.light.min.js"></script>
|
||||
}
|
||||
}
|
||||
@@ -55,7 +71,7 @@ templ TrackPlayer(prefs cfg.Preferences, track sc.Track, stream string, displayE
|
||||
if cfg.Restream && *prefs.Player == cfg.RestreamPlayer {
|
||||
{{ audioPref = *prefs.RestreamAudio }}
|
||||
if nextTrack != nil {
|
||||
<audio id="track" src={ "/_/restream" + track.Href() } controls autoplay?={ autoplay } data-next={ next(nextTrack, playlist, true, mode, "") } volume={volume}></audio>
|
||||
<audio id="track" src={ "/_/restream" + track.Href() } controls autoplay?={ autoplay } data-next={ next(nextTrack, playlist, true, mode, "") } volume={ volume }></audio>
|
||||
<script async src="/restream.js"></script>
|
||||
} else {
|
||||
<audio src={ "/_/restream" + track.Href() } controls autoplay?={ autoplay }></audio>
|
||||
@@ -86,7 +102,6 @@ templ TrackPlayer(prefs cfg.Preferences, track sc.Track, stream string, displayE
|
||||
<p>Only a 30-second snippet is available.</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
if *prefs.ShowAudio {
|
||||
<div>
|
||||
if audioPref == cfg.AudioBest {
|
||||
@@ -132,8 +147,13 @@ templ Track(prefs cfg.Preferences, t sc.Track, stream string, displayErr string,
|
||||
}
|
||||
<h1>{ t.Title }</h1>
|
||||
@TrackPlayer(prefs, t, stream, displayErr, autoplay, nextTrack, playlist, volume, mode, audio)
|
||||
if cfg.Restream {
|
||||
<div style="display: flex; margin-bottom: 1rem;">
|
||||
<a class="btn" href={ templ.URL("/_/restream" + t.Href() + "?metadata=true") } download={ t.Permalink + "." + toExt(audio) }>download</a>
|
||||
</div>
|
||||
}
|
||||
if t.Genre != "" {
|
||||
<a href={templ.URL("/tags/"+t.Genre)}><p class="tag">{ t.Genre }</p></a>
|
||||
<a href={ templ.URL("/tags/" + t.Genre) }><p class="tag">{ t.Genre }</p></a>
|
||||
}
|
||||
if playlist != nil {
|
||||
<details open style="margin-bottom: 1rem;">
|
||||
@@ -143,22 +163,23 @@ templ Track(prefs cfg.Preferences, t sc.Track, stream string, displayErr string,
|
||||
<h2>Next track:</h2>
|
||||
@TrackItem(nextTrack, true, next(nextTrack, playlist, true, mode, volume))
|
||||
<div style="display: flex; gap: 1rem">
|
||||
<a href={ templ.URL(t.Href()) } class="btn">Stop playlist playback</a>
|
||||
if mode != cfg.AutoplayRandom {
|
||||
<a href={ templ.URL(next(&t, playlist, false, cfg.AutoplayRandom, volume)) } class="btn">Switch to random mode</a>
|
||||
} else {
|
||||
<a href={ templ.URL(next(&t, playlist, false, cfg.AutoplayNormal, volume)) } class="btn">Switch to normal mode</a>
|
||||
}
|
||||
<a href={ templ.URL(t.Href()) } class="btn">Stop playlist playback</a>
|
||||
if mode != cfg.AutoplayRandom {
|
||||
<a href={ templ.URL(next(&t, playlist, false, cfg.AutoplayRandom, volume)) } class="btn">Switch to random mode</a>
|
||||
} else {
|
||||
<a href={ templ.URL(next(&t, playlist, false, cfg.AutoplayNormal, volume)) } class="btn">Switch to normal mode</a>
|
||||
}
|
||||
</div>
|
||||
</details>
|
||||
}
|
||||
@UserItem(&t.Author)
|
||||
<div style="display: flex; gap: 1rem">
|
||||
<a class="btn" href={ templ.URL("https://soundcloud.com" + t.Href()) }>view on soundcloud</a>
|
||||
if cfg.Restream {
|
||||
<a class="btn" href={ templ.URL("/_/restream" + t.Href() + "?metadata=true") } download={t.Permalink + "." + toExt(audio)}>download</a>
|
||||
}
|
||||
</div>
|
||||
@TrackButtons("", t)
|
||||
// <div style="display: flex; gap: 1rem">
|
||||
// <a class="btn" href={ templ.URL("https://soundcloud.com" + t.Href()) }>view on soundcloud</a>
|
||||
// if cfg.Restream {
|
||||
// <a class="btn" href={ templ.URL("/_/restream" + t.Href() + "?metadata=true") } download={t.Permalink + "." + toExt(audio)}>download</a>
|
||||
// }
|
||||
// </div>
|
||||
<br/>
|
||||
@Description(prefs, t.Description, nil)
|
||||
<p>{ strconv.FormatInt(t.Likes, 10) } likes</p>
|
||||
@@ -212,3 +233,60 @@ templ SearchTracks(p *sc.Paginated[*sc.Track]) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
templ RelatedTracks(t sc.Track, p *sc.Paginated[*sc.Track]) {
|
||||
if t.Artwork != "" {
|
||||
<img src={ t.Artwork } width="300px"/>
|
||||
}
|
||||
<h1><a href={templ.URL(t.Href())}>{ t.Title }</a></h1>
|
||||
@TrackButtons("related tracks", t)
|
||||
<br/>
|
||||
if len(p.Collection) == 0 {
|
||||
<p>no more results</p>
|
||||
} else {
|
||||
for _, track := range p.Collection {
|
||||
@TrackItem(track, true, "")
|
||||
}
|
||||
if p.Next != "" {
|
||||
<a class="btn" href={ templ.URL("?pagination=" + url.QueryEscape(strings.Split(p.Next, "/related")[1])) } rel="noreferrer">more tracks</a>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
templ TrackInAlbums(t sc.Track, p *sc.Paginated[*sc.Playlist]) {
|
||||
if t.Artwork != "" {
|
||||
<img src={ t.Artwork } width="300px"/>
|
||||
}
|
||||
<h1><a href={templ.URL(t.Href())}>{ t.Title }</a></h1>
|
||||
@TrackButtons("in albums", t)
|
||||
<br/>
|
||||
if len(p.Collection) == 0 {
|
||||
<p>no more albums</p>
|
||||
} else {
|
||||
for _, playlist := range p.Collection {
|
||||
@PlaylistItem(playlist, true)
|
||||
}
|
||||
if p.Next != "" {
|
||||
<a class="btn" href={ templ.URL("?pagination=" + url.QueryEscape(strings.Split(p.Next, "/albums")[1])) } rel="noreferrer">more albums</a>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
templ TrackInPlaylists(t sc.Track, p *sc.Paginated[*sc.Playlist]) {
|
||||
if t.Artwork != "" {
|
||||
<img src={ t.Artwork } width="300px"/>
|
||||
}
|
||||
<h1><a href={templ.URL(t.Href())}>{ t.Title }</a></h1>
|
||||
@TrackButtons("in playlists", t)
|
||||
<br/>
|
||||
if len(p.Collection) == 0 {
|
||||
<p>no more playlists</p>
|
||||
} else {
|
||||
for _, playlist := range p.Collection {
|
||||
@PlaylistItem(playlist, true)
|
||||
}
|
||||
if p.Next != "" {
|
||||
<a class="btn" href={ templ.URL("?pagination=" + url.QueryEscape(strings.Split(p.Next, "/playlists_without_albums")[1])) } rel="noreferrer">more playlists</a>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user