From 8e21c669cbbeae7f4b28b767df1d074abbca9728 Mon Sep 17 00:00:00 2001 From: scigward Date: Tue, 19 Aug 2025 09:00:49 +0300 Subject: [PATCH] revert to "Probably fix filler fetching" --- .../CustomPlayer/CustomPlayer.swift | 8 --- .../DownloadUtils/DownloadModels.swift | 14 ----- .../Downloads/JSController+Downloader.swift | 5 +- .../Downloads/JSController-Downloads.swift | 56 ------------------- .../JSController-StreamTypeDownload.swift | 1 - .../EpisodeCell/EpisodeCell.swift | 2 + 6 files changed, 3 insertions(+), 83 deletions(-) diff --git a/Sora/MediaUtils/CustomPlayer/CustomPlayer.swift b/Sora/MediaUtils/CustomPlayer/CustomPlayer.swift index dbb80c6..6a57dc0 100644 --- a/Sora/MediaUtils/CustomPlayer/CustomPlayer.swift +++ b/Sora/MediaUtils/CustomPlayer/CustomPlayer.swift @@ -152,7 +152,6 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele private var malID: Int? private var skipIntervals: (op: CMTimeRange?, ed: CMTimeRange?) = (nil, nil) - private var preloadedSkipInfo: SkipInfo? = nil private var skipIntroButton: UIButton! private var skipOutroButton: UIButton! @@ -267,7 +266,6 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele onWatchNext: @escaping () -> Void, subtitlesURL: String?, aniListID: Int, - skipInfo: SkipInfo? = nil, totalEpisodes: Int, episodeImageUrl: String,headers:[String:String]?) { @@ -282,7 +280,6 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele self.onWatchNext = onWatchNext self.subtitlesURL = subtitlesURL self.aniListID = aniListID - self.preloadedSkipInfo = skipInfo self.headers = headers self.totalEpisodes = totalEpisodes @@ -396,11 +393,6 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele view.bringSubviewToFront(subtitleStackView) subtitleStackView.isHidden = !SubtitleSettingsManager.shared.settings.enabled - if let info = preloadedSkipInfo { - if let s = info.opStart, let e = info.opEnd { self.skipIntervals.op = CMTimeRange(start: CMTime(seconds: s, preferredTimescale: 600), end: CMTime(seconds: e, preferredTimescale: 600)) } - if let s = info.edStart, let e = info.edEnd { self.skipIntervals.ed = CMTimeRange(start: CMTime(seconds: s, preferredTimescale: 600), end: CMTime(seconds: e, preferredTimescale: 600)) } - self.updateSegments() - } AniListMutation().fetchMalID(animeId: aniListID) { [weak self] result in switch result { case .success(let mal): diff --git a/Sora/Utlis & Misc/DownloadUtils/DownloadModels.swift b/Sora/Utlis & Misc/DownloadUtils/DownloadModels.swift index 0e665ef..685a943 100644 --- a/Sora/Utlis & Misc/DownloadUtils/DownloadModels.swift +++ b/Sora/Utlis & Misc/DownloadUtils/DownloadModels.swift @@ -55,18 +55,6 @@ enum DownloadType: String, Codable { case .episode: return "Episode" } - -// MARK: - Skip Information -struct SkipInfo: Codable, Equatable { - let opStart: Double? - let opEnd: Double? - let edStart: Double? - let edEnd: Double? - let introURL: String? - let outroURL: String? -} - - } } @@ -82,7 +70,6 @@ struct DownloadedAsset: Identifiable, Codable, Equatable { // New fields for subtitle support let subtitleURL: URL? let localSubtitleURL: URL? - let skipInfo: SkipInfo? // For caching purposes, but not stored as part of the codable object private var _cachedFileSize: Int64? = nil @@ -426,7 +413,6 @@ struct AssetMetadata: Codable { let showPosterURL: URL? // Main show poster URL (distinct from episode-specific images) let episodeTitle: String? let seasonNumber: Int? - let anilistId: Int? init( title: String, diff --git a/Sora/Utlis & Misc/JSLoader/Downloads/JSController+Downloader.swift b/Sora/Utlis & Misc/JSLoader/Downloads/JSController+Downloader.swift index 3320f30..810a917 100644 --- a/Sora/Utlis & Misc/JSLoader/Downloads/JSController+Downloader.swift +++ b/Sora/Utlis & Misc/JSLoader/Downloads/JSController+Downloader.swift @@ -20,11 +20,10 @@ struct DownloadRequest { let episode: Int? let subtitleURL: URL? let showPosterURL: URL? - let anilistId: Int? init(url: URL, headers: [String: String], title: String? = nil, imageURL: URL? = nil, isEpisode: Bool = false, showTitle: String? = nil, season: Int? = nil, - episode: Int? = nil, subtitleURL: URL? = nil, showPosterURL: URL? = nil, anilistId: Int? = nil) { + episode: Int? = nil, subtitleURL: URL? = nil, showPosterURL: URL? = nil) { self.url = url self.headers = headers self.title = title @@ -35,7 +34,6 @@ struct DownloadRequest { self.episode = episode self.subtitleURL = subtitleURL self.showPosterURL = showPosterURL - self.anilistId = anilistId } } @@ -410,7 +408,6 @@ extension JSController { episode: request.episode, subtitleURL: request.subtitleURL, showPosterURL: request.showPosterURL, - anilistId: request.anilistId, completionHandler: completionHandler ) } diff --git a/Sora/Utlis & Misc/JSLoader/Downloads/JSController-Downloads.swift b/Sora/Utlis & Misc/JSLoader/Downloads/JSController-Downloads.swift index 754a889..024d44a 100644 --- a/Sora/Utlis & Misc/JSLoader/Downloads/JSController-Downloads.swift +++ b/Sora/Utlis & Misc/JSLoader/Downloads/JSController-Downloads.swift @@ -1208,31 +1208,6 @@ extension JSController: AVAssetDownloadDelegate { // Add to saved assets and save DownloadPersistence.upsert(newAsset) - // Fetch skip info in background if we know AniList ID & episode number - if let meta = newAsset.metadata, let aId = meta.anilistId, let ep = meta.episodeNumber { - self.fetchSkipInfo(anilistId: aId, episodeNumber: ep) { info in - guard let info = info else { return } - let updated = DownloadedAsset( - id: newAsset.id, - name: newAsset.name, - downloadDate: newAsset.downloadDate, - originalURL: newAsset.originalURL, - localURL: newAsset.localURL, - imageURL: newAsset.imageURL, - fileSize: newAsset.fileSize, - type: newAsset.type, - progress: newAsset.progress, - headers: newAsset.headers, - referer: newAsset.referer, - userAgent: newAsset.userAgent, - metadata: newAsset.metadata, - subtitleURL: newAsset.subtitleURL, - localSubtitleURL: newAsset.localSubtitleURL, - skipInfo: info - ) - DownloadPersistence.upsert(updated) - } - } DispatchQueue.main.async { [weak self] in self?.savedAssets = DownloadPersistence.load() self?.objectWillChange.send() @@ -1671,35 +1646,4 @@ enum DownloadQueueStatus: Equatable { case downloading /// Download has been completed case completed - -// MARK: - Offline Skip Info (lightweight) -private struct _AniSkipEntry: Codable { let interval: _Interval } -private struct _Interval: Codable { let startTime: Double; let endTime: Double } -private struct _AniSkipAPIResponse: Codable { let found: Bool; let results: [String:[_AniSkipEntry]]? } - -private func fetchSkipInfo(anilistId: Int, episodeNumber: Int, completion: @escaping (SkipInfo?) -> Void) { - // Convert AniList -> MAL - AniListMutation().fetchMalID(animeId: anilistId) { res in - guard case .success(let malId) = res, let malId = malId else { completion(nil); return } - // Build requests for OP and ED - let types = ["op","ed"] - var info = SkipInfo(opStart: nil, opEnd: nil, edStart: nil, edEnd: nil, introURL: nil, outroURL: nil) - let group = DispatchGroup() - for t in types { - group.enter() - let urlStr = "https://api.aniskip.com/v2/skip-times/" + String(malId) + "?episode=" + String(episodeNumber) + "&types=" + t + "&anilistID=" + String(anilistId) - guard let url = URL(string: urlStr) else { group.leave(); continue } - URLSession.shared.dataTask(with: url) { data, _, _ in - defer { group.leave() } - guard let data = data, let resp = try? JSONDecoder().decode(_AniSkipAPIResponse.self, from: data), resp.found else { return } - if let entries = resp.results?[t], let first = entries.first { - if t == "op" { info = SkipInfo(opStart: first.interval.startTime, opEnd: first.interval.endTime, edStart: info.edStart, edEnd: info.edEnd, introURL: nil, outroURL: nil) } - if t == "ed" { info = SkipInfo(opStart: info.opStart, opEnd: info.opEnd, edStart: first.interval.startTime, edEnd: first.interval.endTime, introURL: nil, outroURL: nil) } - } - }.resume() - } - group.notify(queue: .main) { completion((info.opStart != nil || info.edStart != nil) ? info : nil) } - } -} - } diff --git a/Sora/Utlis & Misc/JSLoader/Downloads/JSController-StreamTypeDownload.swift b/Sora/Utlis & Misc/JSLoader/Downloads/JSController-StreamTypeDownload.swift index d6e00a2..bb48d8f 100644 --- a/Sora/Utlis & Misc/JSLoader/Downloads/JSController-StreamTypeDownload.swift +++ b/Sora/Utlis & Misc/JSLoader/Downloads/JSController-StreamTypeDownload.swift @@ -34,7 +34,6 @@ extension JSController { showTitle: String? = nil, season: Int? = nil, episode: Int? = nil, - anilistId: Int? = nil, subtitleURL: URL? = nil, showPosterURL: URL? = nil, completionHandler: ((Bool, String) -> Void)? = nil diff --git a/Sora/Views/MediaInfoView/EpisodeCell/EpisodeCell.swift b/Sora/Views/MediaInfoView/EpisodeCell/EpisodeCell.swift index c84a2a3..8e4fc9f 100644 --- a/Sora/Views/MediaInfoView/EpisodeCell/EpisodeCell.swift +++ b/Sora/Views/MediaInfoView/EpisodeCell/EpisodeCell.swift @@ -976,6 +976,8 @@ private extension EpisodeCell { } }.resume() } + + // Removed Jikan fetching from EpisodeCell. All filler/Jikan handling is now in MediaInfoView and passed in via `fillerEpisodes`. func handleFetchFailure(error: Error) { Logger.shared.log("Episode details fetch error: \(error.localizedDescription)", type: "Error")