S2BEmitter
public final class S2BEmitter
Danmaku poster
-
Default emitter.
Declaration
Swift
public static let `default` = S2BEmitter() -
Suggested cool time between sending danmaku in seconds. Number smaller than the default may result in ban or failure.
Declaration
Swift
public static let defaultDelay: Double = 3.5 -
Suggested cool time when received -636 (frequency too high) from bilibili. Number smaller than the default may result in ban or failure.
Declaration
Swift
public static let defaultLongDelay: Double = 5 * 60 -
Initalize a S2BEmitter with specified session and delay.
Declaration
Swift
public init(session: BKSession! = .shared, delay: Double = S2BEmitter.defaultDelay, longDelay: Double = S2BEmitter.defaultLongDelay)Parameters
sessionsession containing cookie required for posting danmaku.
delaycool time between sending danmaku in seconds.
longDelayseconds between -636 and sending next danmaku.
-
Initalize a S2BEmitter with specified cookie to add to the default session and delay.
Declaration
Swift
public convenience init(cookie: BKCookie, delay: Double = S2BEmitter.defaultDelay, longDelay: Double = S2BEmitter.defaultLongDelay)Parameters
cookiecookie to be added to the default session.
delaycool time between sending danmaku in seconds.
longDelayseconds between -636 and sending next danmaku.
-
Result after trying to post a danmaku.
- success: danmaku was successfully posted.
- refused: bilibili refused to accept the postable danmaku.
- aborted: something else went wrong.
Declaration
Swift
public enum Result -
To handle result after tring to post a danmaku.
Declaration
Swift
public typealias FailablePostCompletionHandler = (_ result: Result) -> VoidParameters
resultresult after trying to post a danmaku.
-
Try to post a danmaku.
Declaration
Swift
public func tryPost(danmaku: S2BDanmaku, toPage page: BKVideo.Page, completionHandler: FailablePostCompletionHandler? = nil)Parameters
danmakudanmaku to post.
completionHandlertask to perform once tried.
-
Task to perform once a single danmaku was posted.
Declaration
Swift
public typealias PostCompletionHandler = (_ posted: S2BPostedDanmaku) -> VoidParameters
postabledanmaku posted.
-
Post a danmaku, auto retry if failed.
Declaration
Swift
public func post(danmaku: S2BDanmaku, toPage page: BKVideo.Page, completionHandler: PostCompletionHandler? = nil)Parameters
danmakudanmaku to post.
completionHandlertask to perform once the danmaku was successfully posted.
-
Task to perform once a danmaku in the queue was posted.
Declaration
Swift
public typealias ProgressReportHandler = (_ posted: S2BPostedDanmaku, _ progress: Progress) -> VoidParameters
postabledanmaku posted.
progressobject tracking the current progress.
-
Post all contents within the subtile to video of given cid.
Declaration
Swift
public func post(subtitle: S2BSubtitle, toPage page: BKVideo.Page, configs: [S2BDanmaku.Config] = [.default], updateHandler: ProgressReportHandler? = nil, completionHandler: CompletionHandler? = nil)Parameters
subtitlesubtitle to post.
cidcid of the video to post to.
configsconfigurations of danmakus.
updateHandlertask to perform once a danmaku was posted.
completionHandlertask to perform after all danmaku were posted.
-
Post all contents within the file to video of given cid.
Declaration
Swift
public func post(srt: S2BSubRipFile, toPage page: BKVideo.Page, configs: [S2BDanmaku.Config] = [.default], updateHandler: ProgressReportHandler? = nil, completionHandler: CompletionHandler? = nil)Parameters
srtSubRip file to post.
cidcid of the video to post to.
configsconfigurations of danmakus.
updateHandlertask to perform once a danmaku was posted.
completionHandlertask to perform after all danmaku were posted.
View on GitHub
Install in Dash
S2BEmitter Class Reference