Skip to content

Commit

Permalink
Inital Release
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Oberhoff authored and Dennis Oberhoff committed Dec 3, 2016
1 parent 6ada612 commit fcd2c5e
Show file tree
Hide file tree
Showing 129 changed files with 10,164 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ fastlane/screenshots
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
.DS_Store
648 changes: 648 additions & 0 deletions MusaicFM.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions MusaicFM.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions MusaicFM/Artwork.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Artwork.h
// MusaicFM
//
// Created by Dennis Oberhoff on 13/11/2016.
// Copyright © 2016 Dennis Oberhoff. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface Artwork : NSObject <NSCoding>

@property (nonatomic, readwrite, strong)NSString * album;
@property (nonatomic, readwrite, strong) NSString *artist;
@property (nonatomic, readwrite, strong) NSURL *artworkUrl;
@property (nonatomic, readwrite, strong) NSURL *url;

@end
39 changes: 39 additions & 0 deletions MusaicFM/Artwork.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Artwork.m
// MusaicFM
//
// Created by Dennis Oberhoff on 13/11/2016.
// Copyright © 2016 Dennis Oberhoff. All rights reserved.
//

#import "Artwork.h"

@implementation Artwork

- (instancetype)initWithCoder:(NSCoder *)decoder {
self = [super init];
if (self) {
self.url = [decoder decodeObjectForKey:@"url"];
self.artworkUrl = [decoder decodeObjectForKey:@"artworkUrl"];
self.album = [decoder decodeObjectForKey:@"name"];
self.artist = [decoder decodeObjectForKey:@"artist"];
}
return self;
}

- (void)encodeWithCoder:(NSCoder *)encoder {
[encoder encodeObject:self.url forKey:@"url"];
[encoder encodeObject:self.artworkUrl forKey:@"artworkUrl"];
[encoder encodeObject:self.album forKey:@"album"];
[encoder encodeObject:self.artist forKey:@"artist"];
}

- (BOOL)isEqual:(id)object {
if (![object isKindOfClass:[self class]]) {
return NO;
}
Artwork *compare = object;
return [compare.artworkUrl isEqual:self.artworkUrl];
}

@end
14 changes: 14 additions & 0 deletions MusaicFM/Constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Constants.h
// MusaicFM
//
// Created by Dennis Oberhoff on 20/11/2016.
// Copyright © 2016 Dennis Oberhoff. All rights reserved.
//

#import <Foundation/Foundation.h>

extern NSString *const spotifyClientId;
extern NSString *const spotifySecretId;
extern NSString *const spotifyRedirectUrl;
extern NSString *const lastFmId;
14 changes: 14 additions & 0 deletions MusaicFM/Constants.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Constants.m
// MusaicFM
//
// Created by Dennis Oberhoff on 20/11/2016.
// Copyright © 2016 Dennis Oberhoff. All rights reserved.
//

#import "Constants.h"

NSString *const spotifyClientId = @"465423dcfdca4d8f8213181e9e5e3fa4";
NSString *const spotifySecretId = @"8330d56673864353ac187b5b29532f06";
NSString *const spotifyRedirectUrl = @"musaicfm://spotify";
NSString *const lastFmId = @"b61d847786cc5f854207a51afd77b01f";
20 changes: 20 additions & 0 deletions MusaicFM/Factory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// Factory.h
// MusaicFM
//
// Created by Dennis Oberhoff on 03/12/2016.
// Copyright © 2016 Dennis Oberhoff. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface Factory : NSObject

+ (NSURLRequest *)lastFmRequest:(NSArray *)queryItems;

+ (NSURLComponents *)spotifyAlbums;
+ (NSURLComponents *)spotifyNewReleases;
+ (NSURLComponents *)spotifyToken;
+ (NSURLComponents *)spotifyAuthentification;

@end
69 changes: 69 additions & 0 deletions MusaicFM/Factory.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// Factory.m
// MusaicFM
//
// Created by Dennis Oberhoff on 03/12/2016.
// Copyright © 2016 Dennis Oberhoff. All rights reserved.
//

#import "Factory.h"
#import "Constants.h"

@implementation Factory


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

[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 *)spotifyAlbums {
NSURLComponents *components = [NSURLComponents new];
components.scheme = @"https";
components.host = @"api.spotify.com";
components.path = @"/v1/me/albums";
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 *)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]];

return components;
}

@end
26 changes: 26 additions & 0 deletions MusaicFM/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Dennis Oberhoff. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string>MusaicFMView</string>
</dict>
</plist>
33 changes: 33 additions & 0 deletions MusaicFM/Manager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Manager.h
// MusaicFM
//
// Created by Dennis Oberhoff on 13/11/2016.
// Copyright © 2016 Dennis Oberhoff. All rights reserved.
//

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

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

@interface Manager : NSObject

@property (nonatomic, readwrite, strong)Preferences * preferences;


- (void)performSpotifyUserAlbums:(void (^)(NSArray *items)) completion andFailure:(void (^)(NSError *error))failure;
- (void)performSpotifyReleases:(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

0 comments on commit fcd2c5e

Please sign in to comment.