mirror of
https://github.com/cranci1/Sora.git
synced 2026-03-30 06:18:46 +00:00
Final commit
Persist aniListID and totalEpisodes through download pipeline to fix AniList progress tracking for downloaded episodes
This commit is contained in:
commit
5850d0beec
6 changed files with 52 additions and 28 deletions
|
|
@ -415,6 +415,8 @@ struct AssetMetadata: Codable {
|
|||
let seasonNumber: Int?
|
||||
/// Indicates whether this episode is a filler (derived from metadata at download time)
|
||||
let isFiller: Bool?
|
||||
let aniListID: Int?
|
||||
let totalEpisodes: Int?
|
||||
|
||||
init(
|
||||
title: String,
|
||||
|
|
@ -428,7 +430,9 @@ struct AssetMetadata: Codable {
|
|||
showPosterURL: URL? = nil,
|
||||
episodeTitle: String? = nil,
|
||||
seasonNumber: Int? = nil,
|
||||
isFiller: Bool? = nil
|
||||
isFiller: Bool? = nil,
|
||||
aniListID: Int? = nil,
|
||||
totalEpisodes: Int? = nil
|
||||
) {
|
||||
self.title = title
|
||||
self.overview = overview
|
||||
|
|
@ -442,6 +446,8 @@ struct AssetMetadata: Codable {
|
|||
self.episodeTitle = episodeTitle
|
||||
self.seasonNumber = seasonNumber
|
||||
self.isFiller = isFiller
|
||||
self.aniListID = aniListID
|
||||
self.totalEpisodes = totalEpisodes
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,10 +23,11 @@ struct DownloadRequest {
|
|||
let aniListID: Int?
|
||||
let malID: Int?
|
||||
let isFiller: Bool?
|
||||
let totalEpisodes: 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, malID: Int? = nil, isFiller: Bool? = nil) {
|
||||
episode: Int? = nil, subtitleURL: URL? = nil, showPosterURL: URL? = nil, aniListID: Int? = nil, malID: Int? = nil, isFiller: Bool? = nil, totalEpisodes: Int? = nil) {
|
||||
self.url = url
|
||||
self.headers = headers
|
||||
self.title = title
|
||||
|
|
@ -40,6 +41,7 @@ struct DownloadRequest {
|
|||
self.aniListID = aniListID
|
||||
self.malID = malID
|
||||
self.isFiller = isFiller
|
||||
self.totalEpisodes = totalEpisodes
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -62,6 +64,7 @@ extension JSController {
|
|||
showTitle: String? = nil, season: Int? = nil, episode: Int? = nil,
|
||||
subtitleURL: URL? = nil, showPosterURL: URL? = nil,
|
||||
aniListID: Int? = nil, malID: Int? = nil, isFiller: Bool? = nil,
|
||||
totalEpisodes: Int? = nil,
|
||||
completionHandler: ((Bool, String) -> Void)? = nil) {
|
||||
|
||||
|
||||
|
|
@ -69,7 +72,7 @@ extension JSController {
|
|||
url: url, headers: headers, title: title, imageURL: imageURL,
|
||||
isEpisode: isEpisode, showTitle: showTitle, season: season,
|
||||
episode: episode, subtitleURL: subtitleURL, showPosterURL: showPosterURL,
|
||||
aniListID: aniListID, malID: malID, isFiller: isFiller
|
||||
aniListID: aniListID, malID: malID, isFiller: isFiller, totalEpisodes: totalEpisodes
|
||||
)
|
||||
|
||||
logDownloadStart(request: request)
|
||||
|
|
@ -114,7 +117,8 @@ extension JSController {
|
|||
showPosterURL: request.showPosterURL,
|
||||
aniListID: request.aniListID,
|
||||
malID: request.malID,
|
||||
isFiller: request.isFiller
|
||||
isFiller: request.isFiller,
|
||||
totalEpisodes: request.totalEpisodes
|
||||
)
|
||||
self.downloadWithOriginalMethod(request: qualityRequest, completionHandler: completionHandler)
|
||||
} else {
|
||||
|
|
@ -142,6 +146,7 @@ extension JSController {
|
|||
imageURL: URL? = nil, isEpisode: Bool = false, showTitle: String? = nil,
|
||||
season: Int? = nil, episode: Int? = nil, subtitleURL: URL? = nil,
|
||||
showPosterURL: URL? = nil, aniListID: Int? = nil, malID: Int? = nil, isFiller: Bool? = nil,
|
||||
totalEpisodes: Int? = nil,
|
||||
completionHandler: ((Bool, String) -> Void)? = nil) {
|
||||
|
||||
|
||||
|
|
@ -149,7 +154,7 @@ extension JSController {
|
|||
url: url, headers: headers, title: title, imageURL: imageURL,
|
||||
isEpisode: isEpisode, showTitle: showTitle, season: season,
|
||||
episode: episode, subtitleURL: subtitleURL, showPosterURL: showPosterURL,
|
||||
aniListID: aniListID, malID: malID, isFiller: isFiller
|
||||
aniListID: aniListID, malID: malID, isFiller: isFiller, totalEpisodes: totalEpisodes
|
||||
)
|
||||
|
||||
downloadMP4(request: request, completionHandler: completionHandler)
|
||||
|
|
@ -382,7 +387,9 @@ extension JSController {
|
|||
showPosterURL: request.showPosterURL ?? request.imageURL,
|
||||
episodeTitle: nil,
|
||||
seasonNumber: nil,
|
||||
isFiller: request.isFiller
|
||||
isFiller: request.isFiller,
|
||||
aniListID: request.aniListID,
|
||||
totalEpisodes: request.totalEpisodes
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -436,6 +443,7 @@ extension JSController {
|
|||
aniListID: request.aniListID,
|
||||
malID: request.malID,
|
||||
isFiller: request.isFiller,
|
||||
totalEpisodes: request.totalEpisodes,
|
||||
completionHandler: completionHandler
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ extension JSController {
|
|||
aniListID: Int? = nil,
|
||||
malID: Int? = nil,
|
||||
isFiller: Bool? = nil,
|
||||
totalEpisodes: Int? = nil,
|
||||
completionHandler: ((Bool, String) -> Void)? = nil
|
||||
) {
|
||||
// If a module is provided, use the stream type aware download
|
||||
|
|
@ -137,6 +138,7 @@ extension JSController {
|
|||
aniListID: aniListID,
|
||||
malID: malID,
|
||||
isFiller: isFiller,
|
||||
totalEpisodes: totalEpisodes,
|
||||
completionHandler: completionHandler
|
||||
)
|
||||
return
|
||||
|
|
@ -163,7 +165,9 @@ extension JSController {
|
|||
season: season,
|
||||
episode: episode,
|
||||
showPosterURL: showPosterURL, // Main show poster
|
||||
isFiller: isFiller
|
||||
isFiller: isFiller,
|
||||
aniListID: aniListID,
|
||||
totalEpisodes: totalEpisodes
|
||||
)
|
||||
|
||||
// Create the download ID now so we can use it for notifications
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ extension JSController {
|
|||
aniListID: Int? = nil,
|
||||
malID: Int? = nil,
|
||||
isFiller: Bool? = nil,
|
||||
totalEpisodes: Int? = nil,
|
||||
completionHandler: ((Bool, String) -> Void)? = nil
|
||||
) {
|
||||
let streamType = module.metadata.streamType.lowercased()
|
||||
|
|
@ -59,6 +60,7 @@ extension JSController {
|
|||
aniListID: aniListID,
|
||||
malID: malID,
|
||||
isFiller: isFiller,
|
||||
totalEpisodes: totalEpisodes,
|
||||
completionHandler: completionHandler
|
||||
)
|
||||
}else {
|
||||
|
|
@ -77,6 +79,7 @@ extension JSController {
|
|||
aniListID: aniListID,
|
||||
malID: malID,
|
||||
isFiller: isFiller,
|
||||
totalEpisodes: totalEpisodes,
|
||||
completionHandler: completionHandler
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -281,8 +281,8 @@ struct DownloadView: View {
|
|||
}
|
||||
},
|
||||
subtitlesURL: asset.localSubtitleURL?.absoluteString,
|
||||
aniListID: 0,
|
||||
totalEpisodes: asset.metadata?.episode ?? 0,
|
||||
aniListID: asset.metadata?.aniListID ?? 0,
|
||||
totalEpisodes: asset.metadata?.totalEpisodes ?? 0,
|
||||
episodeImageUrl: asset.metadata?.posterURL?.absoluteString ?? "",
|
||||
headers: nil
|
||||
)
|
||||
|
|
@ -1050,7 +1050,6 @@ struct EnhancedShowEpisodesView: View {
|
|||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
heroImageSection
|
||||
mainScrollView
|
||||
.navigationBarHidden(true)
|
||||
.ignoresSafeArea(.container, edges: .top)
|
||||
|
|
@ -1099,7 +1098,10 @@ struct EnhancedShowEpisodesView: View {
|
|||
@ViewBuilder
|
||||
private var mainScrollView: some View {
|
||||
ScrollView(showsIndicators: false) {
|
||||
contentContainer
|
||||
ZStack(alignment: .top) {
|
||||
heroImageSection
|
||||
contentContainer
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
UIScrollView.appearance().bounces = false
|
||||
|
|
@ -1108,24 +1110,22 @@ struct EnhancedShowEpisodesView: View {
|
|||
|
||||
@ViewBuilder
|
||||
private var heroImageSection: some View {
|
||||
if let posterURL = group.posterURL {
|
||||
LazyImage(url: posterURL) { state in
|
||||
if let uiImage = state.imageContainer?.image {
|
||||
Image(uiImage: uiImage)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
} else {
|
||||
placeholderGradient
|
||||
Group {
|
||||
if let posterURL = group.posterURL {
|
||||
LazyImage(url: posterURL) { @MainActor state in
|
||||
if let uiImage = state.imageContainer?.image {
|
||||
Image(uiImage: uiImage)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: UIScreen.main.bounds.width, height: 700)
|
||||
.clipped()
|
||||
} else {
|
||||
placeholderGradient
|
||||
}
|
||||
}
|
||||
} else {
|
||||
placeholderGradient
|
||||
}
|
||||
.ignoresSafeArea(.all)
|
||||
.frame(maxWidth: .infinity, maxHeight: 400)
|
||||
.clipped()
|
||||
} else {
|
||||
placeholderGradient
|
||||
.ignoresSafeArea(.all)
|
||||
.frame(maxWidth: .infinity, maxHeight: 400)
|
||||
.clipped()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1142,6 +1142,8 @@ struct EnhancedShowEpisodesView: View {
|
|||
endPoint: .bottomTrailing
|
||||
)
|
||||
)
|
||||
.frame(width: UIScreen.main.bounds.width, height: 700)
|
||||
.clipped()
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
|
|
|||
|
|
@ -747,7 +747,8 @@ private extension EpisodeCell {
|
|||
showPosterURL: showPosterImageURL,
|
||||
aniListID: itemID,
|
||||
malID: malIDFromParent,
|
||||
isFiller: isFiller
|
||||
isFiller: isFiller,
|
||||
totalEpisodes: totalEpisodes
|
||||
) { success, message in
|
||||
if success {
|
||||
Logger.shared.log("Started download for Episode \(self.episodeID + 1): \(self.episode)", type: "Download")
|
||||
|
|
|
|||
Loading…
Reference in a new issue