Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
import AVFoundation
|
2021-10-17 04:18:58 +05:30
|
|
|
import Foundation
|
|
|
|
import Siesta
|
2021-10-19 03:23:02 +05:30
|
|
|
import SwiftUI
|
2021-10-17 04:18:58 +05:30
|
|
|
|
|
|
|
extension PlayerModel {
|
|
|
|
var isLoadingAvailableStreams: Bool {
|
|
|
|
streamSelection.isNil || availableStreams.isEmpty
|
|
|
|
}
|
|
|
|
|
|
|
|
var isLoadingStream: Bool {
|
|
|
|
!stream.isNil && stream != streamSelection
|
|
|
|
}
|
|
|
|
|
2021-10-18 03:19:56 +05:30
|
|
|
var availableStreamsSorted: [Stream] {
|
|
|
|
availableStreams.sorted(by: streamsSorter)
|
|
|
|
}
|
|
|
|
|
2022-12-18 17:41:06 +05:30
|
|
|
func loadAvailableStreams(_ video: Video, onCompletion: @escaping (ResponseInfo) -> Void = { _ in }) {
|
2022-12-22 01:46:47 +05:30
|
|
|
captions = nil
|
2021-10-17 04:18:58 +05:30
|
|
|
availableStreams = []
|
2021-12-19 22:26:47 +05:30
|
|
|
|
2022-09-28 19:57:01 +05:30
|
|
|
guard let playerInstance else { return }
|
2021-10-17 04:18:58 +05:30
|
|
|
|
2022-12-21 22:43:41 +05:30
|
|
|
guard let api = playerAPI(video) else { return }
|
2022-06-18 18:09:49 +05:30
|
|
|
logger.info("loading streams from \(playerInstance.description)")
|
2022-12-21 22:43:41 +05:30
|
|
|
fetchStreams(api.video(video.videoID), instance: playerInstance, video: video, onCompletion: onCompletion)
|
2021-10-17 04:18:58 +05:30
|
|
|
}
|
|
|
|
|
2021-10-21 03:51:50 +05:30
|
|
|
private func fetchStreams(
|
|
|
|
_ resource: Resource,
|
|
|
|
instance: Instance,
|
2021-10-17 04:18:58 +05:30
|
|
|
video: Video,
|
|
|
|
onCompletion: @escaping (ResponseInfo) -> Void = { _ in }
|
|
|
|
) {
|
2021-10-21 03:51:50 +05:30
|
|
|
resource
|
2021-10-17 04:18:58 +05:30
|
|
|
.load()
|
|
|
|
.onSuccess { response in
|
|
|
|
if let video: Video = response.typedContent() {
|
2022-12-10 05:53:13 +05:30
|
|
|
VideosCacheModel.shared.storeVideo(video)
|
2022-11-12 01:04:37 +05:30
|
|
|
guard video.videoID == self.currentVideo?.videoID else {
|
2021-12-30 00:25:41 +05:30
|
|
|
self.logger.info("ignoring loaded streams from \(instance.description) as current video has changed")
|
|
|
|
return
|
|
|
|
}
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
self.streamsWithInstance(instance: instance, streams: video.streams) { processedStreams in
|
|
|
|
self.availableStreams = processedStreams
|
|
|
|
}
|
2021-12-19 22:26:47 +05:30
|
|
|
} else {
|
|
|
|
self.logger.critical("no streams available from \(instance.description)")
|
2021-10-17 04:18:58 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
.onCompletion(onCompletion)
|
2022-06-30 04:14:32 +05:30
|
|
|
.onFailure { [weak self] responseError in
|
|
|
|
self?.navigation.presentAlert(title: "Could not load streams", message: responseError.userMessage)
|
|
|
|
self?.videoBeingOpened = nil
|
|
|
|
}
|
2021-10-17 04:18:58 +05:30
|
|
|
}
|
|
|
|
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
func streamsWithInstance(instance _: Instance, streams: [Stream], completion: @escaping ([Stream]) -> Void) {
|
2024-05-17 18:59:42 +05:30
|
|
|
// Queue for stream processing
|
|
|
|
let streamProcessingQueue = DispatchQueue(label: "stream.yattee.streamProcessing.Queue", qos: .userInitiated)
|
|
|
|
// Queue for accessing the processedStreams array
|
|
|
|
let processedStreamsQueue = DispatchQueue(label: "stream.yattee.processedStreams.Queue")
|
|
|
|
// DispatchGroup for managing multiple tasks
|
|
|
|
let streamProcessingGroup = DispatchGroup()
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
|
2024-05-17 18:59:42 +05:30
|
|
|
var processedStreams = [Stream]()
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
|
2024-05-17 18:59:42 +05:30
|
|
|
for stream in streams {
|
|
|
|
streamProcessingQueue.async(group: streamProcessingGroup) {
|
|
|
|
let forbiddenAssetTestGroup = DispatchGroup()
|
|
|
|
var hasForbiddenAsset = false
|
|
|
|
|
|
|
|
let (nonHLSAssets, hlsURLs) = self.getAssets(from: [stream])
|
|
|
|
|
|
|
|
if let randomStream = nonHLSAssets.randomElement() {
|
|
|
|
let instance = randomStream.0
|
|
|
|
let asset = randomStream.1
|
|
|
|
let url = randomStream.2
|
|
|
|
let requestRange = randomStream.3
|
|
|
|
|
|
|
|
// swiftlint:disable:next shorthand_optional_binding
|
|
|
|
if let asset = asset, let instance = instance, !instance.proxiesVideos {
|
|
|
|
if instance.app == .invidious {
|
|
|
|
self.testAsset(url: url, range: requestRange, isHLS: false, forbiddenAssetTestGroup: forbiddenAssetTestGroup) { isForbidden in
|
|
|
|
hasForbiddenAsset = isForbidden
|
|
|
|
}
|
|
|
|
} else if instance.app == .piped {
|
|
|
|
self.testPipedAssets(asset: asset, requestRange: requestRange, isHLS: false, forbiddenAssetTestGroup: forbiddenAssetTestGroup) { isForbidden in
|
|
|
|
hasForbiddenAsset = isForbidden
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if let randomHLS = hlsURLs.randomElement() {
|
|
|
|
let instance = randomHLS.0
|
|
|
|
let asset = AVURLAsset(url: randomHLS.1)
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
|
2024-05-17 18:59:42 +05:30
|
|
|
if instance?.app == .piped {
|
|
|
|
self.testPipedAssets(asset: asset, requestRange: nil, isHLS: true, forbiddenAssetTestGroup: forbiddenAssetTestGroup) { isForbidden in
|
|
|
|
hasForbiddenAsset = isForbidden
|
|
|
|
}
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-17 18:59:42 +05:30
|
|
|
forbiddenAssetTestGroup.wait()
|
|
|
|
|
|
|
|
// Post-processing code
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
if let instance = stream.instance {
|
|
|
|
if instance.app == .invidious {
|
|
|
|
if hasForbiddenAsset || instance.proxiesVideos {
|
|
|
|
if let audio = stream.audioAsset {
|
|
|
|
stream.audioAsset = InvidiousAPI.proxiedAsset(instance: instance, asset: audio)
|
|
|
|
}
|
|
|
|
if let video = stream.videoAsset {
|
|
|
|
stream.videoAsset = InvidiousAPI.proxiedAsset(instance: instance, asset: video)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if instance.app == .piped, !instance.proxiesVideos, !hasForbiddenAsset {
|
|
|
|
if let hlsURL = stream.hlsURL {
|
2024-05-17 18:59:42 +05:30
|
|
|
PipedAPI.nonProxiedAsset(url: hlsURL) { possibleNonProxiedURL in
|
|
|
|
if let nonProxiedURL = possibleNonProxiedURL {
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
stream.hlsURL = nonProxiedURL.url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if let audio = stream.audioAsset {
|
|
|
|
PipedAPI.nonProxiedAsset(asset: audio) { nonProxiedAudioAsset in
|
|
|
|
stream.audioAsset = nonProxiedAudioAsset
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if let video = stream.videoAsset {
|
|
|
|
PipedAPI.nonProxiedAsset(asset: video) { nonProxiedVideoAsset in
|
|
|
|
stream.videoAsset = nonProxiedVideoAsset
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-05-17 18:59:42 +05:30
|
|
|
|
|
|
|
// Append to processedStreams within the processedStreamsQueue
|
|
|
|
processedStreamsQueue.sync {
|
|
|
|
processedStreams.append(stream)
|
|
|
|
}
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
}
|
2024-05-17 18:59:42 +05:30
|
|
|
}
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
|
2024-05-17 18:59:42 +05:30
|
|
|
streamProcessingGroup.notify(queue: .main) {
|
|
|
|
// Access and pass processedStreams within the processedStreamsQueue block
|
|
|
|
processedStreamsQueue.sync {
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
completion(processedStreams)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private func getAssets(from streams: [Stream]) -> (nonHLSAssets: [(Instance?, AVURLAsset?, URL, String?)], hlsURLs: [(Instance?, URL)]) {
|
|
|
|
var nonHLSAssets = [(Instance?, AVURLAsset?, URL, String?)]()
|
|
|
|
var hlsURLs = [(Instance?, URL)]()
|
2021-10-22 04:59:10 +05:30
|
|
|
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
for stream in streams {
|
|
|
|
if stream.isHLS {
|
|
|
|
if let url = stream.hlsURL?.url {
|
|
|
|
hlsURLs.append((stream.instance, url))
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if let asset = stream.audioAsset {
|
|
|
|
nonHLSAssets.append((stream.instance, asset, asset.url, stream.requestRange))
|
2022-06-18 18:09:49 +05:30
|
|
|
}
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
if let asset = stream.videoAsset {
|
|
|
|
nonHLSAssets.append((stream.instance, asset, asset.url, stream.requestRange))
|
2022-06-18 18:09:49 +05:30
|
|
|
}
|
2021-10-22 04:59:10 +05:30
|
|
|
}
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
}
|
2021-10-22 20:30:09 +05:30
|
|
|
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
return (nonHLSAssets, hlsURLs)
|
|
|
|
}
|
|
|
|
|
|
|
|
private func testAsset(url: URL, range: String?, isHLS: Bool, forbiddenAssetTestGroup: DispatchGroup, completion: @escaping (Bool) -> Void) {
|
2024-05-17 18:59:42 +05:30
|
|
|
// In case the range is nil, generate a random one.
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
let randomEnd = Int.random(in: 200 ... 800)
|
|
|
|
let requestRange = range ?? "0-\(randomEnd)"
|
|
|
|
|
|
|
|
forbiddenAssetTestGroup.enter()
|
|
|
|
URLTester.testURLResponse(url: url, range: requestRange, isHLS: isHLS) { statusCode in
|
2024-05-17 18:59:42 +05:30
|
|
|
completion(statusCode == HTTPStatus.Forbidden)
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
forbiddenAssetTestGroup.leave()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private func testPipedAssets(asset: AVURLAsset, requestRange: String?, isHLS: Bool, forbiddenAssetTestGroup: DispatchGroup, completion: @escaping (Bool) -> Void) {
|
2024-05-17 18:59:42 +05:30
|
|
|
PipedAPI.nonProxiedAsset(asset: asset) { possibleNonProxiedAsset in
|
|
|
|
if let nonProxiedAsset = possibleNonProxiedAsset {
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
self.testAsset(url: nonProxiedAsset.url, range: requestRange, isHLS: isHLS, forbiddenAssetTestGroup: forbiddenAssetTestGroup, completion: completion)
|
2024-05-17 18:59:42 +05:30
|
|
|
} else {
|
|
|
|
completion(false)
|
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.
This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.
Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.
This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-09 23:37:55 +05:30
|
|
|
}
|
2021-10-17 04:18:58 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 03:19:56 +05:30
|
|
|
func streamsSorter(_ lhs: Stream, _ rhs: Stream) -> Bool {
|
2021-10-23 02:19:31 +05:30
|
|
|
if lhs.resolution.isNil || rhs.resolution.isNil {
|
|
|
|
return lhs.kind < rhs.kind
|
|
|
|
}
|
|
|
|
|
|
|
|
return lhs.kind == rhs.kind ? (lhs.resolution.height > rhs.resolution.height) : (lhs.kind < rhs.kind)
|
2021-10-18 03:19:56 +05:30
|
|
|
}
|
2021-10-17 04:18:58 +05:30
|
|
|
}
|