Skip to content

Commit 5e98864

Browse files
authored
Update VideoBanner plugin (#578)
1 parent 90bacb8 commit 5e98864

2 files changed

Lines changed: 63 additions & 4 deletions

File tree

plugins/VideoBanner/VideoBanner.js

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,13 @@
431431
const isScenesTab = pathname.endsWith('/scenes');
432432
const isMarkersTab = pathname.endsWith('/markers');
433433
const isGroupsTab = pathname.endsWith('/groups');
434-
// console.log("Tag page details:", { pathname, isScenesTab, isMarkersTab, isGroupsTab });
434+
const isPerformersTab = pathname.endsWith('/performers');
435+
// console.log("Tag page details:", { pathname, isScenesTab, isMarkersTab, isGroupsTab, isPerformersTab });
435436

436437
let scenePreviews = [];
437438
let markerPreviews = [];
438439
let groupScenePreviews = []; // Videos from scenes in groups linked to the tag
440+
let performerScenePreviews = []; // Videos from scenes with performers who have the tag
439441

440442
const scenesQuery = `
441443
query FindScenesForTag($id: ID!) {
@@ -516,7 +518,59 @@
516518

517519
}
518520

519-
if (isScenesTab || (!isScenesTab && !isMarkersTab)) { // Fetch scenes for scenes tab or main tag page
521+
if (isPerformersTab) { // Fetch scenes from performers who have the tag for the performers tab
522+
// console.log("Fetching scenes from performers for tag page...");
523+
// First, find performers associated with the tag
524+
const performersQuery = `
525+
query FindPerformersForTag($tagId: ID!) {
526+
findPerformers(performer_filter: { tags: { value: [$tagId], modifier: INCLUDES_ALL } }) {
527+
performers {
528+
id
529+
}
530+
}
531+
}
532+
`;
533+
const performersResponse = await csLib.callGQL({ query: performersQuery, variables: { tagId: id } });
534+
// console.log("GraphQL Performers Response (Tags page, Performers tab):", performersResponse);
535+
536+
const performerIds = performersResponse?.findPerformers?.performers?.map(performer => performer.id) || [];
537+
// console.log("Performer IDs associated with tag:", performerIds);
538+
539+
if (performerIds.length > 0) {
540+
// Then, find scenes associated with these performers
541+
const scenesByPerformerQuery = `
542+
query FindScenesByPerformerIds($performerIds: [ID!]) {
543+
findScenes(scene_filter: { performers: { value: $performerIds, modifier: INCLUDES } }) {
544+
scenes {
545+
id
546+
paths {
547+
preview
548+
}
549+
}
550+
}
551+
}
552+
`;
553+
const scenesByPerformerResponse = await csLib.callGQL({ query: scenesByPerformerQuery, variables: { performerIds } });
554+
// console.log("GraphQL Scenes by Performer Response (Tags page, Performers tab):", scenesByPerformerResponse);
555+
556+
performerScenePreviews = scenesByPerformerResponse?.findScenes?.scenes
557+
?.filter(scene => scene.paths?.preview)
558+
.map(scene => `${scene.paths.preview}?_ts=${Date.now()}`) || [];
559+
// console.log("Performer scene preview URLs (Tags page, Performers tab):", performerScenePreviews);
560+
561+
// Shuffle the collected performer scene preview URLs
562+
for (let i = performerScenePreviews.length - 1; i > 0; i--) {
563+
const j = Math.floor(Math.random() * (i + 1));
564+
[performerScenePreviews[i], performerScenePreviews[j]] = [performerScenePreviews[j], performerScenePreviews[i]];
565+
}
566+
// console.log("Shuffled performer scene preview URLs (Tags page, Performers tab):", performerScenePreviews);
567+
} else {
568+
// console.log("No performers found for this tag.");
569+
}
570+
571+
}
572+
573+
if (isScenesTab || (!isScenesTab && !isMarkersTab && !isGroupsTab && !isPerformersTab)) { // Fetch scenes for scenes tab or main tag page
520574
// console.log("Fetching scenes for tag page...");
521575
const scenesResponse = await csLib.callGQL({ query: scenesQuery, variables: { id } });
522576
// console.log("GraphQL Scenes Response (Tags page):", scenesResponse);
@@ -526,7 +580,7 @@
526580
// console.log("Scene preview URLs (Tags page):", scenePreviews);
527581
}
528582

529-
if (isMarkersTab || (!isScenesTab && !isMarkersTab)) { // Fetch markers for markers tab or main tag page
583+
if (isMarkersTab || (!isScenesTab && !isMarkersTab && !isGroupsTab && !isPerformersTab)) { // Fetch markers for markers tab or main tag page
530584
// console.log("Fetching markers for tag page...");
531585
const markersResponse = await csLib.callGQL({ query: markersQuery, variables: { id } });
532586
// console.log("GraphQL Markers Response (Tags page):", markersResponse);
@@ -540,6 +594,9 @@
540594
if (isGroupsTab) {
541595
videoUrls = groupScenePreviews; // Only group scene previews on groups tab
542596
// console.log("Video URLs (Groups tab):", videoUrls);
597+
} else if (isPerformersTab) {
598+
videoUrls = performerScenePreviews; // Only performer scene previews on performers tab
599+
// console.log("Video URLs (Performers tab):", videoUrls);
543600
} else if (isMarkersTab) {
544601
videoUrls = markerPreviews; // Only marker previews on markers tab
545602
// console.log("Video URLs (Markers tab):", videoUrls);
@@ -598,6 +655,8 @@
598655
currentVideoIndex = Math.floor(Math.random() * videoUrls.length);
599656
if (isGroupsTab) {
600657
// console.log(`Starting slideshow with a random group scene preview at index: ${currentVideoIndex} (out of ${videoUrls.length} total videos) on Groups tab.`);
658+
} else if (isPerformersTab) {
659+
// console.log(`Starting slideshow with a random performer scene preview at index: ${currentVideoIndex} (out of ${videoUrls.length} total videos) on Performers tab.`);
601660
} else if (isMarkersTab) {
602661
// console.log(`Starting slideshow with a random marker preview at index: ${currentVideoIndex} (out of ${videoUrls.length} total videos) on Markers tab.`);
603662
} else if (isScenesTab) {

plugins/VideoBanner/VideoBanner.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Video Banner
22
description: Displays random generated preview videos in the detail page banner.
3-
version: 0.1
3+
version: 0.1.1
44
#url: https://github.com/your_repo # Replace with your plugin repository URL
55

66
ui:

0 commit comments

Comments
 (0)