Skip to content

Commit 223a4ca

Browse files
committed
playlists of folders
1 parent c2aea4f commit 223a4ca

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

Diff for: help.html

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ <h1>iLcatraz Help</h1>
1414
<p>/media/playlists/<tt>ID</tt></p>
1515
<p>gets properties of a playlist with the id=<tt>ID</tt></p>
1616
</li>
17+
<li>
18+
<p>/media/playlists/<tt>ID</tt>/playlists</p>
19+
<p>gets list of playlists of a playlist folder with the id=<tt>ID</tt>. Errors if not a folder.</p>
20+
</li>
1721
<li>
1822
<p>/media/playlists/<tt>ID</tt>/tracks</p>
1923
<p>gets list of tracks of a playlist with the id=<tt>ID</tt></p>

Diff for: iLcatraz/HTTPConnectionIL.m

+15-1
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,24 @@ + (NSString*) sanitizePID:(NSString*) pid{
143143

144144
}
145145
}else{
146+
if ([[components objectAtIndex:4] isEqual:@"playlists"]){
147+
/*
148+
/media/playlists/ID/playlists
149+
*/
150+
if ([components count]==5){
151+
/*
152+
/media/playlists/ID/playlists
153+
*/
154+
ret=[service jsonPlaylitsOfFolderWithID:pid];
155+
}else{
156+
return [[RESTResponse alloc] initWithJSON:@"Use /mdeia/playlists API to get specific playlist" andStatus:400];
157+
}
158+
}else{
146159
/*
147160
/media/playlists/ID/<bad>
148161
*/
149-
return [[RESTResponse alloc] initWithJSON:[NSString stringWithFormat:@"\"%@\" is not known resource of a playlist. \"tracks\" expected",[components objectAtIndex:4]] andStatus:404];
162+
return [[RESTResponse alloc] initWithJSON:[NSString stringWithFormat:@"\"%@\" is not known resource of a playlist. \"tracks\" or \"playlists\" expected",[components objectAtIndex:4]] andStatus:404];
163+
}
150164
}
151165
}
152166
}

Diff for: iLcatraz/ITunesService.h

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
- (NSString*) jsonMediaPlaylistWithID:(NSString*)pid;
3131
- (NSInteger) countOfTracksOfPlaylistWithID:(NSString*) pid;
3232
- (NSString*) jsonTracksOfPlaylistWithID:(NSString*) pid;
33+
- (NSString*) jsonPlaylitsOfFolderWithID:(NSString*) pid;
3334
- (NSString*) jsonTrackWithID:(NSString*)tid ofPlaysitWithID:(NSString*)pid;
3435
- (NSString*) pathForTrackWithID:(NSString*)tid ofPlaysitWithID:(NSString*)pid;
3536
- (NSString*) locationForTrackPath:(NSString*)path;

Diff for: iLcatraz/ITunesService.m

+3
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,9 @@ - (NSString*) locationForTrackPath:(NSString*)path{
754754
else
755755
return [components objectAtIndex:1];
756756
};
757+
- (NSString*) jsonPlaylitsOfFolderWithID:(NSString*) pid{
758+
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]];
759+
};
757760

758761

759762
@end

0 commit comments

Comments
 (0)