getLiveVideos method Null safety
- {String? channelId,
- List<
Includes> includes = const [Includes.liveInfo], - List<
Language> lang = const [Language.all], - int limit = 9999,
- int? maxUpcomingHours = 48,
- String? mentionedChannelId,
- int offset = 0,
- Order order = Order.ascending,
- List<
Organization> ? organization, - bool paginated = true,
- List<
VideoSort> sort = const <VideoSort>[VideoSort.availableAt], - List<
VideoStatus> ? status = const [VideoStatus.live, VideoStatus.upcoming], - String? topic,
- VideoType? type = VideoType.stream}
Get a list of live videos
Returns VideoFullList
This is somewhat similar to calling listVideos().
However, this endpoint imposes these default values on the query parameters: You can choose to override them by providing your own values.
status: [VideoStatus.live, VideoStatus.upcoming],
type: VideoType.stream,
sort: [VideoSort.availableAt],
order: Order.ascending,
max_upcoming_hours: 48,
limit: 9999,
include: [Includes.liveInfo] + query's include
Arguments:
channelId
Filter by video uploader channel IDincludes
Request extra data be included in the results. They are not guarenteed to be returned.lang
Filter by theLanguage
limit
Limit the number of results returned.maxUpcomingHours
Number of maximum hours upcoming to get upcoming videos by (for rejecting waiting rooms that are two years out)mentionedChannelId
Filter by mentioned channel id, excludes itself. Generally used to find collabs/clips that include the requested channeloffset
Receive results starting at this number in the array from the Holodex APIorder
Order by ascending or descendingorganization
Filter by clips that feature the org's talent or videos posted by the org's talent.paginated
If paginated is set to true, returnsVideoFullList
with total, otherwise returnsVideoFullList
without the total.sort
Sort the returned data by this fieldstatus
Filter by the video statustopic
Filter by video topic IDtype
Filter by type of video, either clips or streams
Implementation
@override
Future<VideoFullList> getLiveVideos({
String? channelId,
List<Includes> includes = const [Includes.liveInfo],
List<Language> lang = const [Language.all],
int limit = 9999,
int? maxUpcomingHours = 48,
String? mentionedChannelId,
int offset = 0,
Order order = Order.ascending,
List<Organization>? organization,
bool paginated = true,
List<VideoSort> sort = const <VideoSort>[VideoSort.availableAt],
List<VideoStatus>? status = const [VideoStatus.live, VideoStatus.upcoming],
String? topic,
VideoType? type = VideoType.stream
}) async {
// Create the params list
final Map<String, dynamic> params = {};
// Make sure liveInfo is in the list
if (!includes.contains(Includes.liveInfo)) {
includes.add(Includes.liveInfo);
}
// Add the items with default values (they can't be null)
params.addAll({
'limit': '$limit',
'offset': '$offset',
'order': EnumUtil.convertOrderToString(order),
});
_addVideoSort(sort, params);
_addPaginated(paginated, params);
_addChannelId(channelId, params);
// Add the info the videos must include
_addIncludes(includes, params);
// Add the languages to filter by
// Add the first item so that there is not a comma in front
_addLanguages(lang, params);
// Add the max upcoming hours param
_addMaxUpcomingHours(maxUpcomingHours, params);
// Add the mentioned channel id param
_addMentionedChannelId(mentionedChannelId, params);
// Add the organization param
_addOrganization(organization, params);
// Add the topic param
_addTopic(topic, params);
// Add the status param
_addStatusList(status, params);
// Add the type param
_addType(type, params);
final response = await get(path: _Constants.liveVideosPath, params: params);
if (paginated) {
// Grab total and return with it
final videoList = VideoFullList.fromJson(response.body);
return videoList.copyWith(paginated: true);
}
final List list = jsonDecode(response.body);
return VideoFullList(videos: list.map((video) => VideoFull.fromMap(video)).toList()); // Returns as `List<Video>`
}