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
e6600556
Commit
e6600556
authored
Jan 29, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist/despotify: various code simplifications
parent
8cad2058
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
55 deletions
+31
-55
DespotifyPlaylistPlugin.cxx
src/playlist/DespotifyPlaylistPlugin.cxx
+31
-55
No files found.
src/playlist/DespotifyPlaylistPlugin.cxx
View file @
e6600556
...
...
@@ -33,14 +33,8 @@ extern "C" {
#include <string.h>
#include <stdlib.h>
struct
despotify_playlist
{
struct
despotify_session
*
session
;
std
::
forward_list
<
SongPointer
>
songs
;
};
static
void
add_song
(
st
ruct
despotify_playlist
*
ctx
,
struct
ds_track
*
track
)
add_song
(
st
d
::
forward_list
<
SongPointer
>
&
songs
,
struct
ds_track
*
track
)
{
const
char
*
dsp_scheme
=
despotify_playlist_plugin
.
schemes
[
0
];
struct
song
*
song
;
...
...
@@ -60,92 +54,75 @@ add_song(struct despotify_playlist *ctx, struct ds_track *track)
song
=
song_remote_new
(
uri
);
song
->
tag
=
mpd_despotify_tag_from_track
(
track
);
ctx
->
songs
.
emplace_front
(
song
);
songs
.
emplace_front
(
song
);
}
static
bool
parse_track
(
struct
despotify_playlist
*
ctx
,
struct
ds_link
*
link
)
parse_track
(
struct
despotify_session
*
session
,
std
::
forward_list
<
SongPointer
>
&
songs
,
struct
ds_link
*
link
)
{
struct
ds_track
*
track
;
track
=
despotify_link_get_track
(
ctx
->
session
,
link
);
if
(
!
track
)
struct
ds_track
*
track
=
despotify_link_get_track
(
session
,
link
);
if
(
track
==
nullptr
)
return
false
;
add_song
(
ctx
,
track
);
add_song
(
songs
,
track
);
return
true
;
}
static
bool
parse_playlist
(
struct
despotify_playlist
*
ctx
,
struct
ds_link
*
link
)
parse_playlist
(
struct
despotify_session
*
session
,
std
::
forward_list
<
SongPointer
>
&
songs
,
struct
ds_link
*
link
)
{
struct
ds_playlist
*
playlist
;
struct
ds_track
*
track
;
playlist
=
despotify_link_get_playlist
(
ctx
->
session
,
link
);
if
(
!
playlist
)
ds_playlist
*
playlist
=
despotify_link_get_playlist
(
session
,
link
);
if
(
playlist
==
nullptr
)
return
false
;
for
(
track
=
playlist
->
tracks
;
track
;
track
=
track
->
next
)
add_song
(
ctx
,
track
);
for
(
ds_track
*
track
=
playlist
->
tracks
;
track
!=
nullptr
;
track
=
track
->
next
)
add_song
(
songs
,
track
);
return
true
;
}
static
bool
despotify_playlist_init
(
G_GNUC_UNUSED
const
struct
config_param
*
param
)
{
return
true
;
}
static
void
despotify_playlist_finish
(
void
)
{
}
static
struct
playlist_provider
*
despotify_playlist_open_uri
(
const
char
*
url
,
gcc_unused
Mutex
&
mutex
,
gcc_unused
Cond
&
cond
)
{
struct
despotify_session
*
session
;
struct
ds_link
*
link
;
bool
parse_result
;
session
=
mpd_despotify_get_session
();
if
(
!
session
)
despotify_session
*
session
=
mpd_despotify_get_session
();
if
(
session
==
nullptr
)
return
nullptr
;
/* Get link without spt:// */
link
=
despotify_link_from_uri
(
url
+
strlen
(
despotify_playlist_plugin
.
schemes
[
0
])
+
3
);
if
(
!
link
)
{
ds_link
*
link
=
despotify_link_from_uri
(
url
+
strlen
(
despotify_playlist_plugin
.
schemes
[
0
])
+
3
);
if
(
link
==
nullptr
)
{
g_debug
(
"Can't find %s
\n
"
,
url
);
return
nullptr
;
}
struct
despotify_playlist
ctx
;
ctx
.
session
=
session
;
std
::
forward_list
<
SongPointer
>
songs
;
switch
(
link
->
type
)
{
bool
parse_result
;
switch
(
link
->
type
)
{
case
LINK_TYPE_TRACK
:
parse_result
=
parse_track
(
&
ctx
,
link
);
parse_result
=
parse_track
(
session
,
songs
,
link
);
break
;
case
LINK_TYPE_PLAYLIST
:
parse_result
=
parse_playlist
(
&
ctx
,
link
);
parse_result
=
parse_playlist
(
session
,
songs
,
link
);
break
;
default
:
parse_result
=
false
;
break
;
}
despotify_free_link
(
link
);
if
(
!
parse_result
)
return
nullptr
;
ctx
.
songs
.
reverse
();
return
new
MemoryPlaylistProvider
(
std
::
move
(
ctx
.
songs
));
songs
.
reverse
();
return
new
MemoryPlaylistProvider
(
std
::
move
(
songs
));
}
static
const
char
*
const
despotify_schemes
[]
=
{
...
...
@@ -156,9 +133,8 @@ static const char *const despotify_schemes[] = {
const
struct
playlist_plugin
despotify_playlist_plugin
=
{
"despotify"
,
despotify_playlist_init
,
despotify_playlist_finish
,
nullptr
,
nullptr
,
despotify_playlist_open_uri
,
nullptr
,
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