char * http_post_playlist_item(char *url, json_value *data) { char *location = http_json_extract(data, "location"); char *tag = http_json_extract(data, "tag"); if(location == NULL) return NULL; if(tag == NULL) tag = strdup(""); char *uid = url + 10; //Skip /playlist/ songdata_song *song = http_song_by_uid(uid); if(song == NULL) return NULL; char *filename = strdup(location); char *path = split_filename(filename); songdata_song *newsong = new_songdata_song(); newsong->fullpath = strdup(location);; newsong->filename = strdup(filename); newsong->path = strdup(path); newsong->title = strdup(filename); newsong->tag = tag; free(location); location = NULL; free(path); path = NULL; songdata_add(playlist, song, newsong); return NULL; }
void add_to_playlist ( songdata *list, songdata_song *position, songdata_song *file ) { songdata_song *newfile; char *p; if ( !songdata_check_file ( file ) ) return; newfile = new_songdata_song(); /* remove tracknumber if it exists and user wants it*/ if ( ! ( conf->c_flags & C_TRACK_NUMBERS ) ) { if ( ( file->filename[0]>='0' ) & ( file->filename[0]<='9' ) ) { if ( ( p = strchr ( file->filename, ' ' ) ) ) newfile->filename = strdup ( p + 1 ); } else if ( !strncasecmp ( file->filename,"cd",2 ) ) newfile->filename = strdup ( file->filename+7 ); } if ( !newfile->filename ) newfile->filename = strdup ( file->filename ); if ( strlen ( newfile->filename ) == 0 ) { free ( newfile->filename ); newfile->filename = strdup ( "..." ); } newfile->path = strdup ( file->path ); newfile->fullpath = strdup ( file->fullpath ); if ( file->genre ) newfile->genre = strdup ( file->genre ); if ( file->album ) newfile->album = strdup ( file->album ); if ( file->artist ) newfile->artist = strdup ( file->artist ); if ( file->title ) newfile->title = strdup ( file->title ); newfile->track_id = file->track_id; newfile->length = file->length; songdata_add ( list, position, newfile ); if ( conf->c_flags & C_PADVANCE ) { list->selected = newfile; list->where = list->length; } return; }
char * http_post_playlist(json_value *data) { char *fullpath = http_json_extract(data, "location"); char *tag = http_json_extract(data, "tag"); if(fullpath == NULL) return; if(tag == NULL) tag = strdup(""); char *filename = strdup(fullpath); char *path = split_filename(filename); songdata_song *newsong = new_songdata_song(); newsong->fullpath = fullpath; newsong->filename = strdup(filename); newsong->path = strdup(path); newsong->title = strdup(filename); newsong->tag = tag; free(path); songdata_add(playlist, playlist->tail, newsong); }