Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
xjbeta committed Oct 11, 2022
2 parents bcbc718 + de7059f commit 8d2350a
Show file tree
Hide file tree
Showing 17 changed files with 582 additions and 140 deletions.
16 changes: 14 additions & 2 deletions IINA+.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
01B53B6427B64FD20051F7B4 /* flvplayer.css in Copy Web Files */ = {isa = PBXBuildFile; fileRef = 0120932827A3B441002C7FD3 /* flvplayer.css */; };
01B53B6527B64FD20051F7B4 /* flvplayer.htm in Copy Web Files */ = {isa = PBXBuildFile; fileRef = 0120932A27A3B441002C7FD3 /* flvplayer.htm */; };
01B53B6627B64FD20051F7B4 /* flvplayer.js in Copy Web Files */ = {isa = PBXBuildFile; fileRef = 0120932927A3B441002C7FD3 /* flvplayer.js */; };
01B82B3728EEF74800928F61 /* SelectVideoCollectionViewHeader.xib in Resources */ = {isa = PBXBuildFile; fileRef = 01B82B3628EEF74800928F61 /* SelectVideoCollectionViewHeader.xib */; };
01B82B3928EEF9D300928F61 /* SelectVideoCollectionViewHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01B82B3828EEF9D300928F61 /* SelectVideoCollectionViewHeader.swift */; };
01C0807027BB5CF300E87A8C /* JSPlayer.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 01C0807227BB5CF300E87A8C /* JSPlayer.storyboard */; };
01C0807527BB5CFD00E87A8C /* Preferences.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 01C0807727BB5CFD00E87A8C /* Preferences.storyboard */; };
01C0807C27BC00EA00E87A8C /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 01C0807B27BC00EA00E87A8C /* Alamofire */; };
Expand All @@ -102,6 +104,7 @@
01C0809727BC074000E87A8C /* SDWebImage in Frameworks */ = {isa = PBXBuildFile; productRef = 01C0809627BC074000E87A8C /* SDWebImage */; };
01C0809A27BC079200E87A8C /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 01C0809927BC079200E87A8C /* Sparkle */; };
01C0809D27BC0BC400E87A8C /* SocketRocket in Frameworks */ = {isa = PBXBuildFile; productRef = 01C0809C27BC0BC400E87A8C /* SocketRocket */; };
01C338B528E47B3F004CC0B8 /* MBGA.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C338B428E47B3F004CC0B8 /* MBGA.swift */; };
01C373592429F2C2006778D1 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 01C373582429F2C2006778D1 /* README.md */; };
01CEA84A264255EF0021A645 /* FontSelectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01CEA849264255EF0021A645 /* FontSelectorViewController.swift */; };
01D8762927D459C5001140DD /* crypto-js.js in Resources */ = {isa = PBXBuildFile; fileRef = 01D8762827D459C5001140DD /* crypto-js.js */; };
Expand Down Expand Up @@ -232,10 +235,13 @@
01B53B5827B64F270051F7B4 /* flv.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = flv.min.js; path = "IINA+/WebFiles/node_modules/flv.js/dist/flv.min.js"; sourceTree = SOURCE_ROOT; };
01B53B5A27B64F370051F7B4 /* CommentCoreLibrary.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = CommentCoreLibrary.min.js; path = "IINA+/WebFiles/node_modules/comment-core-library/dist/CommentCoreLibrary.min.js"; sourceTree = SOURCE_ROOT; };
01B53B5C27B64F420051F7B4 /* style.min.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; name = style.min.css; path = "IINA+/WebFiles/node_modules/comment-core-library/dist/css/style.min.css"; sourceTree = SOURCE_ROOT; };
01B82B3628EEF74800928F61 /* SelectVideoCollectionViewHeader.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SelectVideoCollectionViewHeader.xib; sourceTree = "<group>"; };
01B82B3828EEF9D300928F61 /* SelectVideoCollectionViewHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectVideoCollectionViewHeader.swift; sourceTree = "<group>"; };
01C0807127BB5CF300E87A8C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/JSPlayer.storyboard; sourceTree = "<group>"; };
01C0807427BB5CF500E87A8C /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/JSPlayer.strings"; sourceTree = "<group>"; };
01C0807627BB5CFD00E87A8C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Preferences.storyboard; sourceTree = "<group>"; };
01C0807927BB5CFF00E87A8C /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Preferences.strings"; sourceTree = "<group>"; };
01C338B428E47B3F004CC0B8 /* MBGA.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MBGA.swift; sourceTree = "<group>"; };
01C373582429F2C2006778D1 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; };
01CEA849264255EF0021A645 /* FontSelectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontSelectorViewController.swift; sourceTree = "<group>"; };
01D8762827D459C5001140DD /* crypto-js.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "crypto-js.js"; path = "IINA+/WebFiles/node_modules/crypto-js/crypto-js.js"; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -407,6 +413,8 @@
016792E4212BDEE5003517A7 /* SelectVideoCollectionViewItem.swift */,
016792ED212C421F003517A7 /* SelectVideoCollectionViewItemView.swift */,
016792E5212BDEE5003517A7 /* SelectVideoCollectionViewItem.xib */,
01B82B3828EEF9D300928F61 /* SelectVideoCollectionViewHeader.swift */,
01B82B3628EEF74800928F61 /* SelectVideoCollectionViewHeader.xib */,
);
path = SelectVideoCollectionView;
sourceTree = "<group>";
Expand Down Expand Up @@ -445,6 +453,7 @@
018F4F6B2817FFF30045B67C /* BiliLive.swift */,
01683DDA2118905D0016A886 /* Bilibili.swift */,
018739ED2852135200156F3F /* QQLive.swift */,
01C338B428E47B3F004CC0B8 /* MBGA.swift */,
);
path = VideoDecoder;
sourceTree = "<group>";
Expand Down Expand Up @@ -660,6 +669,7 @@
01C0807027BB5CF300E87A8C /* JSPlayer.storyboard in Resources */,
016792E7212BDEE5003517A7 /* SelectVideoCollectionViewItem.xib in Resources */,
01E40FF622C39E7100864118 /* Localizable.strings in Resources */,
01B82B3728EEF74800928F61 /* SelectVideoCollectionViewHeader.xib in Resources */,
013850FA214EA2AA003817CE /* huya.js in Resources */,
01AEC8B220EDFD02001406E8 /* Main.storyboard in Resources */,
01892C8327C27FAB00494AFD /* douyin.html in Resources */,
Expand Down Expand Up @@ -704,6 +714,7 @@
016792E6212BDEE5003517A7 /* SelectVideoCollectionViewItem.swift in Sources */,
0101013921200DC5002F0F7F /* LiveUrlTableCellView.swift in Sources */,
018F4F6A2812D95C0045B67C /* CC163.swift in Sources */,
01C338B528E47B3F004CC0B8 /* MBGA.swift in Sources */,
01479CD3210AF5F40046AAAD /* DataManager.swift in Sources */,
01398985210F27A600B7042F /* PreferencesWindowController.swift in Sources */,
01AEC8BE20EE108B001406E8 /* Processes.swift in Sources */,
Expand Down Expand Up @@ -742,6 +753,7 @@
015EDE27273D333900271901 /* LiveStateTransformers.swift in Sources */,
0120934427A4F632002C7FD3 /* JSPlayerWebView.swift in Sources */,
01AEC8BC20EDFFBD001406E8 /* YouGetJSON.swift in Sources */,
01B82B3928EEF9D300928F61 /* SelectVideoCollectionViewHeader.swift in Sources */,
0132B2E52123D68D001EB7DC /* BilibiliCardImageBoxView.swift in Sources */,
01683DD9211869AE0016A886 /* BilibiliLoginViewController.swift in Sources */,
010F0F1320FE1DD100F33553 /* Preferences.swift in Sources */,
Expand Down Expand Up @@ -944,7 +956,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 0.6.18;
MARKETING_VERSION = 0.6.19;
PRODUCT_BUNDLE_IDENTIFIER = "com.xjbeta.iina-plus";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -969,7 +981,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 0.6.18;
MARKETING_VERSION = 0.6.19;
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 @@ -59,8 +59,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/SDWebImage/SDWebImage",
"state" : {
"revision" : "484bc774e1091f622c4856e576ff957b29403676",
"version" : "5.13.3"
"revision" : "9248fe561a2a153916fb9597e3af4434784c6d32",
"version" : "5.13.4"
}
},
{
Expand All @@ -77,8 +77,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/sparkle-project/Sparkle",
"state" : {
"revision" : "8e27997de02457a0c4690ffcfb8ac9c8e1066883",
"version" : "2.2.2"
"revision" : "2a98381dfe72e24bf593c5c06d2c4fc1763c3f19",
"version" : "2.3.0"
}
},
{
Expand Down
94 changes: 93 additions & 1 deletion IINA+/Utils/VideoDecoder/BiliLive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,53 @@ class BiliLive: NSObject, SupportSiteProtocol {
}
}
}

func getRoomList(_ url: String) -> Promise<(String, [BiliLiveVideoSelector])> {
var re = [BiliLiveVideoSelector]()

return AF.request(url).responseString().map { res -> [BiliLiveVideoSelector] in
let s = res.string.subString(from: "window.__initialState = ", to: ";\n")
guard let data = s.data(using: .utf8),
let json: JSONObject = try? JSONParser.JSONObjectWithData(data) else { return [] }

let list: [BiliLiveRoomList] = try json.value(for: "live-non-revenue-player")

re = list.first?.roomList.enumerated().map {
BiliLiveVideoSelector(
id: $0.element.roomId,
sid: "",
index: $0.offset,
title: $0.element.tabText, url: "")
} ?? []
return re
}.then {
self.liveInfos($0.compactMap({ Int($0.id) }))
}.map {
guard let json: JSONObject = try? JSONParser.JSONObjectWithData($0) else { return ("", []) }

try re.enumerated().forEach {
let info: BiliLiveBaseInfo = try json.value(for: "data.by_room_ids.\($0.element.id)")
re[$0.offset].isLiving = info.isLiving
re[$0.offset].url = info.url
re[$0.offset].sid = "\(info.shortId)"
}
return ("", re)
}
}

func liveInfos(_ roomIds: [Int]) -> Promise<Data> {
let s = roomIds.filter {
$0 > 0
}.map {
"room_ids=\($0)"
}.joined(separator: "&")

guard s.count > 0 else { return .value(Data()) }

let u = "https://api.live.bilibili.com/xlive/web-room/v1/index/getRoomBaseInfo?\(s)&req_biz=web_room_componet"

return AF.request(u).responseData().map({ $0.data })
}
}

struct BiliLiveInfo: Unmarshaling, LiveInfo {
Expand All @@ -133,6 +180,19 @@ struct BiliLiveInfo: Unmarshaling, LiveInfo {
}
}

struct BiliLiveBaseInfo: Unmarshaling {
let roomId: Int
let shortId: Int
let isLiving: Bool
let url: String

init(object: MarshaledObject) throws {
roomId = try object.value(for: "room_id")
shortId = try object.value(for: "short_id")
isLiving = try object.value(for: "live_status") == 1
url = try object.value(for: "live_url")
}
}

struct BiliLiveOldPlayUrl: Unmarshaling {
let currentQuality: Int
Expand Down Expand Up @@ -263,7 +323,7 @@ struct BiliLivePlayUrl: Unmarshaling {
var s = Stream(url: "")
s.quality = $0.qn
if codec.currentQn == $0.qn {
var urls = codec.urls()
var urls = MBGA.update(codec.urls())
s.url = urls.removeFirst()
s.src = urls
}
Expand All @@ -284,3 +344,35 @@ struct BiliLivePlayUrl: Unmarshaling {
return json
}
}

struct BiliLiveRoomList: Unmarshaling {
let defaultRoomId: String
let roomList: [Room]

struct Room: Unmarshaling {
let roomId: String
let tabText: String
init(object: MarshaledObject) throws {
roomId = try object.value(for: "roomId")
tabText = try object.value(for: "tabText")
}
}

init(object: MarshaledObject) throws {
defaultRoomId = try object.value(for: "defaultRoomId")
roomList = try object.value(for: "roomsConfig")
}
}


struct BiliLiveVideoSelector: VideoSelector {
let id: String
var sid: String
var coverUrl: URL?
var isLiving: Bool = false

let site = SupportSites.biliLive
let index: Int
let title: String
var url: String
}
43 changes: 30 additions & 13 deletions IINA+/Utils/VideoDecoder/Bilibili.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ class Bilibili: NSObject, SupportSiteProtocol {
switch bUrl.urlType {
case .video:
json.site = .bilibili
return getVideoList(url).compactMap { list -> YouGetJSON? in
return getVideoList(url).compactMap { eps -> YouGetJSON? in
let list = eps.flatMap({ $0.1 })
var selector = list.first
if let s = selector, s.isCollection {
selector = list.first(where: { $0.bvid == bUrl.id })
Expand All @@ -251,7 +252,7 @@ class Bilibili: NSObject, SupportSiteProtocol {
}
guard let s = selector else { return nil }

json.id = s.id
json.id = Int(s.id) ?? -1
json.bvid = s.bvid
json.title = s.title
json.duration = Int(s.duration)
Expand Down Expand Up @@ -370,7 +371,7 @@ class Bilibili: NSObject, SupportSiteProtocol {
}
}

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

Expand Down Expand Up @@ -411,7 +412,7 @@ class Bilibili: NSObject, SupportSiteProtocol {
infos.enumerated().forEach {
infos[$0.offset].bvid = bvid
}
return infos
return [("", infos)]
}
}
}
Expand Down Expand Up @@ -559,11 +560,14 @@ protocol BilibiliVideoSelector: VideoSelector {
}

struct BiliVideoSelector: Unmarshaling, BilibiliVideoSelector {
var url: String = ""
var isLiving: Bool = false

var bvid = ""
var isCollection = false

// epid
let id: Int
let id: String
var index: Int
let part: String
var duration: Int
Expand All @@ -580,7 +584,8 @@ struct BiliVideoSelector: Unmarshaling, BilibiliVideoSelector {
}

init(object: MarshaledObject) throws {
id = try object.value(for: "cid")
let cid: Int = try object.value(for: "cid")
id = "\(cid)"

if let pic: String = try? object.value(for: "arc.pic") {
coverUrl = .init(string: pic)
Expand All @@ -603,7 +608,7 @@ struct BiliVideoSelector: Unmarshaling, BilibiliVideoSelector {
}

init(ep: BangumiInfo.BangumiEp) {
id = ep.id
id = "\(ep.id)"
index = -1
part = ""
duration = 0
Expand All @@ -625,7 +630,7 @@ struct BilibiliVideoCollection: Unmarshaling {
let mid: Int
let epCount: Int
let isPaySeason: Bool
let episodes: [BiliVideoSelector]
let episodes: [(String, [BiliVideoSelector])]

init(object: MarshaledObject) throws {
id = try object.value(for: "id")
Expand All @@ -636,7 +641,9 @@ struct BilibiliVideoCollection: Unmarshaling {
isPaySeason = try object.value(for: "is_pay_season")

let s: [Section] = try object.value(for: "sections")
episodes = s.first?.episodes ?? []
episodes = s.map {
($0.title, $0.episodes)
}
}

struct Section: Unmarshaling {
Expand Down Expand Up @@ -853,10 +860,16 @@ struct BilibiliPlayInfo: Unmarshaling {
yougetJson.duration = duration

videos.enumerated().forEach {
var stream = Stream(url: $0.element.url)
var urls = $0.element.backupUrl
urls.append($0.element.url)
urls = MBGA.update(urls)

var stream = Stream(url: "")
// stream.quality = $0.element.bandwidth
stream.quality = 999 - $0.element.index
stream.src = $0.element.backupUrl

stream.url = urls.removeFirst()
stream.src = urls
yougetJson.streams[$0.element.description] = stream
}

Expand Down Expand Up @@ -905,8 +918,12 @@ struct BilibiliSimplePlayInfo: Unmarshaling {
var stream = yougetJson.streams[$0.value] ?? Stream(url: "")
if $0.key == quality,
let durl = durl.first {
stream.url = durl.url
stream.src = durl.backupUrls
var urls = durl.backupUrls
urls.append(durl.url)
urls = MBGA.update(urls)

stream.url = urls.removeFirst()
stream.src = urls
}
stream.quality = $0.key
yougetJson.streams[$0.value] = stream
Expand Down
Loading

0 comments on commit 8d2350a

Please sign in to comment.