Giter Site home page Giter Site logo

apollozhu / bilibilikit Goto Github PK

View Code? Open in Web Editor NEW
18.0 4.0 3.0 339 KB

bilibili APIs in Swift. docs:

Home Page: https://apollozhu.github.io/BilibiliKit/

License: MIT License

Ruby 0.80% Swift 99.20%
bilibili bilibili-api swift-package-manager cocoapods hacktoberfest

bilibilikit's Issues

Audio

Improve RSA

static func rsaEncrypt(_ string: String, with publicKey: String) -> Result<String, BKError> {
let publicKey = publicKey
.replacingOccurrences(of: "-----BEGIN PUBLIC KEY-----", with: "")
.replacingOccurrences(of: "-----END PUBLIC KEY-----", with: "")
.replacingOccurrences(of: "\n", with: "")
var error: Unmanaged<CFError>? = nil
guard let keyData = Data(base64Encoded: publicKey) else {
return .failure(.parseError(reason: .dataEncodeFailure))
}
guard let key = SecKeyCreateWithData(keyData as CFData, [
kSecAttrType: kSecAttrKeyTypeRSA,
kSecAttrKeyClass: kSecAttrKeyClassPublic,
kSecAttrKeySizeInBits: (keyData.count * 8) as NSNumber,
] as CFDictionary, &error) else {
return .failure(.encryptError(reason:
.publicKeySecKeyGenerationFailure(String(describing: error))))
}
guard let stringData = string.data(using: .utf8) else {
return .failure(.implementationError(reason: .invalidDataEncoding))
}
guard let data = SecKeyCreateEncryptedData(
key, .rsaEncryptionPKCS1, stringData as CFData, &error) else {
return .failure(.encryptError(reason:
.rsaEncryptFailure(String(describing: error))))
}
return .success((data as Data).base64EncodedString())
}

As demonstrated in the documentation, we should

  • check if it is supported
  • some other checks in the documentation
  • take retained value instead of using String(describing:)

Migration to BV

Old AV {info, page list} API still works, however, all URLs defaults to BV now

https://api.bilibili.com/x/web-interface/view?bvid=BV1XJ41157tQ
https://api.bilibili.com/x/web-interface/view?aid=82054919

{
    "code": 0,
    "message": "0",
    "ttl": 1,
    "data": {
        "bvid": "BV1XJ41157tQ",
        "aid": 82054919,
        "videos": 1,
        "tid": 21,
        "tname": "日常",
        "copyright": 1,
        "pic": "http://i1.hdslb.com/bfs/archive/fa125f2f74f19ccde76aaebb9c310bee81a7086b.jpg",
        "title": "看完这个视频的人,2020都变得更好了",
        "pubdate": 1578136510,
        "ctime": 1578136510,
        "desc": "【打卡挑战年度视频】哪有什么天生如此,只是我们天天坚持。\n感谢2019年在B站坚持打卡的你们,希望在新的一年,大家变得更好!\n本视频参演UP主:\n是落拓呀\n三坨土本土\n张子贺Zake\n陈耐时很奶思\n翼飞书画\nBGM:\nPaRaD1SE - 桜流し - EVA Q [piano]\nカワキヲアメク(内心的嘶吼)- 美波(Minami)\nA Thousand Years - Christina Perri",
        "state": 0,
        "attribute": 16768,
        "duration": 248,
        "rights": {
            "bp": 0,
            "elec": 0,
            "download": 1,
            "movie": 0,
            "pay": 0,
            "hd5": 1,
            "no_reprint": 1,
            "autoplay": 1,
            "ugc_pay": 0,
            "is_cooperation": 0,
            "ugc_pay_preview": 0,
            "no_background": 0
        },
        "owner": {
            "mid": 37090048,
            "name": "哔哩哔哩创作中心",
            "face": "http://i2.hdslb.com/bfs/face/01365904ffb64d1858da7e20e1040b9f2d94165d.jpg"
        },
        "stat": {
            "aid": 82054919,
            "view": 219918,
            "danmaku": 4509,
            "reply": 996,
            "favorite": 8790,
            "coin": 8587,
            "share": 3259,
            "now_rank": 0,
            "his_rank": 82,
            "like": 23728,
            "dislike": 0,
            "evaluation": ""
        },
        "dynamic": "#VLOG##生活记录##打卡挑战#",
        "cid": 140393526,
        "dimension": {
            "width": 1920,
            "height": 1080,
            "rotate": 0
        },
        "no_cache": false,
        "pages": [{
            "cid": 140393526,
            "page": 1,
            "from": "vupload",
            "part": "打卡挑战年度视频",
            "duration": 248,
            "vid": "",
            "weblink": "",
            "dimension": {
                "width": 1920,
                "height": 1080,
                "rotate": 0
            }
        }],
        "subtitle": {
            "allow_submit": false,
            "list": []
        }
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.