- guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
- let params = components.queryItems else {
- return nil
- }
+ guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
+ let params = components.queryItems
+ else {
+ return nil
+ }
+
+ var paramsDict = [String: Any]()
+
+ params.forEach { item in
+ paramsDict[item.name] = item.value
+ }
+
+ guard let action = paramsDict["action"] as? String else {
+ return nil
+ }
- var paramsDict = [String: Any]()
+ switch action {
+ case "configure":
+ var fps = Int(paramsDict["fps"] as? String ?? "")
+ let backend = URL(string: paramsDict["backend"] as? String ?? "")
+ let keepLocalFiles = Bool(paramsDict["keep_local_files"] as? String ?? "")
+ let outputs = OutputFormatSetting(paramsDict["outputs"] as? String ?? "")
+ var backendOutput = OutputFormatSetting(paramsDict["backend_output"] as? String ?? "")
- switch action {
- case "configure":
- var fps = Int(paramsDict["fps"] as? String ?? "")
- let backend = URL(string: paramsDict["backend"] as? String ?? "")
- let keepLocalFiles = Bool(paramsDict["keep_local_files"] as? String ?? "")
- let outputs = OutputFormatSetting(paramsDict["outputs"] as? String ?? "")
- var backendOutput = OutputFormatSetting(paramsDict["backend_output"] as? String ?? "")
-
- if fps != nil {
- fps = min(10, max(4, fps!))
- }
-
- if backendOutput == .all {
- backendOutput = .gifOnly
- }
-
- return .configure(ConfigureAction(
+ return .configure(
+ ConfigureAction(
- case "record":
- let x = Int(paramsDict["x"] as? String ?? "")
- let y = Int(paramsDict["y"] as? String ?? "")
- let width = Int(paramsDict["width"] as? String ?? "")
- let height = Int(paramsDict["height"] as? String ?? "")
- let preventResize = Bool(paramsDict["prevent_resize"] as? String ?? "")
- let preventMove = Bool(paramsDict["prevent_move"] as? String ?? "")
- var fps = Int(paramsDict["fps"] as? String ?? "")
- let backend = URL(string: paramsDict["backend"] as? String ?? "")
- let keepLocalFiles = Bool(paramsDict["keep_local_files"] as? String ?? "")
- let outputs = OutputFormatSetting(paramsDict["outputs"] as? String ?? "")
- var backendOutput = OutputFormatSetting(paramsDict["backend_output"] as? String ?? "")
- let autoStart = Bool(paramsDict["auto_start"] as? String ?? "")
- var maxLength = Int(paramsDict["max_length"] as? String ?? "")
-
- if fps != nil {
- fps = min(10, max(4, fps!))
- }
-
- if maxLength != nil {
- maxLength = min(300, max(1, fps!))
- }
-
- if backendOutput == .all {
- backendOutput = .gifOnly
- }
-
- var skipBackend = false
- if let backendString = paramsDict["backend"] as? String {
- if backendString == "" {
- skipBackend = true
- }
+ case "record":
+ let x = Int(paramsDict["x"] as? String ?? "")
+ let y = Int(paramsDict["y"] as? String ?? "")
+ let width = Int(paramsDict["width"] as? String ?? "")
+ let height = Int(paramsDict["height"] as? String ?? "")
+ let preventResize = Bool(paramsDict["prevent_resize"] as? String ?? "")
+ let preventMove = Bool(paramsDict["prevent_move"] as? String ?? "")
+ var fps = Int(paramsDict["fps"] as? String ?? "")
+ let backend = URL(string: paramsDict["backend"] as? String ?? "")
+ let keepLocalFiles = Bool(paramsDict["keep_local_files"] as? String ?? "")
+ let outputs = OutputFormatSetting(paramsDict["outputs"] as? String ?? "")
+ var backendOutput = OutputFormatSetting(paramsDict["backend_output"] as? String ?? "")
+ let autoStart = Bool(paramsDict["auto_start"] as? String ?? "")
+ var maxLength = Int(paramsDict["max_length"] as? String ?? "")
+
+ if fps != nil {
+ fps = min(10, max(4, fps!))
+ }
+
+ if maxLength != nil {
+ maxLength = min(300, max(1, fps!))
+ }
+
+ if backendOutput == .all {
+ backendOutput = .gifOnly
+ }
+
+ var skipBackend = false
+ if let backendString = paramsDict["backend"] as? String {
+ if backendString == "" {
+ skipBackend = true