Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions MusaicFM.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@
TargetAttributes = {
E1CF25981DD7D8D500441255 = {
CreatedOnToolsVersion = 8.1;
DevelopmentTeam = YE33ZK7Z99;
ProvisioningStyle = Automatic;
};
E1FA39671DDA3FBE00186BE2 = {
Expand Down Expand Up @@ -530,10 +529,11 @@
E1CF25A41DD7D8D500441255 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 14;
DEVELOPMENT_TEAM = YE33ZK7Z99;
DEVELOPMENT_TEAM = DWVM9CSFLC;
INFOPLIST_FILE = MusaicFM/Info.plist;
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
MACH_O_TYPE = mh_bundle;
Expand All @@ -550,10 +550,12 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Developer ID Application: Dennis Oberhoff (YE33ZK7Z99)";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 14;
DEVELOPMENT_TEAM = YE33ZK7Z99;
"DEVELOPMENT_TEAM[sdk=macosx*]" = DWVM9CSFLC;
INFOPLIST_FILE = MusaicFM/Info.plist;
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
MACH_O_TYPE = mh_bundle;
Expand Down
3 changes: 3 additions & 0 deletions MusaicFM/Factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
+ (NSURLComponents *)spotifyToken;
+ (NSURLComponents *)spotifyAuthentification;

+ (NSURLComponents*)deezerUserPlaylists:(NSString*)userId;
+ (NSURLComponents*)deezerPlaylist:(NSString*)playlistId;

@end
137 changes: 73 additions & 64 deletions MusaicFM/Factory.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,85 +11,94 @@

@implementation Factory

+ (NSURLRequest*)lastFmRequest:(NSArray*)queryItems
{
NSMutableArray* items = queryItems ? queryItems.mutableCopy : [NSMutableArray new];
+ (NSURLRequest *)lastFmRequest:(NSArray *)queryItems {
NSMutableArray *items =
queryItems ? queryItems.mutableCopy : [NSMutableArray new];

[items addObjectsFromArray:@[ [NSURLQueryItem queryItemWithName:@"api_key" value:lastFmId],
[NSURLQueryItem queryItemWithName:@"format"
value:@"json"] ]];
[items addObjectsFromArray:@[
[NSURLQueryItem queryItemWithName:@"api_key" value:lastFmId],
[NSURLQueryItem queryItemWithName:@"format" value:@"json"]
]];

NSURLComponents* components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"ws.audioscrobbler.com";
components.path = @"/2.0/";
components.queryItems = items.copy;
return [NSURLRequest requestWithURL:components.URL];
NSURLComponents *components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"ws.audioscrobbler.com";
components.path = @"/2.0/";
components.queryItems = items.copy;
return [NSURLRequest requestWithURL:components.URL];
}

+ (NSURLComponents*)spotifyAlbums
{
NSURLComponents* components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"api.spotify.com";
components.path = @"/v1/me/albums";
return components;
+ (NSURLComponents *)spotifyAlbums {
NSURLComponents *components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"api.spotify.com";
components.path = @"/v1/me/albums";
return components;
}

+ (NSURLComponents*)spotifyTracks
{
NSURLComponents* components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"api.spotify.com";
components.path = @"/v1/me/tracks";
return components;
+ (NSURLComponents *)spotifyTracks {
NSURLComponents *components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"api.spotify.com";
components.path = @"/v1/me/tracks";
return components;
}

+ (NSURLComponents*)spotifyNewReleases
{
NSURLComponents* components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"api.spotify.com";
components.path = @"/v1/browse/new-releases";
return components;
+ (NSURLComponents *)spotifyNewReleases {
NSURLComponents *components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"api.spotify.com";
components.path = @"/v1/browse/new-releases";
return components;
}

+ (NSURLComponents*)spotifyArtists
{
NSURLComponents* components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"api.spotify.com";
components.path = @"/v1/me/following";
components.queryItems = @[ [NSURLQueryItem queryItemWithName:@"type" value:@"artist"] ];
return components;
+ (NSURLComponents *)spotifyArtists {
NSURLComponents *components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"api.spotify.com";
components.path = @"/v1/me/following";
components.queryItems = @[ [NSURLQueryItem queryItemWithName:@"type"
value:@"artist"] ];
return components;
}

+ (NSURLComponents*)spotifyToken
{
NSURLComponents* components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"accounts.spotify.com";
components.path = @"/api/token";
return components;
+ (NSURLComponents *)spotifyToken {
NSURLComponents *components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"accounts.spotify.com";
components.path = @"/api/token";
return components;
}

+ (NSURLComponents*)spotifyAuthentification
{
NSURLComponents* components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"accounts.spotify.com";
components.path = @"/authorize/";
components.queryItems = @[ [NSURLQueryItem queryItemWithName:@"client_id" value:spotifyClientId],
[NSURLQueryItem queryItemWithName:@"response_type"
value:@"code"],
[NSURLQueryItem queryItemWithName:@"scope"
value:@"user-library-read"],
[NSURLQueryItem queryItemWithName:@"show_dialog"
value:@"true"],
[NSURLQueryItem queryItemWithName:@"redirect_uri"
value:spotifyRedirectUrl] ];
+ (NSURLComponents *)spotifyAuthentification {
NSURLComponents *components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"accounts.spotify.com";
components.path = @"/authorize/";
components.queryItems = @[
[NSURLQueryItem queryItemWithName:@"client_id" value:spotifyClientId],
[NSURLQueryItem queryItemWithName:@"response_type" value:@"code"],
[NSURLQueryItem queryItemWithName:@"scope" value:@"user-library-read"],
[NSURLQueryItem queryItemWithName:@"redirect_uri" value:spotifyRedirectUrl]
];

return components;
return components;
}

+ (NSURLComponents *)deezerUserPlaylists:(NSString *)userId {
NSURLComponents *components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"api.deezer.com";
components.path = [NSString stringWithFormat:@"/user/%@/playlists", userId];
return components;
}

+ (NSURLComponents *)deezerPlaylist:(NSString *)playlistId {
NSURLComponents *components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"api.deezer.com";
components.path = [NSString stringWithFormat:@"/playlist/%@", playlistId];
return components;
}

@end
37 changes: 23 additions & 14 deletions MusaicFM/Manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,34 @@
// Copyright © 2016 Dennis Oberhoff. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Preferences.h"
#import <Foundation/Foundation.h>

typedef NS_ENUM (NSUInteger, Weekly) {
WeeklyAll = 0,
Weekly7Days = 1,
Weekly1Month = 2,
Weekly3Month = 3,
Weekly6Month = 4,
Weekly12Month = 5,
typedef NS_ENUM(NSUInteger, Weekly) {
WeeklyAll = 0,
Weekly7Days = 1,
Weekly1Month = 2,
Weekly3Month = 3,
Weekly6Month = 4,
Weekly12Month = 5,
};

@interface Manager : NSObject

- (void)performSpotifyUserAlbums:(void (^)(NSArray *items)) completion andFailure:(void (^)(NSError *error))failure;
- (void)performSpotifyReleases:(void (^)(NSArray *items)) completion andFailure:(void (^)(NSError *error))failure;
- (void)performSpotifyLikedSongs:(void (^)(NSArray *items)) completion andFailure:(void (^)(NSError *error))failure;
- (void)performSpotifyToken:(NSString *)code completionHandler:(dispatch_block_t)completion andFailure:(void (^)(NSError *error))failure;
- (void)performLastfmTag:(void (^)(NSArray *items)) completion andFailure:(void (^)(NSError *error))failure;
- (void)performLastfmWeekly:(void (^)(NSArray *items)) completion andFailure:(void (^)(NSError *error))failure;
- (void)performSpotifyUserAlbums:(void (^)(NSArray *items))completion
andFailure:(void (^)(NSError *error))failure;
- (void)performSpotifyReleases:(void (^)(NSArray *items))completion
andFailure:(void (^)(NSError *error))failure;
- (void)performSpotifyLikedSongs:(void (^)(NSArray *items))completion
andFailure:(void (^)(NSError *error))failure;
- (void)performDeezerPlaylists:(void (^)(NSArray *items))completion
andFailure:(void (^)(NSError *error))failure;
- (void)performSpotifyToken:(NSString *)code
completionHandler:(dispatch_block_t)completion
andFailure:(void (^)(NSError *error))failure;
- (void)performLastfmTag:(void (^)(NSArray *items))completion
andFailure:(void (^)(NSError *error))failure;
- (void)performLastfmWeekly:(void (^)(NSArray *items))completion
andFailure:(void (^)(NSError *error))failure;

@end
Loading