getContinuationToken function

String? getContinuationToken(
  1. List results
)

Get the token used for continuations.

Implementation

String? getContinuationToken(List results) {
  final lastResult = results.last;
  final token =
      nav(lastResult, CONTINUATION_TOKEN, nullIfAbsent: true) as String?;

  if (token != null) {
    return token;
  }
  // continuation tokens may be nested in a commandExecutorCommand list
  //  (alongside playlistVotingRefreshPopupCommand, for example)
  final commands =
      nav(lastResult, COMMAND_EXECUTOR_COMMANDS, nullIfAbsent: true) as List? ??
      [];

  for (final command in commands) {
    if (nav(command, ['continuationCommand', 'request'], nullIfAbsent: true) ==
        'CONTINUATION_REQUEST_TYPE_BROWSE') {}
    return nav(command, ['continuationCommand', 'token']) as String;
  }

  return null;
}