Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add Studio and Performer buttons #5

Closed
sampulsar opened this issue Oct 21, 2024 · 5 comments · Fixed by #29
Closed

Feature: Add Studio and Performer buttons #5

sampulsar opened this issue Oct 21, 2024 · 5 comments · Fixed by #29
Labels
enhancement New feature or request

Comments

@sampulsar
Copy link
Contributor

Pull request Whisparr/Whisparr#274 will allow a studio or performers information to be returned by a stashID

You could do something to toggle on monitoring, or perform a search. Example of showing if a performer is monitored

// Function to add the button when the card-header element is found
function addButtonToPerfomerHeader() {
    const cardHeader = document.querySelector('.PerformerInfo .card-header');
    if (cardHeader && !document.querySelector('#whisparrButtonHeader')) {
        const triggerButton = createHeaderButton();
        cardHeader.appendChild(triggerButton);
        const performerID = window.location.href.split(`https://stashdb.org/performers/`)[1];
        handlePerformerLookup(triggerButton, performerID, true);
    }
}

function handlePerformerLookup(button, performerID, isHeader) {
if (performerID) {
const fullApiUrl = ${config.apiUrl}performer?stashId=${encodeURIComponent(performerID)};
fetch(fullApiUrl, { method: 'GET', headers: createHeaders() })
.then(response => response.json())
.then(data => {
if (data?.length > 0) {
if (data[0].monitored) {
button.innerHTML = '';
button.style.color = '#ffffffcc';
button.style.backgroundColor = '#4CAF50';;
} else {
button.innerHTML = '';
button.style.backgroundColor = '#e385ed';
button.style.color = '#ffffffcc';
}

                }
            })
            .catch(error => {
                console.error('API Call Error:', error);
                showToast('Error checking scene in Whisparr.', false);
            });
    } else {
        console.log('No StashID in the URL.');
        showToast('No valid StashID found in the URL.', false);
    }
}
@enymawse
Copy link
Owner

Completely redesigned the userscript. I'm going to put this in the backlog for sure. I like this idea for those that dont use the Import List for StashDB favorites.

@enymawse enymawse added the enhancement New feature or request label Oct 22, 2024
@enymawse enymawse moved this to In Progress in stasharr Nov 6, 2024
@enymawse
Copy link
Owner

enymawse commented Nov 6, 2024

Working this in branch feature/add-studio-monitoring-toggle.

@sampulsar
Copy link
Contributor Author

@enymawse

When I initially used it I was going to put a place holder before it calls the api, so that it would say loading like on the buttons.

It was a rush job to give you a good head start on displaying this information. The code looks good.

@enymawse
Copy link
Owner

enymawse commented Nov 7, 2024

Being monitored or unmonitored must be predicated by the studio or performer existing in the users Whisparr instance otherwise when querying Whisparr, WhisparrService.handleStudioLookup wouldn't return anything.

I haven't found a way to add a studio into Whisparr via the API, maybe I totally missed it but I don't think it's there.

@sampulsar
Copy link
Contributor Author

Added it as a pull request Whisparr/Whisparr#288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants