Skip to content

Commit 727fd66

Browse files
committed
remove siri play-as-radio restriction
1 parent 58fe124 commit 727fd66

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Sources/EeveeSpotify/Models/Extensions/StirngArray+Extension.swift renamed to Sources/EeveeSpotify/Models/Extensions/StringArray+Extension.swift

File renamed without changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Orion
2+
import Intents
3+
4+
class INMediaItemHook: ClassHook<INMediaItem> {
5+
func identifier() -> String {
6+
var identifier = orig.identifier()
7+
8+
if identifier.contains("play-command") {
9+
let components = identifier.components(separatedBy: ":")
10+
let jsonData = Data(base64Encoded: components[2])!
11+
var json = try! JSONSerialization.jsonObject(with: jsonData) as! [String: Any]
12+
13+
if let feedbackDetails = json["feedback_details"] as? [String: Any],
14+
feedbackDetails["restriction"] as? String == "play-as-radio" {
15+
var context = json["context"] as! [String: Any]
16+
17+
let urlString = context["url"] as! String
18+
context["url"] = urlString.removeMatches(":station")
19+
20+
json["context"] = context
21+
22+
let newData = try! JSONSerialization.data(withJSONObject: json)
23+
identifier = "spotify:play-command:\(newData.base64EncodedString())"
24+
}
25+
}
26+
27+
return identifier
28+
}
29+
}

0 commit comments

Comments
 (0)