Skip to content

Commit

Permalink
Merge pull request #22 from ddhhz/bugfix
Browse files Browse the repository at this point in the history
Looks good. Thanks
  • Loading branch information
AnakinMac authored Dec 22, 2017
2 parents c23c13b + 916a188 commit 0077caf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 6 additions & 4 deletions diumoo/core/DMControlCenter/DMControlCenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@ - (void)startToPlay:(DMPlayableItem*)aSong

[self play];
[playingItem prepareCoverWithCallbackBlock:^(NSImage* image) {
[diumooPanel setRated:playingItem.like];
[diumooPanel setPlayingItem:playingItem];
[notificationCenter notifyMusicPlaybackWithItem:playingItem];
[recordHandler addRecordWithItem:playingItem];
[DMService performOnMainQueue:^{
[diumooPanel setRated:playingItem.like];
[diumooPanel setPlayingItem:playingItem];
[notificationCenter notifyMusicPlaybackWithItem:playingItem];
[recordHandler addRecordWithItem:playingItem];
}];
}];
}
pauseType = PAUSE_PASS;
Expand Down
10 changes: 5 additions & 5 deletions diumoo/core/DMPlaylistFetcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ public class DMPlaylistFetcher : NSObject{
let urlRequest = URLRequest.init(url: URL.init(string: urlString)!, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 20.0)

// Processing cookie
let validAttr = (attribute != nil) ? attribute : ""
let validAttr = attribute ?? ""
let cookie = HTTPCookie.init(properties: [HTTPCookiePropertyKey.domain: "douban.fm",
HTTPCookiePropertyKey.name: "start",
HTTPCookiePropertyKey.value: validAttr!,
HTTPCookiePropertyKey.value: validAttr,
HTTPCookiePropertyKey.discard: true,
HTTPCookiePropertyKey.path:"/"])

HTTPCookieStorage.shared.setCookie(cookie!)

let session = URLSession.shared.dataTask(with: urlRequest) { data, response, error in
if error != nil {
self.delegate?.fetchPlaylist(WithDictionary: dict, startAttribute: attribute!, errorThreshould: errCount + 1)
self.delegate?.fetchPlaylist(WithDictionary: dict, startAttribute: validAttr, errorThreshould: errCount + 1)
} else {
do {
let jResponse = try JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers)
Expand All @@ -103,7 +103,7 @@ public class DMPlaylistFetcher : NSObject{

// Something's wrong
if jrVal != 0 {
self.delegate?.fetchPlaylist(WithDictionary: dict, startAttribute: attribute!, errorThreshould: errCount + 1)
self.delegate?.fetchPlaylist(WithDictionary: dict, startAttribute: validAttr, errorThreshould: errCount + 1)
} else {
let jList = jDict["song"] as? Array<Dictionary<String, AnyObject>>
if attribute != nil {
Expand All @@ -120,7 +120,7 @@ public class DMPlaylistFetcher : NSObject{
}
}
} catch _ {
self.delegate?.fetchPlaylist(WithDictionary: dict, startAttribute: attribute!, errorThreshould: errCount + 1)
self.delegate?.fetchPlaylist(WithDictionary: dict, startAttribute: validAttr, errorThreshould: errCount + 1)
}
}
}
Expand Down

0 comments on commit 0077caf

Please sign in to comment.