From 09dc39b76766d1eaed7d778582edb6e0bf36fe9a Mon Sep 17 00:00:00 2001 From: Mark Chan <45706356+WindowsMEMZ@users.noreply.github.com> Date: Mon, 29 Jan 2024 01:57:05 +0800 Subject: [PATCH] Update README.md --- README.md | 150 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 101 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 1bdcee159..9438e32ea 100644 --- a/README.md +++ b/README.md @@ -49,54 +49,106 @@
项目中的逆天代码片段 ```swift -// UserDynamic/UserDynamicMainView.swift :196 - -dynamics.append([ - "WithText": item.1["modules"]["module_dynamic"]["desc"]["text"].string ?? "", - "MajorType": BiliDynamicMajorType(rawValue: item.1["modules"]["module_dynamic"]["major"]["type"].string ?? "MAJOR_TYPE_DRAW") ?? .majorTypeDraw, - "Draws": { () -> [[String: String]]? in - if BiliDynamicMajorType(rawValue: item.1["modules"]["module_dynamic"]["major"]["type"].string ?? "MAJOR_TYPE_DRAW") == .majorTypeDraw { - var dTmp = [[String: String]]() - for draw in item.1["modules"]["module_dynamic"]["major"]["draw"]["items"] { - isDynamicImagePresented[itemForCount].append(false) - dTmp.append(["Src": draw.1["src"].string ?? ""]) - } - return dTmp - } else { - return nil - } - }(), - "Archive": { () -> [String: String]? in - if BiliDynamicMajorType(rawValue: item.1["modules"]["module_dynamic"]["major"]["type"].string ?? "MAJOR_TYPE_DRAW") == .majorTypeArchive { - let archive = item.1["modules"]["module_dynamic"]["major"]["archive"] - return ["Pic": archive["cover"].string ?? "", "Title": archive["title"].string ?? "", "BV": archive["bvid"].string ?? "", "UP": item.1["modules"]["module_author"]["name"].string ?? "", "View": archive["stat"]["play"].string ?? "-1", "Danmaku": archive["stat"]["danmaku"].string ?? "-1"] - } else { - return nil - } - }(), - "Live": { () -> [String: String]? in - if BiliDynamicMajorType(rawValue: item.1["modules"]["module_dynamic"]["major"]["type"].string ?? "MAJOR_TYPE_DRAW") == .majorTypeLiveRcmd { - do { - let liveContentJson = try JSON(data: (item.1["modules"]["module_dynamic"]["major"]["live_rcmd"]["content"].string ?? "").data(using: .utf8) ?? Data()) - debugPrint(liveContentJson) - return ["Cover": liveContentJson["live_play_info"]["cover"].string ?? "", "Title": liveContentJson["live_play_info"]["title"].string ?? "", "ID": String(liveContentJson["live_play_info"]["room_id"].int ?? 0), "Type": liveContentJson["live_play_info"]["area_name"].string ?? "", "ViewStr": liveContentJson["live_play_info"]["watched_show"]["text_large"].string ?? "-1"] - } catch { - return nil - } - } else { - return nil - } - }(), - "SenderPic": item.1["modules"]["module_author"]["face"].string ?? "", - "SenderName": item.1["modules"]["module_author"]["name"].string ?? "", - "SenderID": String(item.1["modules"]["module_author"]["mid"].int ?? 0), - "SendTimeStr": item.1["modules"]["module_author"]["pub_time"].string ?? "0000/00/00", - "SharedCount": String(item.1["modules"]["module_stat"]["forward"]["count"].int ?? -1), - "LikedCount": String(item.1["modules"]["module_stat"]["like"]["count"].int ?? -1), - "IsLiked": item.1["modules"]["module_stat"]["like"]["status"].bool ?? false, - "CommentCount": String(item.1["modules"]["module_stat"]["comment"]["count"].int ?? -1), - "DynamicID": item.1["id_str"].string ?? "" -]) +// UserDynamic/UserDynamicMainView.swift :322 + dynamics.append([ + "WithText": item.1["modules"]["module_dynamic"]["desc"]["text"].string ?? "", + "Type": BiliDynamicType(rawValue: item.1["type"].string ?? "DYNAMIC_TYPE_WORD") ?? .text, + "Draws": { () -> [[String: String]]? in + if BiliDynamicType(rawValue: item.1["type"].string ?? "DYNAMIC_TYPE_WORD") == .draw { + var dTmp = [[String: String]]() + for draw in item.1["modules"]["module_dynamic"]["major"]["draw"]["items"] { + isDynamicImagePresented[itemForCount].append(false) + dTmp.append(["Src": draw.1["src"].string ?? ""]) + } + return dTmp + } else { + return nil + } + }(), + "Archive": { () -> [String: String]? in + if BiliDynamicType(rawValue: item.1["type"].string ?? "DYNAMIC_TYPE_WORD") == .video { + let archive = item.1["modules"]["module_dynamic"]["major"]["archive"] + return ["Pic": archive["cover"].string ?? "", "Title": archive["title"].string ?? "", "BV": archive["bvid"].string ?? "", "UP": item.1["modules"]["module_author"]["name"].string ?? "", "View": archive["stat"]["play"].string ?? "-1", "Danmaku": archive["stat"]["danmaku"].string ?? "-1"] + } else { + return nil + } + }(), + "Live": { () -> [String: String]? in + if BiliDynamicType(rawValue: item.1["type"].string ?? "DYNAMIC_TYPE_WORD") == .live { + do { + let liveContentJson = try JSON(data: (item.1["modules"]["module_dynamic"]["major"]["live_rcmd"]["content"].string ?? "").data(using: .utf8) ?? Data()) + debugPrint(liveContentJson) + return ["Cover": liveContentJson["live_play_info"]["cover"].string ?? "", "Title": liveContentJson["live_play_info"]["title"].string ?? "", "ID": String(liveContentJson["live_play_info"]["room_id"].int ?? 0), "Type": liveContentJson["live_play_info"]["area_name"].string ?? "", "ViewStr": liveContentJson["live_play_info"]["watched_show"]["text_large"].string ?? "-1"] + } catch { + return nil + } + } else { + return nil + } + }(), + "Forward": { () -> [String: Any?]? in + if BiliDynamicType(rawValue: item.1["type"].string ?? "DYNAMIC_TYPE_WORD") == .forward { + let origData = item.1["orig"] + return [ + "WithText": origData["modules"]["module_dynamic"]["desc"]["text"].string ?? "", + "Type": BiliDynamicType(rawValue: origData["type"].string ?? "DYNAMIC_TYPE_WORD") ?? .text, + "Draws": { () -> [[String: String]]? in + if BiliDynamicType(rawValue: origData["type"].string ?? "DYNAMIC_TYPE_WORD") == .draw { + var dTmp = [[String: String]]() + for draw in origData["modules"]["module_dynamic"]["major"]["draw"]["items"] { + isDynamicImagePresented[itemForCount].append(false) + dTmp.append(["Src": draw.1["src"].string ?? ""]) + } + return dTmp + } else { + return nil + } + }(), + "Archive": { () -> [String: String]? in + if BiliDynamicType(rawValue: origData["type"].string ?? "DYNAMIC_TYPE_WORD") == .video { + let archive = origData["modules"]["module_dynamic"]["major"]["archive"] + return ["Pic": archive["cover"].string ?? "", "Title": archive["title"].string ?? "", "BV": archive["bvid"].string ?? "", "UP": origData["modules"]["module_author"]["name"].string ?? "", "View": archive["stat"]["play"].string ?? "-1", "Danmaku": archive["stat"]["danmaku"].string ?? "-1"] + } else { + return nil + } + }(), + "Live": { () -> [String: String]? in + if BiliDynamicType(rawValue: origData["type"].string ?? "DYNAMIC_TYPE_WORD") == .live { + do { + let liveContentJson = try JSON(data: (origData["modules"]["module_dynamic"]["major"]["live_rcmd"]["content"].string ?? "").data(using: .utf8) ?? Data()) + debugPrint(liveContentJson) + return ["Cover": liveContentJson["live_play_info"]["cover"].string ?? "", "Title": liveContentJson["live_play_info"]["title"].string ?? "", "ID": String(liveContentJson["live_play_info"]["room_id"].int ?? 0), "Type": liveContentJson["live_play_info"]["area_name"].string ?? "", "ViewStr": liveContentJson["live_play_info"]["watched_show"]["text_large"].string ?? "-1"] + } catch { + return nil + } + } else { + return nil + } + }(), + "SenderPic": origData["modules"]["module_author"]["face"].string ?? "", + "SenderName": origData["modules"]["module_author"]["name"].string ?? "", + "SenderID": String(origData["modules"]["module_author"]["mid"].int ?? 0), + "SendTimeStr": origData["modules"]["module_author"]["pub_time"].string ?? "0000/00/00", + "SharedCount": String(origData["modules"]["module_stat"]["forward"]["count"].int ?? -1), + "LikedCount": String(origData["modules"]["module_stat"]["like"]["count"].int ?? -1), + "IsLiked": origData["modules"]["module_stat"]["like"]["status"].bool ?? false, + "CommentCount": String(origData["modules"]["module_stat"]["comment"]["count"].int ?? -1), + "DynamicID": origData["id_str"].string ?? "" + ] + } else { + return nil + } + }(), + "SenderPic": item.1["modules"]["module_author"]["face"].string ?? "", + "SenderName": item.1["modules"]["module_author"]["name"].string ?? "", + "SenderID": String(item.1["modules"]["module_author"]["mid"].int ?? 0), + "SendTimeStr": item.1["modules"]["module_author"]["pub_time"].string ?? "0000/00/00", + "SharedCount": String(item.1["modules"]["module_stat"]["forward"]["count"].int ?? -1), + "LikedCount": String(item.1["modules"]["module_stat"]["like"]["count"].int ?? -1), + "IsLiked": item.1["modules"]["module_stat"]["like"]["status"].bool ?? false, + "CommentCount": String(item.1["modules"]["module_stat"]["comment"]["count"].int ?? -1), + "DynamicID": item.1["id_str"].string ?? "" + ]) ```
@@ -106,7 +158,7 @@ dynamics.append([ 因此,我们在TestFlight上仅仅递增 Build 号,而GitHub上尽可能使用语义化版本,我们更推荐使用GitHub上的版本号来引用喵哩喵哩程序。 -## 用户评价 +## 💬用户评价 ~~用过的都说好~~ > [!TIP]