searchVideos method
Future<PaginatedVideos>
searchVideos({
- List<
String> conditions = const [], - SearchFilter filter = const SearchFilter(sort: SearchSort.newest, paginated: true, offset: 0, limit: 25),
Flexible endpoint to search for videos fulfilling multiple conditions.
Descriptions with "any" implies an OR
condition, and "all" implies an AND
condition.
Note that searching for topics and clips is not supported, because clips do not contain topics.
Arguments
conditions
Match all of the items. -> For each item: look for the text in video title or descriptionfilter
Filter video results from the API
Implementation
Future<PaginatedVideos> searchVideos({
List<String> conditions = const [],
SearchFilter filter = const SearchFilter(
sort: SearchSort.newest,
paginated: true,
offset: 0,
limit: 25,
),
}) async {
final Map<String, dynamic> data = {
'conditions': conditions,
...filter.toJson()
};
final response =
await postEndpoint(HolodexEndpoint.videoSearch, data: data);
if (filter.paginated) {
// Grab total and return with it
final videoList = PaginatedVideos.fromString(response.body);
return videoList.copyWith(paginated: true);
}
final List<dynamic> list = jsonDecode(response.body);
return PaginatedVideos(
items: list.map((video) => VideoFull.fromJson(video)).toList());
}