searchComments method
Future<PaginatedVideos>
searchComments({
- required String comment,
- SearchFilter filter = const SearchFilter(sort: SearchSort.newest, paginated: true, offset: 0, limit: 25),
Flexible endpoint to search for comments in 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
comment
Find videos with comments containing specified string (case insensitive)filter
Filter video results from the API
Implementation
Future<PaginatedVideos> searchComments({
required String comment,
SearchFilter filter = const SearchFilter(
sort: SearchSort.newest,
paginated: true,
offset: 0,
limit: 25,
),
}) async {
final Map<String, dynamic> data = {
'comment': comment,
...filter.toJson(),
};
final response =
await postEndpoint(HolodexEndpoint.commentSearch, 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(),
);
}