/
BKUser+AudioStat.swift
35 lines (32 loc) · 995 Bytes
/
BKUser+AudioStat.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// BKUser+AudioStat.swift
// BilibiliKit
//
// Created by Apollo Zhu on 8/9/18.
// Copyright (c) 2017-2020 ApolloZhu. MIT License.
//
import Foundation
extension BKUser {
public struct AudioStat: Codable {
/// Number audio creations played
public let play: Int
/// Number of audio creations listend to
public let listen: Int
/// Number of fans
public let fans: Int
/// Number of audio creations
public let creations: Int
}
}
extension BKUser {
/// Fetchs and passes this up's audio stat to `handler`.
///
/// - Important: Won't fail for invalid user.
///
/// - Parameters:
/// - handler: code to process an optional `AudioStat`.
public func getAudioStat(then handler: @escaping BKHandler<AudioStat>) {
let url = "https://www.bilibili.com/audio/music-service-c/web/stat/user?uid=\(mid)"
URLSession.get(url, unwrap: BKWrapperMsg<AudioStat>.self, then: handler)
}
}