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
965e6edc
Commit
965e6edc
authored
May 13, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redimentary addition of url's to playlist
git-svn-id:
https://svn.musicpd.org/mpd/trunk@1000
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
8c484eec
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
12 deletions
+56
-12
command.c
src/command.c
+6
-3
directory.c
src/directory.c
+2
-2
directory.h
src/directory.h
+1
-1
ls.c
src/ls.c
+22
-0
ls.h
src/ls.h
+2
-0
playlist.c
src/playlist.c
+21
-6
song.h
src/song.h
+2
-0
No files found.
src/command.c
View file @
965e6edc
...
...
@@ -237,10 +237,13 @@ int handleClose(FILE * fp, unsigned int * permission, int argArrayLength,
int
handleAdd
(
FILE
*
fp
,
unsigned
int
*
permission
,
int
argArrayLength
,
char
**
argArray
)
{
char
*
directory
=
NULL
;
char
*
path
=
NULL
;
if
(
argArrayLength
==
2
)
directory
=
argArray
[
1
];
return
addAllIn
(
fp
,
directory
);
if
(
argArrayLength
==
2
)
{
path
=
argArray
[
1
];
if
(
isRemoteUrl
(
path
))
return
addToPlaylist
(
fp
,
path
);
}
return
addAllIn
(
fp
,
path
);
}
int
handleDelete
(
FILE
*
fp
,
unsigned
int
*
permission
,
int
argArrayLength
,
...
...
src/directory.c
View file @
965e6edc
...
...
@@ -1045,7 +1045,7 @@ int traverseAllIn(FILE * fp, char * name,
if
((
directory
=
getDirectory
(
name
))
==
NULL
)
{
Song
*
song
;
if
((
song
=
getSong
(
name
))
&&
forEachSong
)
{
if
((
song
=
getSong
FromDB
(
name
))
&&
forEachSong
)
{
return
forEachSong
(
fp
,
song
,
data
);
}
myfprintf
(
fp
,
"%s: directory or file not found
\n
"
,
COMMAND_RESPOND_ERROR
);
...
...
@@ -1269,7 +1269,7 @@ Song * getSongDetails(char * file, char ** shortnameRet,
return
(
Song
*
)
song
;
}
Song
*
getSong
(
char
*
file
)
{
Song
*
getSong
FromDB
(
char
*
file
)
{
return
getSongDetails
(
file
,
NULL
,
NULL
);
}
...
...
src/directory.h
View file @
965e6edc
...
...
@@ -65,7 +65,7 @@ int countSongsIn(FILE * fp, char * name);
unsigned
long
sumSongTimesIn
(
FILE
*
fp
,
char
*
name
);
Song
*
getSong
(
char
*
file
);
Song
*
getSong
FromDB
(
char
*
file
);
time_t
getDbModTime
();
...
...
src/ls.c
View file @
965e6edc
...
...
@@ -41,6 +41,28 @@ char * dupAndStripPlaylistSuffix(char * file) {
return
ret
;
}
int
isRemoteUrl
(
char
*
url
)
{
char
*
urlPrefixes
[]
=
{
"http://"
,
"ftp://"
,
NULL
};
while
(
*
urlPrefixes
)
{
if
(
strncmp
(
*
urlPrefixes
,
url
,
strlen
(
*
urlPrefixes
))
==
0
)
{
#ifdef HAVE_MAD
if
(
hasMp3Suffix
(
*
urlPrefixes
))
return
1
;
#endif
#ifdef HAVE_OGG
if
(
hasOggSuffix
(
*
urlPrefixes
))
return
1
;
return
0
;
#endif
}
}
return
0
;
}
int
lsPlaylists
(
FILE
*
fp
,
char
*
utf8path
)
{
DIR
*
dir
;
struct
stat
st
;
...
...
src/ls.h
View file @
965e6edc
...
...
@@ -26,6 +26,8 @@
int
lsPlaylists
(
FILE
*
fp
,
char
*
utf8path
);
int
isRemoteUrl
(
char
*
url
);
int
isFile
(
char
*
utf8file
,
time_t
*
mtime
);
int
isDir
(
char
*
utf8name
);
...
...
src/playlist.c
View file @
965e6edc
...
...
@@ -149,7 +149,12 @@ int clearPlaylist(FILE * fp) {
if
(
stopPlaylist
(
fp
)
<
0
)
return
-
1
;
for
(
i
=
0
;
i
<
playlist
.
length
;
i
++
)
playlist
.
songs
[
i
]
=
NULL
;
for
(
i
=
0
;
i
<
playlist
.
length
;
i
++
)
{
if
(
playlist
.
songs
[
i
]
->
type
==
SONG_TYPE_URL
)
{
free
(
playlist
.
songs
[
i
]);
}
playlist
.
songs
[
i
]
=
NULL
;
}
playlist
.
length
=
0
;
incrPlaylistVersion
();
...
...
@@ -449,13 +454,18 @@ void clearPlayerQueue() {
}
}
int
addToPlaylist
(
FILE
*
fp
,
char
*
file
)
{
int
addToPlaylist
(
FILE
*
fp
,
char
*
url
)
{
Song
*
song
;
DEBUG
(
"add to playlist: %s
\n
"
,
file
);
DEBUG
(
"add to playlist: %s
\n
"
,
url
);
if
(
!
(
song
=
getSong
(
file
)))
{
myfprintf
(
fp
,
"%s
\"
%s
\"
is not in the music db
\n
"
,
COMMAND_RESPOND_ERROR
,
file
);
if
((
song
=
getSongFromDB
(
url
)))
{
}
else
if
(
isRemoteUrl
(
url
)
&&
(
song
=
newSong
(
url
,
SONG_TYPE_URL
)))
{
}
else
{
myfprintf
(
fp
,
"%s
\"
%s
\"
is not in the music db
\n
"
,
COMMAND_RESPOND_ERROR
,
url
);
return
-
1
;
}
...
...
@@ -588,6 +598,9 @@ int deleteFromPlaylist(FILE * fp, int song) {
if
(
playlist
.
order
[
i
]
>
song
)
playlist
.
order
[
i
]
--
;
}
/* now take care of other misc stuff */
if
(
playlist
.
songs
[
playlist
.
length
-
1
]
->
type
==
SONG_TYPE_URL
)
{
freeJustSong
(
playlist
.
songs
[
playlist
.
length
-
1
]);
}
playlist
.
songs
[
playlist
.
length
-
1
]
=
NULL
;
playlist
.
length
--
;
...
...
@@ -1127,7 +1140,9 @@ int loadPlaylist(FILE * fp, char * utf8file) {
temp
=
fsCharsetToUtf8
(
s
);
if
(
!
temp
)
continue
;
temp
=
strdup
(
temp
);
if
(
s
[
0
]
==
PLAYLIST_COMMENT
&&
!
getSong
(
temp
))
{
if
(
s
[
0
]
==
PLAYLIST_COMMENT
&&
!
getSongFromDB
(
temp
)
&&
!
isRemoteUrl
(
temp
))
{
free
(
temp
);
continue
;
}
...
...
src/song.h
View file @
965e6edc
...
...
@@ -48,6 +48,8 @@ Song * newSong(char * utf8url, SONG_TYPE type);
void
freeSong
(
Song
*
);
void
freeJustSong
(
Song
*
);
SongList
*
newSongList
();
void
freeSongList
(
SongList
*
list
);
...
...
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