Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
xjbeta committed Aug 3, 2022
2 parents f2610bf + 3058b1d commit 1306ade
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 42 deletions.
4 changes: 2 additions & 2 deletions IINA+.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 0.6.16;
MARKETING_VERSION = 0.6.17;
PRODUCT_BUNDLE_IDENTIFIER = "com.xjbeta.iina-plus";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -967,7 +967,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 0.6.16;
MARKETING_VERSION = 0.6.17;
PRODUCT_BUNDLE_IDENTIFIER = "com.xjbeta.iina-plus";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Alamofire/Alamofire",
"state" : {
"revision" : "354dda32d89fc8cd4f5c46487f64957d355f53d8",
"version" : "5.6.1"
"revision" : "8dd85aee02e39dd280c75eef88ffdb86eed4b07b",
"version" : "5.6.2"
}
},
{
Expand Down Expand Up @@ -50,17 +50,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mxcl/PromiseKit",
"state" : {
"revision" : "c946b7561fbe11379a874e59faa2c5f8077ae0e1",
"version" : "6.17.1"
"revision" : "ed3192004c0b00b4b3d7baa9578ee655c66faae3",
"version" : "6.18.0"
}
},
{
"identity" : "sdwebimage",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SDWebImage/SDWebImage",
"state" : {
"revision" : "c4b8660bb3ef543fe4bdcaac0db956b32dc5583f",
"version" : "5.13.0"
"revision" : "3e48cb68d8e668d146dc59c73fb98cb628616236",
"version" : "5.13.2"
}
},
{
Expand All @@ -77,17 +77,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/sparkle-project/Sparkle",
"state" : {
"revision" : "c1bf68f91f5c37ba5b3ac5028e34ceb5d444de12",
"version" : "2.2.0"
"revision" : "059ce9128775d5a636c7f4716f71a58919d3111e",
"version" : "2.2.1"
}
},
{
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "e1499bc69b9040b29184f7f2996f7bab467c1639",
"version" : "1.19.0"
"revision" : "fa0fcd43f272a260e7f734f23e6dc55e16fcae0a",
"version" : "1.19.1"
}
},
{
Expand Down
2 changes: 2 additions & 0 deletions IINA+/Core Data/Bookmark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ public class Bookmark: NSManagedObject {

inited = true

/*
if let d = updateDate?.timeIntervalSince1970,
(Date().timeIntervalSince1970 - d) > 1800 {
state = LiveState.none.raw
}
*/

Processes.shared.videoDecoder.liveInfo(url).done(on: .main) {
self.setInfo($0)
Expand Down
114 changes: 88 additions & 26 deletions IINA+/Utils/VideoDecoder/Bilibili.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,14 @@ class Bilibili: NSObject, SupportSiteProtocol {
case .video:
json.site = .bilibili
return getVideoList(url).compactMap { list -> YouGetJSON? in
guard let s = list.first(where: { $0.index == bUrl.p }) else {
return nil
var selector = list.first
if let s = selector, s.isCollection {
selector = list.first(where: { $0.bvid == bUrl.id })
} else {
selector = list.first(where: { $0.index == bUrl.p })
}
guard let s = selector else { return nil }

json.id = s.id
json.bvid = s.bvid
json.title = s.title
Expand Down Expand Up @@ -365,7 +370,7 @@ class Bilibili: NSObject, SupportSiteProtocol {
}
}

func getVideoList(_ url: String) -> Promise<[BilibiliVideoSelector]> {
func getVideoList(_ url: String) -> Promise<[BiliVideoSelector]> {
var aid = -1
var bvid = ""

Expand Down Expand Up @@ -393,17 +398,21 @@ class Bilibili: NSObject, SupportSiteProtocol {

return r.responseData().map {
let json: JSONObject = try JSONParser.JSONObjectWithData($0.data)
var infos: [BilibiliVideoSelector] = try json.value(for: "data.pages")
let bvid: String = try json.value(for: "data.bvid")

if infos.count == 1 {
infos[0].title = try json.value(for: "data.title")
}
infos.enumerated().forEach {
infos[$0.offset].bvid = bvid
if let collection: BilibiliVideoCollection = try json.value(for: "data.ugc_season"), collection.episodes.count > 0 {
return collection.episodes
} else {
var infos: [BiliVideoSelector] = try json.value(for: "data.pages")
let bvid: String = try json.value(for: "data.bvid")

if infos.count == 1 {
infos[0].title = try json.value(for: "data.title")
}
infos.enumerated().forEach {
infos[$0.offset].bvid = bvid
}
return infos
}

return infos
}
}

Expand Down Expand Up @@ -544,15 +553,20 @@ struct BilibiliPvideo: Unmarshaling {
}
}

struct BilibiliVideoSelector: Unmarshaling, VideoSelector {

protocol BilibiliVideoSelector: VideoSelector {
var bvid: String { get set }
var duration: Int { get set }
}

struct BiliVideoSelector: Unmarshaling, BilibiliVideoSelector {
var bvid = ""
var isCollection = false

// epid
let id: Int
var index: Int
let part: String
let duration: TimeInterval
var duration: Int
var title: String
let longTitle: String
let coverUrl: URL?
Expand All @@ -567,14 +581,24 @@ struct BilibiliVideoSelector: Unmarshaling, VideoSelector {

init(object: MarshaledObject) throws {
id = try object.value(for: "cid")
index = try object.value(for: "page")
part = try object.value(for: "part")
let d: Double? = try? object.value(for: "duration")
duration = d ?? 0
title = part

if let pic: String = try? object.value(for: "arc.pic") {
coverUrl = .init(string: pic)
duration = (try? object.value(for: "arc.duration")) ?? 0
bvid = try object.value(for: "bvid")
index = 0
title = try object.value(for: "title")
isCollection = true
part = ""
} else {
index = try object.value(for: "page")
part = try object.value(for: "part")
duration = (try? object.value(for: "duration")) ?? 0
title = part
coverUrl = nil
// badge = nil
}
longTitle = ""
coverUrl = nil
// badge = nil
site = .bilibili
}

Expand All @@ -594,26 +618,64 @@ struct BilibiliVideoSelector: Unmarshaling, VideoSelector {
}
}

struct BilibiliVideoCollection: Unmarshaling {
let id: Int
let title: String
let cover: URL?
let mid: Int
let epCount: Int
let isPaySeason: Bool
let episodes: [BiliVideoSelector]

init(object: MarshaledObject) throws {
id = try object.value(for: "id")
title = try object.value(for: "title")
cover = .init(string: try object.value(for: "cover"))
mid = try object.value(for: "mid")
epCount = try object.value(for: "ep_count")
isPaySeason = try object.value(for: "is_pay_season")

let s: [Section] = try object.value(for: "sections")
episodes = s.first?.episodes ?? []
}

struct Section: Unmarshaling {
let id: Int
let title: String
let episodes: [BiliVideoSelector]

init(object: MarshaledObject) throws {
id = try object.value(for: "id")
title = try object.value(for: "title")
var eps: [BiliVideoSelector] = try object.value(for: "episodes")
eps.enumerated().forEach {
eps[$0.offset].index = $0.offset + 1
}
episodes = eps
}
}
}

struct BangumiList: Unmarshaling {
let title: String
let epList: [BangumiInfo.BangumiEp]
let sections: [BangumiInfo.BangumiSections]

var epVideoSelectors: [BilibiliVideoSelector] {
var epVideoSelectors: [BiliVideoSelector] {
get {
var list = epList.map(BilibiliVideoSelector.init)
var list = epList.map(BiliVideoSelector.init)
list.enumerated().forEach {
list[$0.offset].index = $0.offset + 1
}
return list
}
}

var selectionVideoSelectors: [BilibiliVideoSelector] {
var selectionVideoSelectors: [BiliVideoSelector] {
get {
var list = sections.compactMap {
$0.epList.first
}.map(BilibiliVideoSelector.init)
}.map(BiliVideoSelector.init)
list.enumerated().forEach {
list[$0.offset].index = $0.offset + 1
}
Expand Down
14 changes: 12 additions & 2 deletions IINA+/Utils/VideoDecoder/DouYin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ class DouYin: NSObject, SupportSiteProtocol {
}

let jsonObj: JSONObject = try JSONParser.JSONObjectWithData(json)
return try DouYinInfo(object: jsonObj)

if let re = try? DouYinInfo(object: jsonObj) {
return re
} else {
let info: DouYinInfo = try jsonObj.value(for: "app")
return info
}
}
}

Expand Down Expand Up @@ -265,7 +271,11 @@ struct DouYinInfo: Unmarshaling, LiveInfo {


init(object: MarshaledObject) throws {
roomId = try object.value(for: "initialState.roomStore.roomInfo.roomId")
if let rid: String = try? object.value(for: "initialState.roomStore.roomInfo.roomId") {
roomId = rid
} else {
roomId = try object.value(for: "initialState.roomStore.roomInfo.room.id_str")
}
webRid = try object.value(for: "initialState.roomStore.roomInfo.web_rid")

title = try object.value(for: "initialState.roomStore.roomInfo.room.title")
Expand Down
4 changes: 4 additions & 0 deletions IINA+/Views/MainWindow/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ class MainViewController: NSViewController {
super.viewDidLoad()
let proc = Processes.shared

dataManager.requestData().forEach {
$0.state = LiveState.none.raw
}

loadBilibiliCards()
bookmarkArrayController.sortDescriptors = dataManager.sortDescriptors
bookmarkTableView.registerForDraggedTypes([.bookmarkRow])
Expand Down
7 changes: 7 additions & 0 deletions IINA+/Views/MainWindow/MainWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ class MainWindowController: NSWindowController, NSWindowDelegate {
NotificationCenter.default.post(name: .reloadMainWindowTableView, object: nil)
}

func windowDidChangeOcclusionState(_ notification: Notification) {
guard let w = window,
w.occlusionState.rawValue == 8194,
!w.isMainWindow
else { return }
NotificationCenter.default.post(name: .reloadMainWindowTableView, object: nil)
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ extension SelectVideoViewController: NSCollectionViewDataSource, NSCollectionVie
s = "\(info.index) \(info.title)"
case .bangumi:
s = info.title
if let longTitle = (info as? BilibiliVideoSelector)?.longTitle {
if let longTitle = (info as? BiliVideoSelector)?.longTitle {
s += " \(longTitle)"
}
case .douyu:
Expand Down Expand Up @@ -135,7 +135,12 @@ extension SelectVideoViewController: NSCollectionViewDataSource, NSCollectionVie
var u = ""
switch info.site {
case .bilibili:
u = "https://www.bilibili.com/video/\(videoId)?p=\(info.index)"
guard let info = info as? BiliVideoSelector else { return }
if info.isCollection {
u = "https://www.bilibili.com/video/\(info.bvid)"
} else {
u = "https://www.bilibili.com/video/\(videoId)?p=\(info.index)"
}
case .douyu:
u = "https://www.douyu.com/\(info.id)"
case .bangumi:
Expand Down

0 comments on commit 1306ade

Please sign in to comment.