Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Oberhoff authored and Dennis Oberhoff committed Dec 15, 2016
0 parents commit 94bb310
Show file tree
Hide file tree
Showing 131 changed files with 10,263 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xcuserstate

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md

fastlane/report.xml
fastlane/screenshots

#Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
.DS_Store
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 John Coates

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
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 = @"";
NSString *const spotifySecretId = @"";
NSString *const spotifyRedirectUrl = @"musaicfm://spotify";
NSString *const lastFmId = @"";
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 94bb310

Please sign in to comment.