Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
xjbeta committed Nov 18, 2021
2 parents 254de47 + 2ce2449 commit cd1726d
Show file tree
Hide file tree
Showing 19 changed files with 689 additions and 275 deletions.
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ github "apple/swift-protobuf" "1.18.0"
github "daltoniam/Starscream" "4.0.4"
github "httpswift/swifter" "1.5.0"
github "krzyzanowskim/CryptoSwift" "1.4.2"
github "mxcl/PromiseKit" "6.16.0"
github "mxcl/PromiseKit" "6.16.1"
github "scinfu/SwiftSoup" "2.3.3"
github "sparkle-project/Sparkle" "1.27.0"
github "sparkle-project/Sparkle" "1.27.1"
github "utahiosmac/Marshal" "1.2.8"
20 changes: 17 additions & 3 deletions IINA+.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
015C19DC218B0D4F003B2F3A /* VideoGetStructs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 015C19DB218B0D4F003B2F3A /* VideoGetStructs.swift */; };
015C19F7218FC9A8003B2F3A /* Block-List-Plus.xml in Resources */ = {isa = PBXBuildFile; fileRef = 015C19F5218FC9A8003B2F3A /* Block-List-Plus.xml */; };
015C19F8218FC9A8003B2F3A /* Block-List-Basic.xml in Resources */ = {isa = PBXBuildFile; fileRef = 015C19F6218FC9A8003B2F3A /* Block-List-Basic.xml */; };
015EDE27273D333900271901 /* LiveStateTransformers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 015EDE26273D333900271901 /* LiveStateTransformers.swift */; };
016792E1212BBB43003517A7 /* SelectVideoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016792E0212BBB43003517A7 /* SelectVideoViewController.swift */; };
016792E6212BDEE5003517A7 /* SelectVideoCollectionViewItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016792E4212BDEE5003517A7 /* SelectVideoCollectionViewItem.swift */; };
016792E7212BDEE5003517A7 /* SelectVideoCollectionViewItem.xib in Resources */ = {isa = PBXBuildFile; fileRef = 016792E5212BDEE5003517A7 /* SelectVideoCollectionViewItem.xib */; };
Expand All @@ -78,6 +79,8 @@
01683DDE211924160016A886 /* BilibiliViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01683DDD211924160016A886 /* BilibiliViewController.swift */; };
0169098021CF472F008CDF0E /* SideBarImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0169097F21CF472F008CDF0E /* SideBarImageView.swift */; };
0196CB6421214B4200BCD29E /* AdvancedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0196CB6321214B4200BCD29E /* AdvancedViewController.swift */; };
0199489E2742852E00C71708 /* SupportSites.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0199489D2742852E00C71708 /* SupportSites.swift */; };
019948BF2743DF3600C71708 /* ObjMenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 019948BE2743DF3600C71708 /* ObjMenuItem.swift */; };
01AEC8AB20EDFD01001406E8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01AEC8AA20EDFD01001406E8 /* AppDelegate.swift */; };
01AEC8AD20EDFD01001406E8 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01AEC8AC20EDFD01001406E8 /* MainViewController.swift */; };
01AEC8AF20EDFD02001406E8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 01AEC8AE20EDFD02001406E8 /* Assets.xcassets */; };
Expand Down Expand Up @@ -184,6 +187,7 @@
015C19DB218B0D4F003B2F3A /* VideoGetStructs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoGetStructs.swift; sourceTree = "<group>"; };
015C19F5218FC9A8003B2F3A /* Block-List-Plus.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "Block-List-Plus.xml"; sourceTree = "<group>"; };
015C19F6218FC9A8003B2F3A /* Block-List-Basic.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "Block-List-Basic.xml"; sourceTree = "<group>"; };
015EDE26273D333900271901 /* LiveStateTransformers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiveStateTransformers.swift; sourceTree = "<group>"; };
016792E0212BBB43003517A7 /* SelectVideoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectVideoViewController.swift; sourceTree = "<group>"; };
016792E4212BDEE5003517A7 /* SelectVideoCollectionViewItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectVideoCollectionViewItem.swift; sourceTree = "<group>"; };
016792E5212BDEE5003517A7 /* SelectVideoCollectionViewItem.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SelectVideoCollectionViewItem.xib; sourceTree = "<group>"; };
Expand All @@ -194,6 +198,9 @@
0169097F21CF472F008CDF0E /* SideBarImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideBarImageView.swift; sourceTree = "<group>"; };
016E07C326BB8FDF000AB100 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = "<group>"; };
0196CB6321214B4200BCD29E /* AdvancedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedViewController.swift; sourceTree = "<group>"; };
0199489D2742852E00C71708 /* SupportSites.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportSites.swift; sourceTree = "<group>"; };
019948BE2743DF3600C71708 /* ObjMenuItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjMenuItem.swift; sourceTree = "<group>"; };
019AFB5F27380DEA00B4E458 /* Bookmark v0.3.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Bookmark v0.3.xcdatamodel"; sourceTree = "<group>"; };
01AEC8A720EDFD01001406E8 /* IINA+.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "IINA+.app"; sourceTree = BUILT_PRODUCTS_DIR; };
01AEC8AA20EDFD01001406E8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
01AEC8AC20EDFD01001406E8 /* MainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -261,6 +268,7 @@
children = (
01398986210F58E500B7042F /* MainWindowTableRowView.swift */,
01F515192109F002007C7153 /* LiveStatusTableCellView.swift */,
015EDE26273D333900271901 /* LiveStateTransformers.swift */,
0101013821200DC5002F0F7F /* LiveUrlTableCellView.swift */,
012601732119FBF400C9C639 /* BilibiliCardTableCellView.swift */,
0101012F211E987D002F0F7F /* SuggestionsTableCellView.swift */,
Expand Down Expand Up @@ -304,6 +312,7 @@
013CE8F52185D992000271FB /* HttpServer.swift */,
013CE8DF21854813000271FB /* VideoGet.swift */,
015C19DB218B0D4F003B2F3A /* VideoGetStructs.swift */,
0199489D2742852E00C71708 /* SupportSites.swift */,
01683DDA2118905D0016A886 /* Bilibili.swift */,
01260177211ABD3B00C9C639 /* VideoViewsFormatter.swift */,
01E6A09B211AD62800C6EF98 /* VideoDurationFormatter.swift */,
Expand Down Expand Up @@ -335,6 +344,7 @@
016792E8212BF89A003517A7 /* SelectVideoCollectionView */,
010F0EF120F890DB00F33553 /* MainWindowController.swift */,
01AEC8AC20EDFD01001406E8 /* MainViewController.swift */,
019948BE2743DF3600C71708 /* ObjMenuItem.swift */,
01479CD4210AFACB0046AAAD /* AddBookmarkViewController.swift */,
01010136211EFA75002F0F7F /* SuggestionsTableView.swift */,
);
Expand Down Expand Up @@ -595,7 +605,9 @@
01AEC8C920F1081C001406E8 /* Identifiers.swift in Sources */,
01010125211DBC27002F0F7F /* StringExtension.swift in Sources */,
0196CB6421214B4200BCD29E /* AdvancedViewController.swift in Sources */,
0199489E2742852E00C71708 /* SupportSites.swift in Sources */,
01AEC8AD20EDFD01001406E8 /* MainViewController.swift in Sources */,
019948BF2743DF3600C71708 /* ObjMenuItem.swift in Sources */,
01683DDB2118905D0016A886 /* Bilibili.swift in Sources */,
01260178211ABD3B00C9C639 /* VideoViewsFormatter.swift in Sources */,
014B447E210069FF00E7AA6A /* BookmarkExtension.swift in Sources */,
Expand All @@ -610,6 +622,7 @@
01F5151A2109F002007C7153 /* LiveStatusTableCellView.swift in Sources */,
014B447D210069FF00E7AA6A /* Bookmark.swift in Sources */,
01398987210F58E500B7042F /* MainWindowTableRowView.swift in Sources */,
015EDE27273D333900271901 /* LiveStateTransformers.swift in Sources */,
01AEC8BC20EDFFBD001406E8 /* YouGetJSON.swift in Sources */,
0132B2E52123D68D001EB7DC /* BilibiliCardImageBoxView.swift in Sources */,
01683DD9211869AE0016A886 /* BilibiliLoginViewController.swift in Sources */,
Expand Down Expand Up @@ -788,7 +801,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 0.5.22;
MARKETING_VERSION = 0.5.23;
PRODUCT_BUNDLE_IDENTIFIER = "com.xjbeta.iina-plus";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -812,7 +825,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 0.5.22;
MARKETING_VERSION = 0.5.23;
PRODUCT_BUNDLE_IDENTIFIER = "com.xjbeta.iina-plus";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -849,10 +862,11 @@
010F0F1720FE4F0900F33553 /* DataModel.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
019AFB5F27380DEA00B4E458 /* Bookmark v0.3.xcdatamodel */,
014FD3A42115CB3000F05399 /* Bookmark v0.2.xcdatamodel */,
010F0F1820FE4F0900F33553 /* Bookmark.xcdatamodel */,
);
currentVersion = 014FD3A42115CB3000F05399 /* Bookmark v0.2.xcdatamodel */;
currentVersion = 019AFB5F27380DEA00B4E458 /* Bookmark v0.3.xcdatamodel */;
path = DataModel.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
Expand Down
59 changes: 59 additions & 0 deletions IINA+/Core Data/Bookmark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,69 @@
//
//

import Cocoa
import Foundation
import CoreData

//@objc(Bookmark)
public class Bookmark: NSManagedObject {

lazy var site: SupportSites = {
SupportSites(url: url)
}()

func updateState() {
if site == .unsupported {
self.state = -1
self.save()
return
}

let limitSec: CGFloat = [.bangumi, .bilibili, .unsupported].contains(site) ? 300 : 20

if let d = updateDate?.timeIntervalSince1970,
(Date().timeIntervalSince1970 - d) < limitSec {
return
}

Processes.shared.videoGet.liveInfo(url).done(on: .main) {
self.setInfo($0)
}.catch(on: .main) {
let s = "Get live status error: \($0) \n - \(self.url)"
Log(s)
self.liveTitle = self.url
self.state = -1
self.save()
}
}

private func setInfo(_ info: LiveInfo) {
liveTitle = info.title
liveName = info.name

let isLiveSite = site != .bangumi && site != .bilibili

cover = isLiveSite ? info.avatar : info.cover
cover?.coverUrlFormatter(site: site)

if info.site == .bangumi {
liveName = "Bangumi"
}

if isLiveSite {
state = info.isLiving ? 1 : 0
} else if info.site == .bangumi || info.site == .bilibili {
state = -99
} else {
state = -1
}

updateDate = Date()

save()
}

func save() {
try? (NSApp.delegate as? AppDelegate)?.persistentContainer.viewContext.save()
}
}
6 changes: 5 additions & 1 deletion IINA+/Core Data/BookmarkExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ extension Bookmark {
@NSManaged public var order: Double
@NSManaged public var remark: String?
@NSManaged public var url: String

@NSManaged public var state: Int16
@NSManaged public var liveTitle: String
@NSManaged public var liveName: String
@NSManaged public var updateDate: Date?
@NSManaged public var cover: String?
}
2 changes: 1 addition & 1 deletion IINA+/Core Data/DataModel.xcdatamodeld/.xccurrentversion
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>Bookmark v0.2.xcdatamodel</string>
<string>Bookmark v0.3.xcdatamodel</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="19461" systemVersion="21A559" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="Bookmark" representedClassName=".Bookmark" versionHashModifier="added order" syncable="YES">
<attribute name="cover" optional="YES" attributeType="String"/>
<attribute name="liveName" optional="YES" attributeType="String" defaultValueString=""/>
<attribute name="liveTitle" optional="YES" attributeType="String" defaultValueString=""/>
<attribute name="order" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
<attribute name="remark" optional="YES" attributeType="String"/>
<attribute name="state" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="updateDate" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="url" optional="YES" attributeType="String" defaultValueString="https://live.bilibili.com/1010"/>
</entity>
<elements>
<element name="Bookmark" positionX="-103.39453125" positionY="-9" width="177.39453125" height="149"/>
</elements>
</model>
2 changes: 1 addition & 1 deletion IINA+/Utils/Bilibili.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ struct BilibiliVideoSelector: Unmarshaling, VideoSelector {
let longTitle: String
let coverUrl: URL?
let badge: Badge?
let site: LiveSupportList
let site: SupportSites

struct Badge {
let badge: String
Expand Down
4 changes: 2 additions & 2 deletions IINA+/Utils/Danmaku.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protocol DanmakuDelegate {

class Danmaku: NSObject {
var socket: WebSocket? = nil
var liveSite: LiveSupportList = .unsupported
var liveSite: SupportSites = .unsupported
var url = ""
var id = ""
var delegate: DanmakuDelegate?
Expand Down Expand Up @@ -61,7 +61,7 @@ class Danmaku: NSObject {



init(_ site: LiveSupportList, url: String) {
init(_ site: SupportSites, url: String) {
liveSite = site
self.url = url

Expand Down
4 changes: 2 additions & 2 deletions IINA+/Utils/HttpServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class HttpServer: NSObject, DanmakuDelegate {


var id: String
var site: LiveSupportList
var site: SupportSites
var url: String
var session: WebSocketSession? = nil
var danmaku: Danmaku
Expand All @@ -53,7 +53,7 @@ class HttpServer: NSObject, DanmakuDelegate {
let videoGet = VideoGet()

func register(_ id: String,
site: LiveSupportList,
site: SupportSites,
url: String) {
let d = Danmaku(site, url: url)
d.id = id
Expand Down
20 changes: 20 additions & 0 deletions IINA+/Utils/StringExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,24 @@ extension String {
}
}
}

mutating func coverUrlFormatter(
site: SupportSites,
maxH: Int = 200) {

var u = self
switch site {
case .biliLive, .bilibili, .bangumi:
u += "@\(maxH)h"
case .huya, .eGame:
// default 140x140
break
case .douyu, .cc163:
// default 200x200
break
default:
break
}
self = u
}
}
74 changes: 74 additions & 0 deletions IINA+/Utils/SupportSites.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// SupportSites.swift
// IINA+
//
// Created by xjbeta on 11/15/21.
// Copyright © 2021 xjbeta. All rights reserved.
//

import Cocoa

enum SupportSites: String {
case biliLive = "live.bilibili.com"
case bilibili = "www.bilibili.com/video"
case bangumi = "www.bilibili.com/bangumi"
case douyu = "www.douyu.com"
case huya = "www.huya.com"
case quanmin = "www.quanmin.tv"
case longzhu = "star.longzhu.com"
case eGame = "egame.qq.com"
// case yizhibo = "www.yizhibo.com"
case langPlay = "play.lang.live"
case cc163 = "cc.163.com"
case unsupported

var siteName: String {
switch self {
case .biliLive:
return "Bilibili Live"
case .bilibili:
return "Bilibili"
case .bangumi:
return "Bilibili Bangumi"
case .douyu:
return "Douyu"
case .huya:
return "Huya"
case .quanmin:
return "QuanMin"
case .longzhu:
return "LongZhu"
case .eGame:
return "eGame"
case .langPlay:
return "LangPlay"
case .cc163:
return "CC163"
case .unsupported:
return "Unsupported"
}
}

init(url: String) {
guard let u = URL(string: url) else {
self = .unsupported
return
}

let host = u.host ?? ""
if host == "www.bilibili.com", u.pathComponents.count >= 2 {
switch u.pathComponents[1] {
case "video":
self = .bilibili
case "bangumi":
self = .bangumi
default:
self = .unsupported
}
} else if let list = SupportSites(rawValue: host) {
self = list
} else {
self = .unsupported
}
}
}
Loading

0 comments on commit cd1726d

Please sign in to comment.