studioMedia function
Implementation
@riverpod
FutureOr<List<StudioMediaItem>> studioMedia(Ref ref, String studioId) async {
ref.keepAlive();
final client = ref.read(graphqlClientProvider);
final result = await client.query$FindScenes(
Options$Query$FindScenes(
variables: Variables$Query$FindScenes(
filter: Input$FindFilterType(page: 1, per_page: 24),
scene_filter: Input$SceneFilterType(
studios: Input$HierarchicalMultiCriterionInput(
value: <String>[studioId],
modifier: Enum$CriterionModifier.INCLUDES,
),
),
),
),
);
if (result.hasException) throw result.exception!;
final prefs = ref.read(sharedPreferencesProvider);
final storedServerUrl = prefs.getString('server_base_url')?.trim() ?? '';
final normalizedServerUrl = normalizeGraphqlServerUrl(storedServerUrl);
final endpoint = Uri.parse(
normalizedServerUrl.isEmpty
? 'http://localhost:9999/graphql'
: normalizedServerUrl,
);
return result.parsedData!.findScenes.scenes
.map(
(scene) => StudioMediaItem(
sceneId: scene.id,
title: buildSceneDisplayTitle(
title: scene.title,
filePath: scene.files.isNotEmpty ? scene.files.first.path : null,
streamPath: scene.paths.stream,
),
thumbnailUrl: resolveGraphqlMediaUrl(
rawUrl: scene.paths.screenshot ?? scene.paths.preview,
graphqlEndpoint: endpoint,
),
),
)
.where((item) => item.thumbnailUrl.isNotEmpty)
.toList();
}