downloadHistory method
Future<void>
downloadHistory({
- required LiveBroadcastItem liveBroadcastItem,
- File? file,
- TimeStore? timeStore,
Download the liveChat history. If a File is specified then the data will be stored there otherwise if a TimeStore is specified, only history with a timestamp greater than that given by the TimeStore will be downloaded.
Implementation
Future<void> downloadHistory(
{required LiveBroadcastItem liveBroadcastItem,
File? file,
TimeStore? timeStore}) async {
await _download(
liveBroadcastItem: liveBroadcastItem,
timeStore: timeStore,
onDownload: (List<LiveChatMessage> liveChatMessageList,
LiveBroadcastItem liveBroadcastItem) {
if (file == null) {
for (LiveChatMessage liveChatMessage in liveChatMessageList) {
stdout.writeln(
'${liveChatMessage.snippet.publishedAt!.toLocal()} | ${liveChatMessage.authorDetails?.displayName}: ${liveChatMessage.snippet.textMessageDetails!.messageText}');
}
} else {
file.writeAsStringSync(
ListToCsvConverter().convert(liveChatMessageList
.map((liveChatMessage) => [
liveChatMessage.snippet.publishedAt!.toLocal(),
liveChatMessage.authorDetails?.displayName,
liveChatMessage
.snippet.textMessageDetails!.messageText
])
.toList()),
mode: FileMode.append);
}
});
}