getSceneById method
- String id
override
Implementation
@override
Future<Scene> getSceneById(String id) async {
final result = await client.query$FindScene(
Options$Query$FindScene(
fetchPolicy: FetchPolicy.networkOnly,
variables: Variables$Query$FindScene(id: id),
),
);
if (result.hasException) throw result.exception!;
final s = result.parsedData!.findScene;
if (s == null) throw StateError('Scene not found');
return Scene(
id: s.id,
title: s.title ?? '',
details: s.details,
path: s.files.isNotEmpty ? s.files.first.path : null,
date: DateTime.tryParse(s.date ?? '') ?? DateTime.now(),
rating100: s.rating100,
oCounter: s.o_counter ?? 0,
organized: s.organized,
interactive: s.interactive,
resumeTime: s.resume_time,
playCount: s.play_count ?? 0,
files: s.files
.map(
(f) => SceneFile(
format: f.format,
width: f.width,
height: f.height,
videoCodec: f.video_codec,
audioCodec: f.audio_codec,
bitRate: f.bit_rate,
duration: f.duration,
frameRate: f.frame_rate,
),
)
.toList(),
paths: ScenePaths(
screenshot: resolveGraphqlMediaUrl(
rawUrl: s.paths.screenshot,
graphqlEndpoint: _graphqlEndpoint,
),
preview: resolveGraphqlMediaUrl(
rawUrl: s.paths.preview,
graphqlEndpoint: _graphqlEndpoint,
),
stream: resolveGraphqlMediaUrl(
rawUrl: s.paths.stream,
graphqlEndpoint: _graphqlEndpoint,
),
),
studioId: s.studio?.id,
studioName: s.studio?.name,
studioImagePath: resolveGraphqlMediaUrl(
rawUrl: s.studio?.image_path,
graphqlEndpoint: _graphqlEndpoint,
),
performerIds: s.performers.map((p) => p.id).toList(),
performerNames: s.performers.map((p) => p.name).toList(),
performerImagePaths: s.performers
.map(
(p) => resolveGraphqlMediaUrl(
rawUrl: p.image_path,
graphqlEndpoint: _graphqlEndpoint,
),
)
.toList(),
tagIds: s.tags.map((t) => t.id).toList(),
tagNames: s.tags.map((t) => t.name).toList(),
);
}