frosty/ios/Runner/CookieExtractorPlugin.swift
Tommy Chow 1779520db8 use forked plugin for seamless quality switching, add latency tracking and cookie auth
Switch to forked better_native_video_player that uses preferredPeakBitRate
instead of replaceCurrentItem for seamless quality transitions without
black flash. Fork also adds configureForLivePlayback and getLatencyToLive
APIs for low-latency tuning and HLS program date-time based latency.

Add latency polling (10s interval) with auto-sync chat delay support.
Only update syncedChatDelay on >2s drift to avoid restarting countdown.

Add cookie extraction from WKWebView login session for ad-free GQL
playback. The auth-token cookie works with the web Client-ID per
Streamlink's approach. Extract at login, persist to secure storage,
and attempt fresh extraction on init for existing logged-in users.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 22:34:05 -07:00

26 lines
924 B
Swift

import Flutter
import WebKit
class CookieExtractorPlugin: NSObject, FlutterPlugin {
static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(
name: "frosty/cookie_extractor",
binaryMessenger: registrar.messenger()
)
let instance = CookieExtractorPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
if call.method == "extractTwitchAuthToken" {
WKWebsiteDataStore.default().httpCookieStore.getAllCookies { cookies in
let authCookie = cookies.first {
$0.name == "auth-token" && $0.domain.contains("twitch.tv")
}
result(authCookie?.value)
}
} else {
result(FlutterMethodNotImplemented)
}
}
}