~ knotless Search/
↑↓ move↵ open⇧↵ all results

geesawra.industries/hydraulophone

An unofficial YouTube Music app for iPhone, iPad, and Mac.

0
0
main
111 lines · 3.4 KB Raw History
import Foundation

// Client identities and the bounded order below are adapted from AuraMusic
// (GPL-3.0), TeamAuraMusic/AuraMusic @
// 185a77d31733047de06cbec619d40731755a0ec1. This Swift file does not copy
// Kotlin implementation text; see docs/protocol/innertube-aura-port.md.

/// The finite, AuraMusic-derived profile order used when resolving direct
/// audio. These are client identities, not a general-purpose fallback pool.
public enum InnerTubePlaybackProfiles {
  public static func resolutionOrder(
    webConfiguration: MusicWebConfiguration,
    supportsStreamCipher: Bool = false
  ) -> [InnerTubeClientProfile] {
    let profiles = [
      visionOS,
      androidVR165,
      androidVRNoAuth,
      iPadOS,
      .webRemix(from: webConfiguration),
      androidNoSDK,
      androidGuest,
    ]
    guard supportsStreamCipher else {
      return profiles
    }
    guard
      let webIndex = profiles.firstIndex(where: {
        $0.clientName == webConfiguration.clientName
          && $0.clientVersion == webConfiguration.clientVersion
          && $0.clientID == webConfiguration.clientID
      })
    else {
      return profiles
    }
    let webProfile = profiles[webIndex]
    return [webProfile]
      + profiles.enumerated().compactMap { index, profile in
        index == webIndex ? nil : profile
      }
  }

  public static let visionOS = InnerTubeClientProfile(
    clientName: "VISIONOS",
    clientVersion: "0.1",
    clientID: "101",
    userAgent:
      "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 "
      + "(KHTML, like Gecko) Version/18.0 Safari/605.1.15",
    osName: "visionOS",
    osVersion: "1.3.21O771",
    deviceMake: "Apple",
    deviceModel: "RealityDevice14,1"
  )

  public static let androidVR165 = InnerTubeClientProfile(
    clientName: "ANDROID_VR",
    clientVersion: "1.65.10",
    clientID: "28",
    userAgent:
      "com.google.android.apps.youtube.vr.oculus/1.65.10 "
      + "(Linux; U; Android 12L; eureka-user Build/SQ3A.220605.009.A1) gzip",
    osName: "Android",
    osVersion: "12L",
    deviceMake: "Oculus",
    deviceModel: "Quest 3",
    androidSDKVersion: "32"
  )

  public static let androidVRNoAuth = InnerTubeClientProfile(
    clientName: "ANDROID_VR",
    clientVersion: "1.61.48",
    clientID: "28",
    userAgent:
      "com.google.android.apps.youtube.vr.oculus/1.61.48 "
      + "(Linux; U; Android 12; en_US; Oculus Quest 3; "
      + "Build/SQ3A.220605.009.A1; Cronet/132.0.6808.3)"
  )

  public static let iPadOS = InnerTubeClientProfile(
    clientName: "IOS",
    clientVersion: "21.03.3",
    clientID: "5",
    userAgent:
      "com.google.ios.youtube/21.03.3 "
      + "(iPad7,6; U; CPU iPadOS 17_7_10 like Mac OS X; en-US)",
    osName: "iPadOS",
    osVersion: "17.7.10.21H450",
    deviceMake: "Apple",
    deviceModel: "iPad7,6"
  )

  public static let androidNoSDK = InnerTubeClientProfile(
    clientName: "ANDROID",
    clientVersion: "21.03.38",
    clientID: "3",
    userAgent:
      "com.google.android.youtube/21.03.38 (Linux; U; Android 14) gzip"
  )

  /// AuraMusic's final Android candidate is sent as an explicitly anonymous
  /// request by its resolver. Keeping loginSupported false here makes that
  /// credential boundary structural in Hydraulophone as well.
  public static let androidGuest = InnerTubeClientProfile(
    clientName: "ANDROID",
    clientVersion: "21.03.38",
    clientID: "3",
    userAgent:
      "com.google.android.youtube/21.03.38 (Linux; U; Android 14) gzip"
  )
}