File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree File renamed without changes.
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments