Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djrandom
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ale
djrandom
Commits
501e6d69
Commit
501e6d69
authored
10 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
use a flag to control if DAV urls are generated or not
parent
7d214247
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
client/djplay/djplay.go
+23
-8
23 additions, 8 deletions
client/djplay/djplay.go
with
23 additions
and
8 deletions
client/djplay/djplay.go
+
23
−
8
View file @
501e6d69
...
...
@@ -27,6 +27,7 @@ var (
player
=
config
.
String
(
"player"
,
"avplay -vn -nodisp -"
,
"Audio player program"
)
doPlaylist
=
flag
.
Bool
(
"playlist"
,
false
,
"Output a playlist (m3u)"
)
doDownload
=
flag
.
Bool
(
"download"
,
false
,
"Download the results of the search"
)
withDAV
=
flag
.
Bool
(
"with-dav"
,
false
,
"Use the WebDAV API (deprecated)"
)
trackSort
=
flag
.
Bool
(
"sort"
,
false
,
"Sort output by album/track"
)
fill
=
flag
.
Int
(
"fill"
,
-
1
,
"Fill the playlist with pseudo-random results up to the specified number of total songs"
)
)
...
...
@@ -43,22 +44,35 @@ func escape(s string) string {
return
strings
.
Replace
(
s
,
" "
,
"%20"
,
-
1
)
}
func
songURL
(
song
*
api
.
Song
)
string
{
af
:=
song
.
GetBestAudioFile
()
if
af
==
nil
{
return
""
}
url
:=
addAuthToUrl
(
*
serverUrl
)
if
*
withDAV
{
return
fmt
.
Sprintf
(
"%s/dav/%s/%s/%s%s"
,
url
,
escape
(
song
.
Meta
.
Artist
),
escape
(
song
.
Meta
.
Album
),
escape
(
song
.
Meta
.
Title
),
api
.
GetExtensionForMimeType
(
af
.
MimeType
))
}
return
fmt
.
Sprintf
(
"%s/dl/%s"
,
url
,
af
.
MD5
)
}
func
outputSongs
(
songs
[]
*
api
.
Song
)
{
fmt
.
Printf
(
"#EXTM3U
\n\n
"
)
for
_
,
song
:=
range
songs
{
if
len
(
song
.
Files
)
==
0
{
continue
}
af
:=
song
.
GetBestAudioFile
()
fmt
.
Printf
(
"#EXTINF:-1,%s - %s - %s
\n
%s/dav/%s/%s/%s%s
\n\n
"
,
fmt
.
Printf
(
"#EXTINF:-1,%s - %s - %s
\n
%s
\n\n
"
,
song
.
Meta
.
Artist
,
song
.
Meta
.
Album
,
song
.
Meta
.
Title
,
addAuthToUrl
(
*
serverUrl
),
escape
(
song
.
Meta
.
Artist
),
escape
(
song
.
Meta
.
Album
),
escape
(
song
.
Meta
.
Title
),
api
.
GetExtensionForMimeType
(
af
.
MimeType
))
songURL
(
song
))
}
}
...
...
@@ -67,7 +81,8 @@ func play(client *util.HttpClient, song *api.Song) {
return
}
resp
,
err
:=
client
.
GetRaw
(
"/dl/"
+
song
.
Files
[
0
]
.
MD5
)
af
:=
song
.
GetBestAudioFile
()
resp
,
err
:=
client
.
GetRaw
(
"/dl/"
+
af
.
MD5
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment