Add App Intents for Shortcuts and Siri

Play Video, Add Video to Queue, Download Video, Bookmark Video, Subscribe
to / Unsubscribe from Channel, Control Player, Seek, Set Playback Speed,
Get Now Playing, Open Section and Search Videos. Each runs the same
LinkAction as the matching yattee:// link through LinkActionPerformer,
without the confirmation sheet (the person built the shortcut). Failures
surface their message in Shortcuts.

App Shortcuts: control player, now playing, open section, search.
This commit is contained in:
Arkadiusz Fal
2026-10-06 08:05:54 +02:00
parent c579ee63a2
commit 2fa3027a42
3 changed files with 469 additions and 6 deletions

View File

@@ -151,14 +151,16 @@ struct LinkActionParser {
private static func targetURL(_ raw: String) -> URL? {
// A raw link keeps its percent-escapes; an encoded one is decoded once.
let string = raw.contains("://") ? raw : (raw.removingPercentEncoding ?? raw)
guard let url = URL(string: string),
let scheme = url.scheme?.lowercased(),
["http", "https", "yattee"].contains(scheme) else {
return nil
}
guard let url = URL(string: string), isAllowedTarget(url) else { return nil }
return url
}
/// Links actions may act on: web links and yattee:// screen links.
static func isAllowedTarget(_ url: URL) -> Bool {
guard let scheme = url.scheme?.lowercased() else { return false }
return ["http", "https", "yattee"].contains(scheme)
}
/// Splits the query on `&`, but keeps an unencoded `url=` value whole:
/// it runs until the next parameter the action itself defines.
static func queryParameters(of url: URL) -> [String: String] {

View File

@@ -11,6 +11,10 @@ import Foundation
@MainActor
struct LinkActionPerformer {
let appEnvironment: AppEnvironment
/// Whether state-changing actions show the confirmation sheet (subject to
/// the user's setting). Off for App Intents: the person built the shortcut
/// themselves, so no web page can run it behind their back.
var asksBeforeChanges = true
func perform(_ action: LinkAction) async -> LinkActionResult {
LoggingService.shared.info("Link action: \(action)", category: .general)
@@ -306,7 +310,7 @@ struct LinkActionPerformer {
/// Asks first unless the user lets automation links change things on their own.
private func confirm(title: String, subject: String?, detail: String?, confirmTitle: String, systemImage: String) async -> Bool {
guard !appEnvironment.settingsManager.linkActionsRunWithoutConfirmation else { return true }
guard asksBeforeChanges, !appEnvironment.settingsManager.linkActionsRunWithoutConfirmation else { return true }
let confirmation = LinkActionConfirmation(
title: title,
subject: subject,