allByType method
Future<PlexMediaContainer<PlexMetadata> >
allByType({
- required String sectionId,
- required PlexMetadataType type,
- int start = 0,
- int size = 50,
- String? sort,
- List<
PlexFilter> filters = const [],
Paged list of items inside a section, filtered by type.
Pass a PlexMetadataType; see its members for the wire integers the server expects (the single source of truth for those values).
sort examples: 'titleSort:asc', 'addedAt:desc',
'lastViewedAt:desc', 'originallyAvailableAt:desc'.
filters narrows the result set. Each PlexFilter travels as its
own query parameter — [PlexFilter.genre(6), PlexFilter.yearAfter(2009)]
sends ?genre=6&year>>=2009 — and the server ANDs them. To match
any of several values of one field, put them in a single filter
(see PlexFilter.tag).
Throws a PlexException of type PlexErrorType.state when two filters collide on the same query parameter, since only one of the two could survive into the request.
Implementation
Future<PlexMediaContainer<PlexMetadata>> allByType({
required String sectionId,
required PlexMetadataType type,
int start = 0,
int size = 50,
String? sort,
List<PlexFilter> filters = const [],
}) async {
final qp = <String, dynamic>{
'type': type.value,
'X-Plex-Container-Start': start,
'X-Plex-Container-Size': size,
};
if (sort != null) qp['sort'] = sort;
_applyFilters(qp, filters);
final res = await _http.request<Map<String, dynamic>>(
'/library/sections/$sectionId/all',
queryParameters: qp,
);
return PlexMediaContainer.fromJson(
res.data ?? const {},
'Metadata',
PlexMetadata.fromJson,
);
}