From 9a69e4b06d02d545774813eb2034d72f8caae1a1 Mon Sep 17 00:00:00 2001 From: WindowsMEMZ <45706356+WindowsMEMZ@users.noreply.github.com> Date: Sun, 26 Nov 2023 15:47:52 +0800 Subject: [PATCH 1/4] Update VideoDetailView.swift --- DarockBili Watch App/Video/VideoDetailView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DarockBili Watch App/Video/VideoDetailView.swift b/DarockBili Watch App/Video/VideoDetailView.swift index 18114704c..8e85bd5e8 100644 --- a/DarockBili Watch App/Video/VideoDetailView.swift +++ b/DarockBili Watch App/Video/VideoDetailView.swift @@ -303,7 +303,7 @@ struct VideoDetailView: View { if isSuccess { debugPrint("----------Prints from VideoDetailView.onAppear.*.requsetJSON(*/view)----------") debugPrint(respJson) - owner = ["Name": respJson["data"]["owner"]["name"].string ?? "[加载失败]", "Face": respJson["data"]["owner"]["face"].string ?? "E", "ID": String(respJson["data"]["owner"]["mid"].int ?? -1)] + owner = ["Name": respJson["data"]["owner"]["name"].string ?? "[加载失败]", "Face": respJson["data"]["owner"]["face"].string ?? "E", "ID": String(respJson["data"]["owner"]["mid"].int64 ?? -1)] stat = ["Like": String(respJson["data"]["stat"]["like"].int ?? -1), "Coin": String(respJson["data"]["stat"]["coin"].int ?? -1), "Favorite": String(respJson["data"]["stat"]["favorite"].int ?? -1)] videoDesc = respJson["data"]["desc"].string ?? "[加载失败]".replacingOccurrences(of: "\\n", with: "\n") for _ in 1...4 { From 74c635d1043a2e65b1c7052b5c70f5135fc87c57 Mon Sep 17 00:00:00 2001 From: WindowsMEMZ <45706356+WindowsMEMZ@users.noreply.github.com> Date: Sun, 26 Nov 2023 21:53:18 +0800 Subject: [PATCH 2/4] Update FollowListView.swift --- DarockBili Watch App/PersonalCenter/FollowListView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DarockBili Watch App/PersonalCenter/FollowListView.swift b/DarockBili Watch App/PersonalCenter/FollowListView.swift index 123afc37f..6a249bb20 100644 --- a/DarockBili Watch App/PersonalCenter/FollowListView.swift +++ b/DarockBili Watch App/PersonalCenter/FollowListView.swift @@ -109,9 +109,9 @@ struct FollowListView: View { let datas = respJson["data"]["list"] for data in datas { if pinnedUsers.contains(String(data.1["mid"].int ?? 0)) { - users.insert(["Name": data.1["uname"].string ?? "[加载失败]", "Face": data.1["face"].string ?? "E", "Sign": data.1["sign"].string ?? "[加载失败]", "UID": String(data.1["mid"].int ?? 0)], at: 0) + users.insert(["Name": data.1["uname"].string ?? "[加载失败]", "Face": data.1["face"].string ?? "E", "Sign": data.1["sign"].string ?? "[加载失败]", "UID": String(data.1["mid"].int64 ?? 0)], at: 0) } else { - users.append(["Name": data.1["uname"].string ?? "[加载失败]", "Face": data.1["face"].string ?? "E", "Sign": data.1["sign"].string ?? "[加载失败]", "UID": String(data.1["mid"].int ?? 0)]) + users.append(["Name": data.1["uname"].string ?? "[加载失败]", "Face": data.1["face"].string ?? "E", "Sign": data.1["sign"].string ?? "[加载失败]", "UID": String(data.1["mid"].int64 ?? 0)]) } } totalPage = respJson["data"]["total"].int ?? 0 / 20 + 1 From 04cdb1e39c4c90e172a3f750d3a7cfe39a058ddc Mon Sep 17 00:00:00 2001 From: WindowsMEMZ <45706356+WindowsMEMZ@users.noreply.github.com> Date: Mon, 27 Nov 2023 00:50:28 +0800 Subject: [PATCH 3/4] Update VideoCommentsView.swift Removed an outdated `#if swift(>=5.9)` code --- DarockBili Watch App/Video/VideoCommentsView.swift | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/DarockBili Watch App/Video/VideoCommentsView.swift b/DarockBili Watch App/Video/VideoCommentsView.swift index 956992afa..ed9578fd0 100644 --- a/DarockBili Watch App/Video/VideoCommentsView.swift +++ b/DarockBili Watch App/Video/VideoCommentsView.swift @@ -60,7 +60,6 @@ struct VideoCommentsView: View { var body: some View { ScrollView { LazyVStack { - #if swift(>=5.9) if #unavailable(watchOS 10) { Button(action: { isSendCommentPresented = true @@ -72,17 +71,6 @@ struct VideoCommentsView: View { }) .sheet(isPresented: $isSendCommentPresented, content: {CommentSendView(oid: oid)}) } - #else - Button(action: { - isSendCommentPresented = true - }, label: { - HStack { - Image(systemName: "square.and.pencil") - Text("发送评论") - } - }) - .sheet(isPresented: $isSendCommentPresented, content: {CommentSendView(oid: oid)}) - #endif if comments.count != 0 { ForEach(0...comments.count - 1, id: \.self) { i in VStack { From 086f9a1d7c0701b87459e1239bee3ec2838731ad Mon Sep 17 00:00:00 2001 From: Mark Chan <45706356+WindowsMEMZ@users.noreply.github.com> Date: Sat, 2 Dec 2023 15:23:28 +0800 Subject: [PATCH 4/4] Merge main branch to fix/long-uid (#20) * Update status-check.yml * Delete .github/workflows/codeql.yml * Update status-check.yml * Create statuscheck-runner.yml * Update ios.yml * Update statuscheck-runner.yml * Update statuscheck-runner.yml * Update statuscheck-runner.yml * Add license comments for code files (#13) * Update ErrorGetView.swift * Update FeedbackView.swift * Update MemoryWarningView.swift * Update SignalErrorView.swift * Update AppFileManager.swift * Update CodeExt.swift * Update UIExt.swift * Update ContentView.swift * Update MainView.swift * Update SearchView.swift * Update LivePlayerView.swift * Update OfflineMainView.swift * Update AboutView.swift * Update FirstUsingView.swift * Update LoginView.swift * Update NoticeView.swift * Update SettingsView.swift * Update bMessageSendView.swift * Update ArticleView.swift * Update DownloadsView.swift * Update FavoriteView.swift * Update FollowListView.swift * Update HistoryView.swift * Update PersonAccountView.swift * Update UserDetailView.swift * Update WatchLaterView.swift * Update ImageViewerView.swift * Update UserDynamicMainView.swift * Update AudioPlayerView.swift * Update LyricerView.swift * Update VideoCommentsView.swift * Update VideoDetailView.swift * Update VideoDownloadView.swift * Update VideoPlayerView.swift * Update DarockBiliApp.swift * Update status-check.yml * Update statuscheck-runner.yml * Update status-check.yml * Update statuscheck-runner.yml * Update statuscheck-runner.yml * Update statuscheck-runner.yml * Update statuscheck-runner.yml * Update status-check.yml * Update statuscheck-runner.yml * Update statuscheck-runner.yml * Update status-check.yml * Update statuscheck-runner.yml * Update statuscheck-runner.yml * Merge next branch to main (#19) * Fix Crash Issue when Seeing User's Videos in UserDetailsView (#15) * Update UserDetailView.swift * Merge main workflows (#16) * Update status-check.yml * Update statuscheck-runner.yml * Update CodeExt.swift * Update UserDetailView.swift Fixed optional unwrap issue * Update status-check.yml * Update status-check.yml * Update status-check.yml * Update status-check.yml * Update status-check.yml * Update status-check.yml * Update UserDetailView.swift * Add local wbi sign feature (#18) * Update CodeExt.swift Added wbi calculation logic * Update MainView.swift * Update PersonAccountView.swift * Update UserDetailView.swift Might fix the article access issue at the same time. * Update CodeExt.swift * Update CodeExt.swift * Update CodeExt.swift * Update status-check.yml * Update status-check.yml * Update CodeExt.swift --- .github/workflows/codeql.yml | 51 ------ .github/workflows/ios.yml | 7 +- .github/workflows/status-check.yml | 56 +++++- .github/workflows/statuscheck-runner.yml | 53 ++++++ DarockBili Watch App/DarockBiliApp.swift | 10 ++ .../Errors/ErrorGetView.swift | 10 ++ .../Errors/FeedbackView.swift | 10 ++ .../Errors/MemoryWarningView.swift | 10 ++ .../Errors/SignalErrorView.swift | 10 ++ .../Extension/AppFileManager.swift | 10 ++ DarockBili Watch App/Extension/CodeExt.swift | 164 ++++++++---------- DarockBili Watch App/Extension/UIExt.swift | 10 ++ DarockBili Watch App/InMain/ContentView.swift | 10 ++ DarockBili Watch App/InMain/MainView.swift | 18 +- DarockBili Watch App/InMain/SearchView.swift | 10 ++ .../Live/LivePlayerView.swift | 10 ++ .../Offline/OfflineMainView.swift | 10 ++ DarockBili Watch App/Others/AboutView.swift | 10 ++ .../Others/FirstUsingView.swift | 10 ++ DarockBili Watch App/Others/LoginView.swift | 10 ++ DarockBili Watch App/Others/NoticeView.swift | 10 ++ .../Others/SettingsView.swift | 10 ++ .../PersonalCenter/ArticleView.swift | 10 ++ .../PersonalCenter/DownloadsView.swift | 10 ++ .../PersonalCenter/FavoriteView.swift | 10 ++ .../PersonalCenter/FollowListView.swift | 10 ++ .../PersonalCenter/HistoryView.swift | 10 ++ .../PersonalCenter/PersonAccountView.swift | 18 +- .../PersonalCenter/UserDetailView.swift | 50 ++++-- .../PersonalCenter/WatchLaterView.swift | 10 ++ .../bMessage/bMessageSendView.swift | 10 ++ .../UserDynamic/ImageViewerView.swift | 10 ++ .../UserDynamic/UserDynamicMainView.swift | 10 ++ .../Video/AudioPlayerView.swift | 10 ++ DarockBili Watch App/Video/LyricerView.swift | 10 ++ .../Video/VideoCommentsView.swift | 10 ++ .../Video/VideoDetailView.swift | 10 ++ .../Video/VideoDownloadView.swift | 10 ++ .../Video/VideoPlayerView.swift | 10 ++ 39 files changed, 550 insertions(+), 177 deletions(-) delete mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/statuscheck-runner.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 51e113a69..000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - analyze: - name: Analyze - # Runner size impacts CodeQL analysis time. To learn more, please see: - # - https://gh.io/recommended-hardware-resources-for-running-codeql - # - https://gh.io/supported-runners-and-hardware-resources - # - https://gh.io/using-larger-runners - # Consider using larger runners for possible analysis time improvements. - runs-on: macos-13 - timeout-minutes: 120 - permissions: - actions: read - contents: read - security-events: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set Xcode Version - run: sudo xcode-select -s /Applications/Xcode_15.0.app - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: swift - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - - name: Build - run: | - xcodebuild build -project DarockBili.xcodeproj -scheme "DarockBili Watch App" CODE_SIGN_IDENTITY="" - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:swift" diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 4aeb87993..10f7fdbbf 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -4,11 +4,8 @@ on: push: branches: [ "main" ] paths-ignore: - - '.github/workflows/codeql.yml' - pull_request: - branches: [ "main" ] - paths-ignore: - - '.github/workflows/codeql.yml' + - '.github/workflows/*' + - '!.github/workflows/ios.yml' jobs: build: diff --git a/.github/workflows/status-check.yml b/.github/workflows/status-check.yml index e52f3c8dc..482b147f2 100644 --- a/.github/workflows/status-check.yml +++ b/.github/workflows/status-check.yml @@ -1,30 +1,72 @@ name: Status Check Workflow -on: - push: - branches: [ "*" ] - pull_request: - branches: [ "*" ] +on: + workflow_dispatch: + inputs: + psha: + required: true jobs: build: name: Check Build runs-on: macos-13 + permissions: + checks: write + statuses: write + env: + FIN_STATUS: "error" + GH_TOKEN: ${{ github.token }} steps: + - name: Update Check Status + run: | + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{ github.repository }}/statuses/$GITHUB_SHA \ + -f state='pending' \ + -f target_url='https://github.com/Darock-Studio/Darock-Bili/actions/runs/${{ github.run_id }}' \ + -f description='Building...' \ + -f context='API Status Checker' + - name: Checkout uses: actions/checkout@v3 + with: + ref: ${{ inputs.psha }} - name: Set Xcode Version run: sudo xcode-select -s /Applications/Xcode_15.0.app + - name: Get Current Time + id: current-time + run: echo "time=$(date +"%Y%m%d%H%M%S")" >> $GITHUB_OUTPUT + - name: Cache Build Caches uses: actions/cache@v3 with: - key: check-build-cache + key: ${{ runner.os }}-check-build-cache-${{ steps.current-time.outputs.time }} path: | ~/Library/Developer/Xcode/DerivedData + restore-keys: | + ${{ runner.os }}-check-build-cache- + + - name: Update Status Env + run: echo "FIN_STATUS=failure" >> $GITHUB_ENV - name: Build DarockBili App run: | xcodebuild -scheme 'DarockBili Watch App' -configuration Release build CODE_SIGN_IDENTITY="" - + echo "FIN_STATUS=success" >> $GITHUB_ENV + + - name: Update Check Status + if: always() + run: | + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{ github.repository }}/statuses/$GITHUB_SHA \ + -f state='${{ env.FIN_STATUS }}' \ + -f target_url='https://github.com/Darock-Studio/Darock-Bili/actions/runs/${{ github.run_id }}' \ + -f context='API Status Checker' + diff --git a/.github/workflows/statuscheck-runner.yml b/.github/workflows/statuscheck-runner.yml new file mode 100644 index 000000000..9a06b1fbe --- /dev/null +++ b/.github/workflows/statuscheck-runner.yml @@ -0,0 +1,53 @@ +name: Status Check Runner + +on: + issue_comment: + types: + - created + +jobs: + checkif: + runs-on: ubuntu-latest + name: Check Comment Content + outputs: + shouldc: ${{ steps.checkc.outputs.shouldc }} + steps: + - name: Check + id: checkc + run: | + if [[ "${{ github.event.comment.body }}" != *"!Run check"* ]]; then + echo "The comment content does not contain the specified text. Cancelling workflow." + echo "::set-output name=shouldc::false" + else + echo "The comment content contains the specified text. Continuing with further actions." + echo "::set-output name=shouldc::true" + fi + get-head-sha: + name: Get Pull Request Head SHA + needs: checkif + if: ${{ needs.checkif.outputs.shouldc == 'true' }} + runs-on: ubuntu-latest + outputs: + psha: ${{ steps.getsha.outputs.psha }} + env: + slink: ${{ github.event.issue.pull_request.url }} + steps: + - name: Get SHA + id: getsha + run: | + json_data=$(curl -s "$slink") + sha=$(echo "$json_data" | jq -r '.head.ref') + echo "psha=$sha" >> $GITHUB_OUTPUT + call-check-workflow: + name: Call Check Overflow + needs: get-head-sha + permissions: + actions: write + runs-on: ubuntu-latest + steps: + - name: Call + uses: benc-uk/workflow-dispatch@v1.2.2 + with: + workflow: status-check.yml + ref: ${{ needs.get-head-sha.outputs.psha }} + inputs: '{ "psha": "${{ needs.get-head-sha.outputs.psha }}"}' diff --git a/DarockBili Watch App/DarockBiliApp.swift b/DarockBili Watch App/DarockBiliApp.swift index 1d37a571d..af5fdc1ef 100644 --- a/DarockBili Watch App/DarockBiliApp.swift +++ b/DarockBili Watch App/DarockBiliApp.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/6/30. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import Darwin import SwiftUI diff --git a/DarockBili Watch App/Errors/ErrorGetView.swift b/DarockBili Watch App/Errors/ErrorGetView.swift index daa25fc55..ea6cc64d5 100644 --- a/DarockBili Watch App/Errors/ErrorGetView.swift +++ b/DarockBili Watch App/Errors/ErrorGetView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/4. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/Errors/FeedbackView.swift b/DarockBili Watch App/Errors/FeedbackView.swift index 5d1cbe642..63691671e 100644 --- a/DarockBili Watch App/Errors/FeedbackView.swift +++ b/DarockBili Watch App/Errors/FeedbackView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/5. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/Errors/MemoryWarningView.swift b/DarockBili Watch App/Errors/MemoryWarningView.swift index e7b39a131..0a405f1a8 100644 --- a/DarockBili Watch App/Errors/MemoryWarningView.swift +++ b/DarockBili Watch App/Errors/MemoryWarningView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/24. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI diff --git a/DarockBili Watch App/Errors/SignalErrorView.swift b/DarockBili Watch App/Errors/SignalErrorView.swift index 1de234ecf..a1a8881dd 100644 --- a/DarockBili Watch App/Errors/SignalErrorView.swift +++ b/DarockBili Watch App/Errors/SignalErrorView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/14. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/Extension/AppFileManager.swift b/DarockBili Watch App/Extension/AppFileManager.swift index fbe023e3f..792bdcafd 100644 --- a/DarockBili Watch App/Extension/AppFileManager.swift +++ b/DarockBili Watch App/Extension/AppFileManager.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/4. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import Foundation diff --git a/DarockBili Watch App/Extension/CodeExt.swift b/DarockBili Watch App/Extension/CodeExt.swift index f2631cf4b..6a2e8ad3a 100644 --- a/DarockBili Watch App/Extension/CodeExt.swift +++ b/DarockBili Watch App/Extension/CodeExt.swift @@ -4,13 +4,24 @@ // // Created by WindowsMEMZ on 2023/7/6. // - +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import OSLog import SwiftUI import Dynamic import CryptoKit +import DarockKit import Alamofire +import SwiftyJSON import Foundation import AVFoundation import CommonCrypto @@ -127,86 +138,77 @@ public func hideDigitalTime(_ b: Bool) { app._setStatusBarTimeHidden(b, animated: true, completion: nil) } -public class WbiSign: ObservableObject { - @State var img_key = "" - @State var sub_key = "" - func MD5Hash(_ string: String) -> String { - let data = Data(string.utf8) - var hash = [UInt8](repeating: 0, count: Int(CC_MD5_DIGEST_LENGTH)) - data.withUnsafeBytes { bytes in - _ = CC_MD5(bytes.baseAddress, CC_LONG(data.count), &hash) - } - return hash.map { String(format: "%02x", $0) }.joined() - } - static let mixinKeyEncTab: [Int] = [46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11, 36, 20, 34, 44, 52] - - func getMixinKey(orig: String) -> String { - let result = WbiSign.mixinKeyEncTab.reduce("") { result, index in - if index < orig.count { - let start = orig.index(orig.startIndex, offsetBy: index) - return result + String(orig[start]) - } else { - return result - } - } - print("Mixin Key: \(result)") - return result - } - - func filterInvalidCharacters(from value: Any) -> String { - let invalidCharacters = CharacterSet(charactersIn: "!'()*") - if let strValue = value as? String { - return strValue.components(separatedBy: invalidCharacters).joined() - } else { - return String(describing: value) - } - } - - func md5(data: String) -> String { - let digest = Insecure.MD5.hash(data: data.data(using: .utf8) ?? Data()) - return digest.map { String(format: "%02hhx", $0) }.joined() +func biliWbiSign(paramEncoded: String, completion: @escaping (String?) -> Void) { + func getMixinKey(orig: String) -> String { + return String(mixinKeyEncTab.map { orig[orig.index(orig.startIndex, offsetBy: $0)] }.prefix(32)) } - func encWbi(params: [String: Any]) -> String { - var newParams = params - let mixinKey = getMixinKey(orig: img_key + sub_key) - let currTime = Int(Date().timeIntervalSince1970) - newParams["wts"] = currTime - let sortedParams = newParams.sorted { $0.key < $1.key } - let query = sortedParams.map { "\($0.key)=\(filterInvalidCharacters(from: $0.value))" }.joined(separator: "&") - print("Query: \(query + mixinKey)") - let dataToHash = (query.urlEncoded() + mixinKey.prefix(32)) - let wbiSign = (dataToHash).DDMD5Encrypt() - print("WBI Sign: \(wbiSign)") - newParams["w_rid"] = wbiSign - var paramStr = "" - for param in newParams { - paramStr += "\(param.key)=\(param.value)&" - } - paramStr.removeLast() - return paramStr + func encWbi(params: [String: Any], imgKey: String, subKey: String) -> [String: Any] { + var params = params + let mixinKey = getMixinKey(orig: imgKey + subKey) + let currTime = round(Date().timeIntervalSince1970) + params["wts"] = currTime + params = params.sorted { $0.key < $1.key }.reduce(into: [:]) { $0[$1.key] = $1.value } + params = params.mapValues { String(describing: $0).filter { !"!'()*".contains($0) } } + let query = params.map { "\($0.key)=\($0.value)" }.joined(separator: "&") + let wbiSign = calculateMD5(string: query + mixinKey) + params["w_rid"] = wbiSign + return params } - - func getWbiKeys(completionHandler: @escaping (String, String) -> Void) { + + func getWbiKeys(completion: @escaping (Result<(imgKey: String, subKey: String), Error>) -> Void) { AF.request("https://api.bilibili.com/x/web-interface/nav").responseJSON { response in switch response.result { case .success(let value): - if let dict = value as? [String: Any], - let data = dict["data"] as? [String: Any], - let wbiImg = data["wbi_img"] as? [String: Any], - let imgUrl = wbiImg["img_url"] as? String, - let subUrl = wbiImg["sub_url"] as? String { - let imgKey = String(imgUrl.split(separator: "/").last!.split(separator: ".").first!) - let subKey = String(subUrl.split(separator: "/").last!.split(separator: ".").first!) - print("Image Key: \(imgKey)") - print("Sub Key: \(subKey)") - completionHandler(imgKey, subKey) - } + let json = JSON(value) + let imgURL = json["data"]["wbi_img"]["img_url"].string ?? "" + let subURL = json["data"]["wbi_img"]["sub_url"].string ?? "" + let imgKey = imgURL.components(separatedBy: "/").last?.components(separatedBy: ".").first ?? "" + let subKey = subURL.components(separatedBy: "/").last?.components(separatedBy: ".").first ?? "" + completion(.success((imgKey, subKey))) case .failure(let error): - print(error) + completion(.failure(error)) } } } + + func calculateMD5(string: String) -> String { + let data = Data(string.utf8) + var digest = [UInt8](repeating: 0, count: Int(CC_MD5_DIGEST_LENGTH)) + _ = data.withUnsafeBytes { + CC_MD5($0.baseAddress, CC_LONG(data.count), &digest) + } + return digest.map { String(format: "%02hhx", $0) }.joined() + } + + let mixinKeyEncTab = [ + 46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, + 33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, + 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11, + 36, 20, 34, 44, 52 + ] + + getWbiKeys { result in + switch result { + case .success(let keys): + let decParam = paramEncoded.base64Decoded() ?? "" + let spdParam = decParam.components(separatedBy: "&") + var spdDicParam = [String: String]() + spdParam.forEach { pair in + let components = pair.components(separatedBy: "=") + if components.count == 2 { + spdDicParam[components[0]] = components[1] + } + } + + let signedParams = encWbi(params: spdDicParam, imgKey: keys.imgKey, subKey: keys.subKey) + let query = signedParams.map { "\($0.key)=\($0.value)" }.joined(separator: "&") + completion(query) + case .failure(let error): + print("Error getting keys: \(error)") + completion(nil) + } + } } postfix operator ++ @@ -239,24 +241,4 @@ extension Int { } } -postfix operator / -extension Optional { - static postfix func / (opt: Int?) -> Int { - return opt ?? 0 - } - static postfix func / (opt: String?) -> String { - return opt ?? "" - } - static postfix func / (opt: Double?) -> Double { - return opt ?? 0.0 - } - static postfix func / (opt: Float?) -> Float { - return opt ?? 0.0 - } - static postfix func / (opt: Bool?) -> Bool { - return opt ?? false - } -} - - diff --git a/DarockBili Watch App/Extension/UIExt.swift b/DarockBili Watch App/Extension/UIExt.swift index 7688d2477..de291e5a1 100644 --- a/DarockBili Watch App/Extension/UIExt.swift +++ b/DarockBili Watch App/Extension/UIExt.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/8. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import UIKit import SwiftUI diff --git a/DarockBili Watch App/InMain/ContentView.swift b/DarockBili Watch App/InMain/ContentView.swift index bafff55e5..ef6b0a7d6 100644 --- a/DarockBili Watch App/InMain/ContentView.swift +++ b/DarockBili Watch App/InMain/ContentView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/6/30. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI diff --git a/DarockBili Watch App/InMain/MainView.swift b/DarockBili Watch App/InMain/MainView.swift index cf30e2ef1..1c1884507 100644 --- a/DarockBili Watch App/InMain/MainView.swift +++ b/DarockBili Watch App/InMain/MainView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/6/30. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit @@ -150,10 +160,10 @@ struct MainView: View { let headers: HTTPHeaders = [ "cookie": "SESSDATA=\(sessdata)" ] - DarockKit.Network.shared.requestString("https://api.darock.top/bili/wbi/sign/\("ps=\(isInLowBatteryMode ? 10 : 30)".base64Encoded())") { respStr, isSuccess in - if isSuccess { - debugPrint(respStr.apiFixed()) - DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/web-interface/wbi/index/top/feed/rcmd?\(respStr.apiFixed())", headers: headers) { respJson, isSuccess in + biliWbiSign(paramEncoded: "ps=\(isInLowBatteryMode ? 10 : 30)".base64Encoded()) { signed in + if let signed { + debugPrint(signed) + DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/web-interface/wbi/index/top/feed/rcmd?\(signed)", headers: headers) { respJson, isSuccess in if isSuccess { debugPrint(respJson) let datas = respJson["data"]["item"] diff --git a/DarockBili Watch App/InMain/SearchView.swift b/DarockBili Watch App/InMain/SearchView.swift index b0e0ca82e..b4305e70d 100644 --- a/DarockBili Watch App/InMain/SearchView.swift +++ b/DarockBili Watch App/InMain/SearchView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/1. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/Live/LivePlayerView.swift b/DarockBili Watch App/Live/LivePlayerView.swift index fcf6288ae..ae0b7f84b 100644 --- a/DarockBili Watch App/Live/LivePlayerView.swift +++ b/DarockBili Watch App/Live/LivePlayerView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/28. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import AVKit import SwiftUI diff --git a/DarockBili Watch App/Offline/OfflineMainView.swift b/DarockBili Watch App/Offline/OfflineMainView.swift index 70ec4d5d1..06f0550a4 100644 --- a/DarockBili Watch App/Offline/OfflineMainView.swift +++ b/DarockBili Watch App/Offline/OfflineMainView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/11/3. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI diff --git a/DarockBili Watch App/Others/AboutView.swift b/DarockBili Watch App/Others/AboutView.swift index 5233d720b..3d703e33d 100644 --- a/DarockBili Watch App/Others/AboutView.swift +++ b/DarockBili Watch App/Others/AboutView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/2. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/Others/FirstUsingView.swift b/DarockBili Watch App/Others/FirstUsingView.swift index bb7fea376..88e0d0e59 100644 --- a/DarockBili Watch App/Others/FirstUsingView.swift +++ b/DarockBili Watch App/Others/FirstUsingView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/2. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI diff --git a/DarockBili Watch App/Others/LoginView.swift b/DarockBili Watch App/Others/LoginView.swift index 475b1ec14..4a8bf348c 100644 --- a/DarockBili Watch App/Others/LoginView.swift +++ b/DarockBili Watch App/Others/LoginView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/6/30. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/Others/NoticeView.swift b/DarockBili Watch App/Others/NoticeView.swift index 38875c49c..543ec7cb2 100644 --- a/DarockBili Watch App/Others/NoticeView.swift +++ b/DarockBili Watch App/Others/NoticeView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/2. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/Others/SettingsView.swift b/DarockBili Watch App/Others/SettingsView.swift index 23d6c7f75..8d3a25f69 100644 --- a/DarockBili Watch App/Others/SettingsView.swift +++ b/DarockBili Watch App/Others/SettingsView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/5. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import Charts import SwiftUI diff --git a/DarockBili Watch App/PersonalCenter/ArticleView.swift b/DarockBili Watch App/PersonalCenter/ArticleView.swift index f80ac0631..708a38454 100644 --- a/DarockBili Watch App/PersonalCenter/ArticleView.swift +++ b/DarockBili Watch App/PersonalCenter/ArticleView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/1. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/PersonalCenter/DownloadsView.swift b/DarockBili Watch App/PersonalCenter/DownloadsView.swift index 27e16a95a..6cbcd30c2 100644 --- a/DarockBili Watch App/PersonalCenter/DownloadsView.swift +++ b/DarockBili Watch App/PersonalCenter/DownloadsView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/4. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import AVKit import SwiftUI diff --git a/DarockBili Watch App/PersonalCenter/FavoriteView.swift b/DarockBili Watch App/PersonalCenter/FavoriteView.swift index b7eca0bc3..d3cb7e947 100644 --- a/DarockBili Watch App/PersonalCenter/FavoriteView.swift +++ b/DarockBili Watch App/PersonalCenter/FavoriteView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/4. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/PersonalCenter/FollowListView.swift b/DarockBili Watch App/PersonalCenter/FollowListView.swift index 6a249bb20..66236e0f5 100644 --- a/DarockBili Watch App/PersonalCenter/FollowListView.swift +++ b/DarockBili Watch App/PersonalCenter/FollowListView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/1. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/PersonalCenter/HistoryView.swift b/DarockBili Watch App/PersonalCenter/HistoryView.swift index 8efe72e46..21f00710b 100644 --- a/DarockBili Watch App/PersonalCenter/HistoryView.swift +++ b/DarockBili Watch App/PersonalCenter/HistoryView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/3. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/PersonalCenter/PersonAccountView.swift b/DarockBili Watch App/PersonalCenter/PersonAccountView.swift index 9b0bddc6b..e0bb4517a 100644 --- a/DarockBili Watch App/PersonalCenter/PersonAccountView.swift +++ b/DarockBili Watch App/PersonalCenter/PersonAccountView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/6/30. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import AVKit import SwiftUI @@ -224,10 +234,10 @@ struct PersonAccountView: View { isNetworkFixPresented = true } } - DarockKit.Network.shared.requestString("https://api.darock.top/bili/wbi/sign/\("mid=\(dedeUserID)".base64Encoded())") { respStr, isSuccess in - if isSuccess { - debugPrint(respStr.apiFixed()) - DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/space/wbi/acc/info?\(respStr.apiFixed())", headers: headers) { respJson, isSuccess in + biliWbiSign(paramEncoded: "mid=\(dedeUserID)".base64Encoded()) { signed in + if let signed { + debugPrint(signed) + DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/space/wbi/acc/info?\(signed)", headers: headers) { respJson, isSuccess in if isSuccess { debugPrint(respJson) userFaceUrl = respJson["data"]["face"].string ?? "E" diff --git a/DarockBili Watch App/PersonalCenter/UserDetailView.swift b/DarockBili Watch App/PersonalCenter/UserDetailView.swift index a65ba58ca..400923b8f 100644 --- a/DarockBili Watch App/PersonalCenter/UserDetailView.swift +++ b/DarockBili Watch App/PersonalCenter/UserDetailView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/1. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// // UserDetailView 对于 watchOS 10 和其他版本是两套独立代码,更改时记得同时更改! @@ -136,10 +146,10 @@ struct UserDetailView: View { let headers: HTTPHeaders = [ "cookie": "SESSDATA=\(sessdata);" ] - DarockKit.Network.shared.requestString("https://api.darock.top/bili/wbi/sign/\("mid=\(uid)".base64Encoded())") { respStr, isSuccess in - if isSuccess { - debugPrint(respStr.apiFixed()) - DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/space/wbi/acc/info?\(respStr.apiFixed())", headers: headers) { respJson, isSuccess in + biliWbiSign(paramEncoded: "mid=\(uid)".base64Encoded()) { signed in + if let signed { + debugPrint(signed) + DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/space/wbi/acc/info?\(signed)", headers: headers) { respJson, isSuccess in if isSuccess { debugPrint(respJson) userFaceUrl = respJson["data"]["face"].string ?? "E" @@ -550,19 +560,24 @@ struct UserDetailView: View { func RefreshVideos() { videos = [[String: String]]() let headers: HTTPHeaders = [ - "cookie": "SESSDATA=\(sessdata);" + "cookie": "SESSDATA=\(sessdata);", + "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15" ] - DarockKit.Network.shared.requestString("https://api.darock.top/bili/wbi/sign/\("mid=\(uid)&ps=50&pn=\(videoNowPage)".base64Encoded())") { respStr, isSuccess in - if isSuccess { - debugPrint(respStr.apiFixed()) - DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/space/wbi/arc/search?\(respStr.apiFixed())", headers: headers) { respJson, isSuccess in + biliWbiSign(paramEncoded: "mid=\(uid)&ps=50&pn=\(videoNowPage)".base64Encoded()) { signed in + if let signed { + debugPrint(signed) + DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/space/wbi/arc/search?\(signed)", headers: headers) { respJson, isSuccess in if isSuccess { debugPrint(respJson) + if (respJson["code"].int ?? 0) != 0 { + tipWithText("加载失败:\(respJson["message"].string ?? "")", symbol: "xmark.circle.fill") + return + } let vlist = respJson["data"]["list"]["vlist"] for video in vlist { videos.append(["Title": video.1["title"].string ?? "[加载失败]", "Length": video.1["length"].string ?? "E", "PlayCount": String(video.1["play"].int ?? -1), "PicUrl": video.1["pic"].string ?? "E", "BV": video.1["bvid"].string ?? "E", "Timestamp": String(video.1["created"].int ?? 0), "DanmakuCount": String(video.1["video_review"].int ?? -1)]) } - debugPrint(respJson["data"]["page"]["count"].int!) + debugPrint(respJson["data"]["page"]["count"].int ?? 0) videoTotalPage = Int((respJson["data"]["page"]["count"].int ?? 0) / 50) + 1 videoCount = respJson["data"]["page"]["count"].int ?? 0 if !isVideosLoaded { @@ -579,14 +594,19 @@ struct UserDetailView: View { func RefreshArticles() { articles = [[String: String]]() let headers: HTTPHeaders = [ - "cookie": "SESSDATA=\(sessdata);" + "cookie": "SESSDATA=\(sessdata);", + "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15" ] - DarockKit.Network.shared.requestString("https://api.darock.top/bili/wbi/sign/\("mid=\(uid)&ps=30&pn=\(articleNowPage)&sort=publish_time&platform=web".base64Encoded())") { respStr, isSuccess in - if isSuccess { - debugPrint(respStr.apiFixed()) - DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/space/wbi/article?\(respStr.apiFixed())", headers: headers) { respJson, isSuccess in + biliWbiSign(paramEncoded: "mid=\(uid)&ps=30&pn=\(articleNowPage)&sort=publish_time&platform=web".base64Encoded()) { signed in + if let signed { + debugPrint(signed) + DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/space/wbi/article?\(signed)", headers: headers) { respJson, isSuccess in if isSuccess { debugPrint(respJson) + if (respJson["code"].int ?? 0) != 0 { + tipWithText("加载失败:\(respJson["message"].string ?? "")", symbol: "xmark.circle.fill") + return + } let articlesJson = respJson["data"]["articles"] for article in articlesJson { articles.append(["Title": article.1["title"].string ?? "[加载失败]", "Summary": article.1["summary"].string ?? "[加载失败]", "Type": article.1["categories"][0]["name"].string ?? "[加载失败]", "View": String(article.1["stats"]["view"].int ?? -1), "Like": String(article.1["stats"]["like"].int ?? -1), "Pic": article.1["image_urls"][0].string ?? "E", "CV": String(article.1["id"].int ?? 0)]) diff --git a/DarockBili Watch App/PersonalCenter/WatchLaterView.swift b/DarockBili Watch App/PersonalCenter/WatchLaterView.swift index 0ad3aff37..e967c20ed 100644 --- a/DarockBili Watch App/PersonalCenter/WatchLaterView.swift +++ b/DarockBili Watch App/PersonalCenter/WatchLaterView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/4. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/PersonalCenter/bMessage/bMessageSendView.swift b/DarockBili Watch App/PersonalCenter/bMessage/bMessageSendView.swift index d7daf408a..497764542 100644 --- a/DarockBili Watch App/PersonalCenter/bMessage/bMessageSendView.swift +++ b/DarockBili Watch App/PersonalCenter/bMessage/bMessageSendView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/25. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import WatchKit diff --git a/DarockBili Watch App/UserDynamic/ImageViewerView.swift b/DarockBili Watch App/UserDynamic/ImageViewerView.swift index 3630458de..8e44721ae 100644 --- a/DarockBili Watch App/UserDynamic/ImageViewerView.swift +++ b/DarockBili Watch App/UserDynamic/ImageViewerView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/28. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/UserDynamic/UserDynamicMainView.swift b/DarockBili Watch App/UserDynamic/UserDynamicMainView.swift index dea7ac2b9..a15704f4f 100644 --- a/DarockBili Watch App/UserDynamic/UserDynamicMainView.swift +++ b/DarockBili Watch App/UserDynamic/UserDynamicMainView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/28. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/Video/AudioPlayerView.swift b/DarockBili Watch App/Video/AudioPlayerView.swift index 4f361e931..82e01949b 100644 --- a/DarockBili Watch App/Video/AudioPlayerView.swift +++ b/DarockBili Watch App/Video/AudioPlayerView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/23. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import AVKit import Combine diff --git a/DarockBili Watch App/Video/LyricerView.swift b/DarockBili Watch App/Video/LyricerView.swift index 824348452..f21e6074e 100644 --- a/DarockBili Watch App/Video/LyricerView.swift +++ b/DarockBili Watch App/Video/LyricerView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/30. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI diff --git a/DarockBili Watch App/Video/VideoCommentsView.swift b/DarockBili Watch App/Video/VideoCommentsView.swift index ed9578fd0..8ac11b5d1 100644 --- a/DarockBili Watch App/Video/VideoCommentsView.swift +++ b/DarockBili Watch App/Video/VideoCommentsView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/2. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import OSLog import SwiftUI diff --git a/DarockBili Watch App/Video/VideoDetailView.swift b/DarockBili Watch App/Video/VideoDetailView.swift index 8e85bd5e8..2b7a91a21 100644 --- a/DarockBili Watch App/Video/VideoDetailView.swift +++ b/DarockBili Watch App/Video/VideoDetailView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/6/30. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import AVKit import SwiftUI diff --git a/DarockBili Watch App/Video/VideoDownloadView.swift b/DarockBili Watch App/Video/VideoDownloadView.swift index 49ce5eb65..f921b0ce3 100644 --- a/DarockBili Watch App/Video/VideoDownloadView.swift +++ b/DarockBili Watch App/Video/VideoDownloadView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/7/4. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import SwiftUI import DarockKit diff --git a/DarockBili Watch App/Video/VideoPlayerView.swift b/DarockBili Watch App/Video/VideoPlayerView.swift index 568a0ec5d..1cf2cab78 100644 --- a/DarockBili Watch App/Video/VideoPlayerView.swift +++ b/DarockBili Watch App/Video/VideoPlayerView.swift @@ -4,6 +4,16 @@ // // Created by WindowsMEMZ on 2023/6/30. // +//===----------------------------------------------------------------------===// +// +// This source file is part of the MeowBili open source project +// +// Copyright (c) 2023 Darock Studio and the MeowBili project authors +// Licensed under GNU General Public License v3 +// +// See https://darock.top/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// import AVKit import SwiftUI