Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
d2b8852d
Commit
d2b8852d
authored
Oct 13, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist/SoundCloud: move code to TranslateSoundCloudUri()
parent
7d4de718
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
28 deletions
+33
-28
SoundCloudPlaylistPlugin.cxx
src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
+33
-28
No files found.
src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
View file @
d2b8852d
...
...
@@ -86,6 +86,38 @@ soundcloud_resolve(const char* uri)
return
ru
;
}
static
char
*
TranslateSoundCloudUri
(
const
char
*
uri
)
noexcept
{
if
(
strncmp
(
uri
,
"track/"
,
6
)
==
0
)
{
const
char
*
rest
=
uri
+
6
;
return
xstrcatdup
(
"https://api.soundcloud.com/tracks/"
,
rest
,
".json?client_id="
,
soundcloud_config
.
apikey
.
c_str
());
}
else
if
(
strncmp
(
uri
,
"playlist/"
,
9
)
==
0
)
{
const
char
*
rest
=
uri
+
9
;
return
xstrcatdup
(
"https://api.soundcloud.com/playlists/"
,
rest
,
".json?client_id="
,
soundcloud_config
.
apikey
.
c_str
());
}
else
if
(
strncmp
(
uri
,
"user/"
,
5
)
==
0
)
{
const
char
*
rest
=
uri
+
5
;
return
xstrcatdup
(
"https://api.soundcloud.com/users/"
,
rest
,
"/tracks.json?client_id="
,
soundcloud_config
.
apikey
.
c_str
());
}
else
if
(
strncmp
(
uri
,
"search/"
,
7
)
==
0
)
{
const
char
*
rest
=
uri
+
7
;
return
xstrcatdup
(
"https://api.soundcloud.com/tracks.json?q="
,
rest
,
"&client_id="
,
soundcloud_config
.
apikey
.
c_str
());
}
else
if
(
strncmp
(
uri
,
"url/"
,
4
)
==
0
)
{
const
char
*
rest
=
uri
+
4
;
/* Translate to soundcloud resolver call. libcurl will automatically
follow the redirect to the right resource. */
return
soundcloud_resolve
(
rest
);
}
else
return
nullptr
;
}
/* YAJL parser for track data from both /tracks/ and /playlists/ JSON */
static
const
char
*
const
key_str
[]
=
{
...
...
@@ -240,34 +272,7 @@ soundcloud_open_uri(const char *uri, Mutex &mutex)
assert
(
StringEqualsCaseASCII
(
uri
,
"soundcloud://"
,
13
));
uri
+=
13
;
char
*
u
=
nullptr
;
if
(
strncmp
(
uri
,
"track/"
,
6
)
==
0
)
{
const
char
*
rest
=
uri
+
6
;
u
=
xstrcatdup
(
"https://api.soundcloud.com/tracks/"
,
rest
,
".json?client_id="
,
soundcloud_config
.
apikey
.
c_str
());
}
else
if
(
strncmp
(
uri
,
"playlist/"
,
9
)
==
0
)
{
const
char
*
rest
=
uri
+
9
;
u
=
xstrcatdup
(
"https://api.soundcloud.com/playlists/"
,
rest
,
".json?client_id="
,
soundcloud_config
.
apikey
.
c_str
());
}
else
if
(
strncmp
(
uri
,
"user/"
,
5
)
==
0
)
{
const
char
*
rest
=
uri
+
5
;
u
=
xstrcatdup
(
"https://api.soundcloud.com/users/"
,
rest
,
"/tracks.json?client_id="
,
soundcloud_config
.
apikey
.
c_str
());
}
else
if
(
strncmp
(
uri
,
"search/"
,
7
)
==
0
)
{
const
char
*
rest
=
uri
+
7
;
u
=
xstrcatdup
(
"https://api.soundcloud.com/tracks.json?q="
,
rest
,
"&client_id="
,
soundcloud_config
.
apikey
.
c_str
());
}
else
if
(
strncmp
(
uri
,
"url/"
,
4
)
==
0
)
{
const
char
*
rest
=
uri
+
4
;
/* Translate to soundcloud resolver call. libcurl will automatically
follow the redirect to the right resource. */
u
=
soundcloud_resolve
(
rest
);
}
char
*
u
=
TranslateSoundCloudUri
(
uri
);
AtScopeExit
(
u
)
{
free
(
u
);
};
if
(
u
==
nullptr
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment