getVideos method Null safety
- {String? channelId,
- List<
Includes> ? includes, - List<
Language> lang = const [Language.all], - int limit = 25,
- int? maxUpcomingHours,
- String? mentionedChannelId,
- int offset = 0,
- Order order = Order.descending,
- List<
Organization> ? organization, - bool paginated = false,
- List<
VideoSort> sort = const <VideoSort>[VideoSort.availableAt], - List<
VideoStatus> ? status, - String? topicId,
- VideoType? type}
Get a list of videos
Returns VideoFullList
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. Maximum value of 50maxUpcomingHours
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 results 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> getVideos({
String? channelId,
List<Includes>? includes,
List<Language> lang = const [Language.all],
int limit = 25,
int? maxUpcomingHours,
String? mentionedChannelId,
int offset = 0,
Order order = Order.descending,
List<Organization>? organization,
bool paginated = false,
List<VideoSort> sort = const <VideoSort>[VideoSort.availableAt],
List<VideoStatus>? status,
String? topicId,
VideoType? type,
}) async {
// The limit cannot be greator than 50, otherwise it will throw an error
assert(limit <= 50);
// Create the params list
final Map<String, dynamic> params = {};
// 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(topicId, params);
// Add the status param
_addStatusList(status, params);
// Add the type param
_addType(type, params);
final response = await get(path: _Constants.videosPath, 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>`
}