Skip to content

Commit

Permalink
playlists of folders
Browse files Browse the repository at this point in the history
  • Loading branch information
chamspan committed Oct 27, 2014
1 parent c2aea4f commit 223a4ca
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions help.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ <h1>iLcatraz Help</h1>
<p>/media/playlists/<tt>ID</tt></p>
<p>gets properties of a playlist with the id=<tt>ID</tt></p>
</li>
<li>
<p>/media/playlists/<tt>ID</tt>/playlists</p>
<p>gets list of playlists of a playlist folder with the id=<tt>ID</tt>. Errors if not a folder.</p>
</li>
<li>
<p>/media/playlists/<tt>ID</tt>/tracks</p>
<p>gets list of tracks of a playlist with the id=<tt>ID</tt></p>
Expand Down
16 changes: 15 additions & 1 deletion iLcatraz/HTTPConnectionIL.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,24 @@ + (NSString*) sanitizePID:(NSString*) pid{

}
}else{
if ([[components objectAtIndex:4] isEqual:@"playlists"]){
/*
/media/playlists/ID/playlists
*/
if ([components count]==5){
/*
/media/playlists/ID/playlists
*/
ret=[service jsonPlaylitsOfFolderWithID:pid];
}else{
return [[RESTResponse alloc] initWithJSON:@"Use /mdeia/playlists API to get specific playlist" andStatus:400];
}
}else{
/*
/media/playlists/ID/<bad>
*/
return [[RESTResponse alloc] initWithJSON:[NSString stringWithFormat:@"\"%@\" is not known resource of a playlist. \"tracks\" expected",[components objectAtIndex:4]] andStatus:404];
return [[RESTResponse alloc] initWithJSON:[NSString stringWithFormat:@"\"%@\" is not known resource of a playlist. \"tracks\" or \"playlists\" expected",[components objectAtIndex:4]] andStatus:404];
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions iLcatraz/ITunesService.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- (NSString*) jsonMediaPlaylistWithID:(NSString*)pid;
- (NSInteger) countOfTracksOfPlaylistWithID:(NSString*) pid;
- (NSString*) jsonTracksOfPlaylistWithID:(NSString*) pid;
- (NSString*) jsonPlaylitsOfFolderWithID:(NSString*) pid;
- (NSString*) jsonTrackWithID:(NSString*)tid ofPlaysitWithID:(NSString*)pid;
- (NSString*) pathForTrackWithID:(NSString*)tid ofPlaysitWithID:(NSString*)pid;
- (NSString*) locationForTrackPath:(NSString*)path;
Expand Down
3 changes: 3 additions & 0 deletions iLcatraz/ITunesService.m
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,9 @@ - (NSString*) locationForTrackPath:(NSString*)path{
else
return [components objectAtIndex:1];
};
- (NSString*) jsonPlaylitsOfFolderWithID:(NSString*) pid{
return [self jsonForCode:[NSString stringWithFormat:@"tell application \"iTunes\"\n set f to first item of (playlists whose persistent ID is \"%@\")\n set results to {}\n repeat with p in playlists\n try\n if p's parent = f then set end of results to p's properties\n end try\n end repeat\n results\n end tell",pid]];
};


@end

0 comments on commit 223a4ca

Please sign in to comment.