Skip to content

Commit

Permalink
Added getNewReleasesForUserBasedOnRecommendations and getBuyLinksForA…
Browse files Browse the repository at this point in the history
…lbum
  • Loading branch information
Kevin Renskers committed Sep 26, 2012
1 parent 305891f commit 6a40e47
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 2 deletions.
7 changes: 6 additions & 1 deletion AUTHORS
@@ -1 +1,6 @@
Kevin Renskers - https://github.com/kevinrenskers https://twitter.com/mixedcase
PRIMARY AUTHORS
Kevin Renskers - https://github.com/kevinrenskers

CONTRIBUTORS
Atli Thorbjornsson - https://github.com/atlithorn
Piers Biddlestone - https://github.com/eightytwo
13 changes: 13 additions & 0 deletions CHANGELOG
@@ -0,0 +1,13 @@
0.3.0 - September 26
- Feature: added getNewReleasesForUserBasedOnRecommendations and getBuyLinksForAlbum
- Feature: added a changelog

0.2.1 - September 21
- Bugfix: having no successHandler should never crash the code

0.2.0 - September 21
- Feature: added a bunch of track methods: loveTrack, unloveTrack, banTrack, unbanTrack, getBuyLinksForTrack
- Bugfix: passing in nil instead of a string argument won't result in a crash

0.0.1 - September 17
- First public release on CocoaPods.
8 changes: 8 additions & 0 deletions Example.xcodeproj/project.pbxproj
Expand Up @@ -22,6 +22,8 @@
0A49B90C15E267E0006ED696 /* DDXMLElement.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A49B90415E267E0006ED696 /* DDXMLElement.m */; };
0A49B90D15E267E0006ED696 /* DDXMLNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A49B90615E267E0006ED696 /* DDXMLNode.m */; };
0ABB9D18160766D200503C5B /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 0ABB9D17160766D200503C5B /* README.md */; };
0AC05DA91613089000D49E39 /* AUTHORS in Resources */ = {isa = PBXBuildFile; fileRef = 0AC05DA71613089000D49E39 /* AUTHORS */; };
0AC05DAA1613089000D49E39 /* CHANGELOG in Resources */ = {isa = PBXBuildFile; fileRef = 0AC05DA81613089000D49E39 /* CHANGELOG */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -53,6 +55,8 @@
0A49B90615E267E0006ED696 /* DDXMLNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDXMLNode.m; sourceTree = "<group>"; };
0A49B90815E267E0006ED696 /* DDXMLPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDXMLPrivate.h; sourceTree = "<group>"; };
0ABB9D17160766D200503C5B /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = "<group>"; };
0AC05DA71613089000D49E39 /* AUTHORS */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AUTHORS; sourceTree = "<group>"; };
0AC05DA81613089000D49E39 /* CHANGELOG */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CHANGELOG; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -76,6 +80,8 @@
0A49B8CE15E26300006ED696 /* Frameworks */,
0A49B8CC15E26300006ED696 /* Products */,
0ABB9D17160766D200503C5B /* README.md */,
0AC05DA71613089000D49E39 /* AUTHORS */,
0AC05DA81613089000D49E39 /* CHANGELOG */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -229,6 +235,8 @@
0A49B8DA15E26300006ED696 /* InfoPlist.strings in Resources */,
0A49B8E315E26300006ED696 /* MainStoryboard.storyboard in Resources */,
0ABB9D18160766D200503C5B /* README.md in Resources */,
0AC05DA91613089000D49E39 /* AUTHORS in Resources */,
0AC05DAA1613089000D49E39 /* CHANGELOG in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,4 +1,4 @@
Copyright (c) 2012 Kevin Renskers (http://mixedcase.nl/)
Copyright (c) 2012 Gangverk ehf. http://gangverk.is

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 2 additions & 0 deletions LastFm/LastFm.h
Expand Up @@ -63,6 +63,7 @@ typedef void (^LastFmReturnBlockWithError)(NSError *error);

- (void)getInfoForAlbum:(NSString *)album artist:(NSString *)artist successHandler:(LastFmReturnBlockWithDictionary)successHandler failureHandler:(LastFmReturnBlockWithError)failureHandler;
- (void)getTracksForAlbum:(NSString *)album artist:(NSString *)artist successHandler:(LastFmReturnBlockWithArray)successHandler failureHandler:(LastFmReturnBlockWithError)failureHandler;
- (void)getBuyLinksForAlbum:(NSString *)album artist:(NSString *)artist country:(NSString *)country successHandler:(LastFmReturnBlockWithArray)successHandler failureHandler:(LastFmReturnBlockWithError)failureHandler;

#pragma mark Track methods

Expand All @@ -81,6 +82,7 @@ typedef void (^LastFmReturnBlockWithError)(NSError *error);
- (void)getInfoForUserOrNil:(NSString *)username successHandler:(LastFmReturnBlockWithDictionary)successHandler failureHandler:(LastFmReturnBlockWithError)failureHandler;
- (void)sendNowPlayingTrack:(NSString *)track byArtist:(NSString *)artist onAlbum:(NSString *)album withDuration:(NSTimeInterval)duration successHandler:(LastFmReturnBlockWithDictionary)successHandler failureHandler:(LastFmReturnBlockWithError)failureHandler;
- (void)sendScrobbledTrack:(NSString *)track byArtist:(NSString *)artist onAlbum:(NSString *)album withDuration:(NSTimeInterval)duration atTimestamp:(NSTimeInterval)timestamp successHandler:(LastFmReturnBlockWithDictionary)successHandler failureHandler:(LastFmReturnBlockWithError)failureHandler;
- (void)getNewReleasesForUserBasedOnRecommendations:(BOOL)basedOnRecommendations successHandler:(LastFmReturnBlockWithArray)successHandler failureHandler:(LastFmReturnBlockWithError)failureHandler;

#pragma mark Chart methods

Expand Down
40 changes: 40 additions & 0 deletions LastFm/LastFm.m
Expand Up @@ -425,6 +425,24 @@ - (void)getTracksForAlbum:(NSString *)album artist:(NSString *)artist successHan
failureHandler:failureHandler];
}

- (void)getBuyLinksForAlbum:(NSString *)album artist:(NSString *)artist country:(NSString *)country successHandler:(LastFmReturnBlockWithArray)successHandler failureHandler:(LastFmReturnBlockWithError)failureHandler {
NSDictionary *mappingObject = @{
@"url": @[ @"./buyLink", @"NSURL" ],
@"price": @[ @"./price/amount", @"NSNumber" ],
@"currency": @[ @"./price/currency", @"NSString" ],
@"name": @[ @"./supplierName", @"NSString" ],
@"icon": @[ @"./supplierIcon", @"NSURL" ]
};

[self performApiCallForMethod:@"album.getBuylinks"
withParams:@{ @"artist": [self forceString:artist], @"album": [self forceString:album], @"country": [self forceString:country] }
rootXpath:@"./affiliations/downloads/affiliation"
returnDictionary:NO
mappingObject:mappingObject
successHandler:successHandler
failureHandler:failureHandler];
}

#pragma mark Track methods

- (void)getInfoForTrack:(NSString *)title artist:(NSString *)artist successHandler:(LastFmReturnBlockWithDictionary)successHandler failureHandler:(LastFmReturnBlockWithError)failureHandler {
Expand Down Expand Up @@ -637,6 +655,28 @@ - (void)sendScrobbledTrack:(NSString *)track byArtist:(NSString *)artist onAlbum
failureHandler:failureHandler];
}

- (void)getNewReleasesForUserBasedOnRecommendations:(BOOL)basedOnRecommendations successHandler:(LastFmReturnBlockWithArray)successHandler failureHandler:(LastFmReturnBlockWithError)failureHandler {
NSDictionary *mappingObject = @{
@"name": @[ @"./name", @"NSString" ],
@"artist": @[ @"./artist/name", @"NSString" ],
@"image": @[ @"./image[@size=\"large\"]", @"NSURL" ],
@"releasedate": @[ @"@releasedate", @"NSString" ]
};

NSDictionary *params = @{
@"user": [self forceString:[self username]],
@"userec": @(basedOnRecommendations)
};

[self performApiCallForMethod:@"user.getNewReleases"
withParams:params
rootXpath:@"./albums/album"
returnDictionary:NO
mappingObject:mappingObject
successHandler:successHandler
failureHandler:failureHandler];
}

#pragma mark Chart methods

- (void)getTopTracksWithLimit:(NSInteger)limit page:(NSInteger)page successHandler:(LastFmReturnBlockWithArray)successHandler failureHandler:(LastFmReturnBlockWithError)failureHandler {
Expand Down

0 comments on commit 6a40e47

Please sign in to comment.