Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: optimize ugc_season selection logic #103

Merged
merged 3 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion BilibiliLive/Component/Video/VideoDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,16 @@ class VideoDetailViewController: UIViewController {
}

if let season = data.View.ugc_season {
allUgcEpisodes = Array((season.sections.map { $0.episodes }.joined()))
if season.sections.count > 1 {
if let section = season.sections.first(where: { section in section.episodes.contains(where: { episode in episode.aid == data.View.aid }) }) {
allUgcEpisodes = section.episodes
}
} else {
allUgcEpisodes = season.sections.first?.episodes ?? []
}
allUgcEpisodes.sort { $0.arc.ctime < $1.arc.ctime }
}

ugcCollectionView.reloadData()
ugcLabel.text = "合集 \(data.View.ugc_season?.title ?? "") \(data.View.ugc_season?.sections.first?.title ?? "")"
ugcView.isHidden = allUgcEpisodes.count == 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct PlayInfo {
var cid: Int? = 0
var epid: Int? = 0 // 港澳台解锁需要
var isBangumi: Bool = false
var ctime: Int? = 0

var isCidVaild: Bool {
return cid ?? 0 > 0
Expand Down
3 changes: 3 additions & 0 deletions BilibiliLive/Request/WebRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ struct VideoDetail: Codable, Hashable {
let ugc_season: UgcSeason?
let redirect_url: URL?
let stat: Stat
var ctime: Int?
struct Stat: Codable, Hashable {
let favorite: Int
let coin: Int
Expand Down Expand Up @@ -623,13 +624,15 @@ struct VideoDetail: Codable, Hashable {
struct UgcVideoInfo: Codable, Hashable, DisplayData {
var ownerName: String { "" }
var pic: URL? { arc.pic }
let id: Int
let aid: Int
let cid: Int
let arc: Arc
let title: String

struct Arc: Codable, Hashable {
let pic: URL
let ctime: Int
}
}
}
Expand Down