Skip to content

Commit

Permalink
Merge pull request #49 from skiptomyliu/2022-08-11
Browse files Browse the repository at this point in the history
Re-support Pandora Premium and bug fix long pause
  • Loading branch information
skiptomyliu authored Aug 14, 2022
2 parents dea1faa + 5356e88 commit 5e1d9c8
Show file tree
Hide file tree
Showing 22 changed files with 238 additions and 223 deletions.
Binary file modified App/Milkshake.dmg
Binary file not shown.
18 changes: 15 additions & 3 deletions Milkshake.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
05D3421028A34D620039D620 /* Crypt.m in Sources */ = {isa = PBXBuildFile; fileRef = 05D3420F28A34D620039D620 /* Crypt.m */; };
05D4F5EE217CEC4A00283085 /* milkshake.icns in Resources */ = {isa = PBXBuildFile; fileRef = 05D4F5ED217CEC4900283085 /* milkshake.icns */; };
05D4F5F0217CEE5100283085 /* milkshake_512x512.png in Resources */ = {isa = PBXBuildFile; fileRef = 05D4F5EF217CEE5100283085 /* milkshake_512x512.png */; };
05E1929928A71DCE00E81970 /* VolumeSliderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05E1929828A71DCE00E81970 /* VolumeSliderCell.swift */; };
05ED20D51FCCFA4F00123317 /* API.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05ED20D41FCCFA4F00123317 /* API.swift */; };
05ED20DF1FCD10B000123317 /* playing.gif in Resources */ = {isa = PBXBuildFile; fileRef = 05ED20DC1FCD10B000123317 /* playing.gif */; };
05ED20E21FCD125C00123317 /* ResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05ED20E01FCD125C00123317 /* ResultsViewController.swift */; };
Expand Down Expand Up @@ -145,6 +146,7 @@
05D3421128A34D840039D620 /* Crypt.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Crypt.h; sourceTree = "<group>"; };
05D4F5ED217CEC4900283085 /* milkshake.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = milkshake.icns; sourceTree = "<group>"; };
05D4F5EF217CEE5100283085 /* milkshake_512x512.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = milkshake_512x512.png; sourceTree = "<group>"; };
05E1929828A71DCE00E81970 /* VolumeSliderCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VolumeSliderCell.swift; sourceTree = "<group>"; };
05ED20D41FCCFA4F00123317 /* API.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = API.swift; sourceTree = "<group>"; };
05ED20DC1FCD10B000123317 /* playing.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = playing.gif; sourceTree = "<group>"; };
05ED20E01FCD125C00123317 /* ResultsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResultsViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -323,6 +325,7 @@
05ED20E61FCD2FBD00123317 /* SearchTableCellView.swift */,
05ED20E81FCD2FE200123317 /* SearchTableCellView.xib */,
059A061F200DC7ED003C81F1 /* SpectrumAnalyzerView.swift */,
05E1929828A71DCE00E81970 /* VolumeSliderCell.swift */,
);
name = views;
sourceTree = "<group>";
Expand Down Expand Up @@ -395,7 +398,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0810;
LastUpgradeCheck = 0910;
LastUpgradeCheck = 1250;
ORGANIZATIONNAME = "Dean Liu";
TargetAttributes = {
48F749421FCCEBD000F0A853 = {
Expand Down Expand Up @@ -545,6 +548,7 @@
054A31171FF5D5B10022D06E /* HeaderTableCellView.swift in Sources */,
05ED21131FD6ED8F00123317 /* MusicItem.swift in Sources */,
05A57E692010E90F00B8FBCB /* NSBezierPath+CGPath.swift in Sources */,
05E1929928A71DCE00E81970 /* VolumeSliderCell.swift in Sources */,
48F749491FCCEBD000F0A853 /* MainViewController.swift in Sources */,
054130351FE01EBA0067DCFE /* PlayerButton.swift in Sources */,
48F749581FCCECBD00F0A853 /* RoundView.swift in Sources */,
Expand Down Expand Up @@ -605,6 +609,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand All @@ -614,15 +619,18 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -661,6 +669,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand All @@ -670,15 +679,18 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -715,7 +727,7 @@
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = S9FKV88H43;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = Milkshake/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
Expand All @@ -739,7 +751,7 @@
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = S9FKV88H43;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = Milkshake/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0910"
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,95 +7,76 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "9FA24512-758E-48DC-97BA-E2B973F825CD"
uuid = "13ED5B57-6F02-47DE-BE55-3E3D9B570A79"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Milkshake/API.swift"
timestampString = "681811592.794281"
timestampString = "681811592.795244"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "103"
endingLineNumber = "103"
landmarkName = "request(_:params:callbackHandler:)"
startingLineNumber = "184"
endingLineNumber = "184"
landmarkName = "_partnerAuthUserLogin(username:password:partnerAuthToken:partnerId:syncTime:callbackHandler:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
BreakpointExtensionID = "Xcode.Breakpoint.RuntimeIssueBreakpoint">
<BreakpointContent
uuid = "532C079F-CB08-459F-A49D-F6887A763BED"
shouldBeEnabled = "No"
uuid = "6C47B28C-DB93-4FB2-A7EE-6559D20A7CB2"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Milkshake/API.swift"
timestampString = "681811592.794768"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "150"
endingLineNumber = "150"
landmarkName = "auth(username:pass:callbackHandler:)"
landmarkType = "7">
breakpointStackSelectionBehavior = "1"
type = "4">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "13ED5B57-6F02-47DE-BE55-3E3D9B570A79"
uuid = "BDF4016D-5ABA-457D-9D74-6D8F7A7F7197"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Milkshake/API.swift"
timestampString = "681811592.795244"
filePath = "Milkshake/SearchTableCellView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "193"
endingLineNumber = "193"
landmarkName = "partnerAuthUserLogin(username:password:partnerAuthToken:partnerId:syncTime:callbackHandler:)"
startingLineNumber = "152"
endingLineNumber = "152"
landmarkName = "setCellWithSearchResult(result:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "B11F9EBD-A194-4B01-BF47-F7BA775E7C6D"
uuid = "124704E2-BEF9-4CED-A107-4FD1C49AEF66"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Milkshake/LoginViewController.swift"
timestampString = "681804855.496473"
filePath = "Milkshake/AppDelegate.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "63"
endingLineNumber = "63"
landmarkName = "callbackPartnerAuthUserLogin(results:)"
startingLineNumber = "253"
endingLineNumber = "253"
landmarkName = "handleSuccessLogin(results:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.RuntimeIssueBreakpoint">
<BreakpointContent
uuid = "6C47B28C-DB93-4FB2-A7EE-6559D20A7CB2"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
breakpointStackSelectionBehavior = "1"
type = "4">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "BDF4016D-5ABA-457D-9D74-6D8F7A7F7197"
uuid = "7ACBECDD-E24A-4F93-A99A-6BDB9B4CDC32"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Milkshake/SearchTableCellView.swift"
filePath = "Milkshake/Util.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "152"
endingLineNumber = "152"
landmarkName = "setCellWithSearchResult(result:)"
startingLineNumber = "558"
endingLineNumber = "558"
landmarkName = "parseArtistIntoItems(artistResults:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
Expand Down
49 changes: 23 additions & 26 deletions Milkshake/API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,17 @@ class API: NSObject {
}
let rv = responseValue as! [String: AnyObject]

if (rv["errorCode"] as? Int) == 1001 {
if (rv["errorCode"] as? Int ?? 0) == 1001 {
print("Token needs to be refreshed!!")
self.X_AuthToken = ""

if let dictionary = Locksmith.loadDataForUserAccount(userAccount: "Milkshake") {
let username = dictionary["username"] as! String
let password = dictionary["password"] as! String
self.auth(username: username, pass: password) { responseDict in
self.X_AuthToken = responseDict["authToken"] as? String;

self.authPartnerAndUser(username: username, password: password) { responseDict in
self.X_AuthToken = responseDict["result"]!["userAuthToken"] as? String;

// Clear the station queues because they're all expired
if url.hasSuffix("annotateObjectsSimple") {
print("Clearing out... trying again")
Expand Down Expand Up @@ -141,30 +143,19 @@ class API: NSObject {
print(self.cookies)
}


func auth(username:String, pass:String, callbackHandler:@escaping(_ Dictionary:[String:AnyObject]) -> ()) {
let parameters: [String: Any] = [
"existingAuthToken": "",
"username": username,
"password": pass,
"keepLoggedIn": NSNumber(value: true)
]
let url: String = "\(Constants.pandoraApiUrlV1)/auth/login"
self.request(url, params: parameters, callbackHandler: callbackHandler)
}

func auth(username:String, token:String, callbackHandler:@escaping(_ Dictionary:[String:AnyObject]) -> ()) {
let params: [String: Any] = [
"existingAuthToken": token,
"username": username,
"password": "",
"keepLoggedIn": true
]
let url: String = "\(Constants.pandoraApiUrlV1)/auth/login"
self.request(url, params: params, callbackHandler: callbackHandler)
func authPartnerAndUser(username:String, password:String, callbackHandler:@escaping(_ Dictionary:[String:AnyObject]) ->()){

self._partnerAuthPartnerLogin() { responseDict in
let partnerAuthToken = responseDict["result"]!["partnerAuthToken"] as! String
let partnerId = responseDict["result"]!["partnerId"] as! String
let syncTimeEnc = responseDict["result"]!["syncTime"] as! String
let syncTime = PandoraDecryptTime(syncTimeEnc, Constants.decryptPassword)

self._partnerAuthUserLogin(username: username, password: password, partnerAuthToken: partnerAuthToken, partnerId: partnerId, syncTime: syncTime, callbackHandler: callbackHandler)
}
}

func partnerAuthPartnerLogin(callbackHandler:@escaping(_ Dictionary:[String:AnyObject]) ->()){
func _partnerAuthPartnerLogin(callbackHandler:@escaping(_ Dictionary:[String:AnyObject]) ->()){
let params: [String: String] = [
"username": Constants.username,
"password": Constants.password,
Expand All @@ -176,7 +167,7 @@ class API: NSObject {
self.requestTuner(url, params: params, encrypted: false, callbackHandler: callbackHandler)
}

func partnerAuthUserLogin(username:String, password:String, partnerAuthToken:String, partnerId:String, syncTime:Int, callbackHandler:@escaping(_ Dictionary:[String:AnyObject]) ->()){
func _partnerAuthUserLogin(username:String, password:String, partnerAuthToken:String, partnerId:String, syncTime:Int, callbackHandler:@escaping(_ Dictionary:[String:AnyObject]) ->()){
let params: [String: Any] = [
"loginType": "user",
"username": username,
Expand All @@ -194,6 +185,12 @@ class API: NSObject {
self.requestTuner(urlParams.url!.absoluteString, params: params, encrypted: true, callbackHandler: callbackHandler)
}

func billingInfo(callbackHandler:@escaping(_ Dictionary:[String:AnyObject]) -> ()) {
let url: String = "\(Constants.pandoraApiUrlV1)/billing/infoV2"
let params: [String: Any] = [:]
self.request(url, params: params, callbackHandler: callbackHandler)
}

func playbackResumed(forceActive:Bool, callbackHandler:@escaping(_ Dictionary:[String:AnyObject]) -> ()) {
let params: [String: Any] = [
"forceActive": true
Expand Down
22 changes: 11 additions & 11 deletions Milkshake/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,20 +244,20 @@ class AppDelegate: NSObject, NSApplicationDelegate, LoginProtocol {
func handleSuccessLogin(results: Dictionary<String, AnyObject>) {
let authToken = results["userAuthToken"] as! String
self.listenerId = results["userId"] as! String
// self.isPremium = (config["branding"] as! String).lowercased() == "pandorapremium"
// self.listenerId = results["listenerId"] as! String

if self.isPremium == false {
self.menuArtists.isHidden = true
self.menuPlaylist.isHidden = true
}
// Setting

let defaults = UserDefaults.standard
defaults.set(authToken, forKey: "authToken")
self.api.X_AuthToken = authToken
print ("x auth token....")
print(self.api.X_AuthToken!)
self.launchMain()

self.api.billingInfo() { results in
self.isPremium = ((results["activeProduct"]?["productTier"] as? String) ?? "").lowercased() == "pandora_premium"
if self.isPremium == false {
self.menuArtists.isHidden = true
self.menuPlaylist.isHidden = true
self.menuShuffle.isHidden = true
}
self.launchMain()
}
}

func isRadio() -> Bool {
Expand Down
Loading

0 comments on commit 5e1d9c8

Please sign in to comment.