redimentary addition of url's to playlist
git-svn-id: https://svn.musicpd.org/mpd/trunk@1000 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
8c484eeccf
commit
965e6edcf1
@ -237,10 +237,13 @@ int handleClose(FILE * fp, unsigned int * permission, int argArrayLength,
|
|||||||
int handleAdd(FILE * fp, unsigned int * permission, int argArrayLength,
|
int handleAdd(FILE * fp, unsigned int * permission, int argArrayLength,
|
||||||
char ** argArray)
|
char ** argArray)
|
||||||
{
|
{
|
||||||
char * directory = NULL;
|
char * path = NULL;
|
||||||
|
|
||||||
if(argArrayLength == 2) directory = argArray[1];
|
if(argArrayLength == 2) {
|
||||||
return addAllIn(fp,directory);
|
path = argArray[1];
|
||||||
|
if(isRemoteUrl(path)) return addToPlaylist(fp,path);
|
||||||
|
}
|
||||||
|
return addAllIn(fp,path);
|
||||||
}
|
}
|
||||||
|
|
||||||
int handleDelete(FILE * fp, unsigned int * permission, int argArrayLength,
|
int handleDelete(FILE * fp, unsigned int * permission, int argArrayLength,
|
||||||
|
@ -1045,7 +1045,7 @@ int traverseAllIn(FILE * fp, char * name,
|
|||||||
|
|
||||||
if((directory = getDirectory(name))==NULL) {
|
if((directory = getDirectory(name))==NULL) {
|
||||||
Song * song;
|
Song * song;
|
||||||
if((song = getSong(name)) && forEachSong) {
|
if((song = getSongFromDB(name)) && forEachSong) {
|
||||||
return forEachSong(fp, song, data);
|
return forEachSong(fp, song, data);
|
||||||
}
|
}
|
||||||
myfprintf(fp,"%s: directory or file not found\n",COMMAND_RESPOND_ERROR);
|
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;
|
return (Song *)song;
|
||||||
}
|
}
|
||||||
|
|
||||||
Song * getSong(char * file) {
|
Song * getSongFromDB(char * file) {
|
||||||
return getSongDetails(file,NULL,NULL);
|
return getSongDetails(file,NULL,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ int countSongsIn(FILE * fp, char * name);
|
|||||||
|
|
||||||
unsigned long sumSongTimesIn(FILE * fp, char * name);
|
unsigned long sumSongTimesIn(FILE * fp, char * name);
|
||||||
|
|
||||||
Song * getSong(char * file);
|
Song * getSongFromDB(char * file);
|
||||||
|
|
||||||
time_t getDbModTime();
|
time_t getDbModTime();
|
||||||
|
|
||||||
|
22
src/ls.c
22
src/ls.c
@ -41,6 +41,28 @@ char * dupAndStripPlaylistSuffix(char * file) {
|
|||||||
return ret;
|
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) {
|
int lsPlaylists(FILE * fp, char * utf8path) {
|
||||||
DIR * dir;
|
DIR * dir;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
2
src/ls.h
2
src/ls.h
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
int lsPlaylists(FILE * fp, char * utf8path);
|
int lsPlaylists(FILE * fp, char * utf8path);
|
||||||
|
|
||||||
|
int isRemoteUrl(char * url);
|
||||||
|
|
||||||
int isFile(char * utf8file, time_t * mtime);
|
int isFile(char * utf8file, time_t * mtime);
|
||||||
|
|
||||||
int isDir(char * utf8name);
|
int isDir(char * utf8name);
|
||||||
|
@ -149,7 +149,12 @@ int clearPlaylist(FILE * fp) {
|
|||||||
|
|
||||||
if(stopPlaylist(fp)<0) return -1;
|
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;
|
playlist.length = 0;
|
||||||
|
|
||||||
incrPlaylistVersion();
|
incrPlaylistVersion();
|
||||||
@ -449,13 +454,18 @@ void clearPlayerQueue() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int addToPlaylist(FILE * fp, char * file) {
|
int addToPlaylist(FILE * fp, char * url) {
|
||||||
Song * song;
|
Song * song;
|
||||||
|
|
||||||
DEBUG("add to playlist: %s\n",file);
|
DEBUG("add to playlist: %s\n",url);
|
||||||
|
|
||||||
if(!(song = getSong(file))) {
|
if((song = getSongFromDB(url))) {
|
||||||
myfprintf(fp,"%s \"%s\" is not in the music db\n",COMMAND_RESPOND_ERROR,file);
|
}
|
||||||
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,6 +598,9 @@ int deleteFromPlaylist(FILE * fp, int song) {
|
|||||||
if(playlist.order[i]>song) playlist.order[i]--;
|
if(playlist.order[i]>song) playlist.order[i]--;
|
||||||
}
|
}
|
||||||
/* now take care of other misc stuff */
|
/* 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.songs[playlist.length-1] = NULL;
|
||||||
playlist.length--;
|
playlist.length--;
|
||||||
|
|
||||||
@ -1127,7 +1140,9 @@ int loadPlaylist(FILE * fp, char * utf8file) {
|
|||||||
temp = fsCharsetToUtf8(s);
|
temp = fsCharsetToUtf8(s);
|
||||||
if(!temp) continue;
|
if(!temp) continue;
|
||||||
temp = strdup(temp);
|
temp = strdup(temp);
|
||||||
if(s[0]==PLAYLIST_COMMENT && !getSong(temp)) {
|
if(s[0]==PLAYLIST_COMMENT && !getSongFromDB(temp)
|
||||||
|
&& !isRemoteUrl(temp))
|
||||||
|
{
|
||||||
free(temp);
|
free(temp);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,8 @@ Song * newSong(char * utf8url, SONG_TYPE type);
|
|||||||
|
|
||||||
void freeSong(Song *);
|
void freeSong(Song *);
|
||||||
|
|
||||||
|
void freeJustSong(Song *);
|
||||||
|
|
||||||
SongList * newSongList();
|
SongList * newSongList();
|
||||||
|
|
||||||
void freeSongList(SongList * list);
|
void freeSongList(SongList * list);
|
||||||
|
Loading…
Reference in New Issue
Block a user