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

Add support for regional, alternate, altdvd orders #139

Merged
merged 1 commit into from
May 17, 2024

Conversation

scampower3
Copy link
Member

@scampower3 scampower3 commented May 14, 2024

Fixes: #49
Requires: jellyfin/jellyfin-web#5505

@scampower3 scampower3 marked this pull request as ready for review May 17, 2024 04:17
@scampower3
Copy link
Member Author

Can be merged before web changes.

@scampower3
Copy link
Member Author

scampower3 commented May 17, 2024

Here's a simple userscript to inject the options if the web changes are not merged. Replace [protocal] with http or https and replace [url] with your ip+port or domain of Jellyfin.

To be used with any user script manager like Tampermonkey or Violentmonkey.

// ==UserScript==
// @name         Tvdb Display Order Options Injector
// @namespace    http://tampermonkey.net/
// @version      2024-05-17
// @description  Adds missing Tvdb Display Order in Jellyfin.
// @author       scampower3
// @match        [protocal]://[url]/web/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=greasyfork.org
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    console.log("Tvdb Display Order Options Injector Script loaded");
    /**Setup Event Listeners */
    document.addEventListener('viewshow', viewShowEvent)

    // Mutation Observer
    const observer = new MutationObserver(injectDisplayOrderOptions);
    // Only observe when on tv.html, details, home.html, or search.html
    observer.disconnect();

    function viewShowEvent(){
        const location = window.location.hash;
        console.debug("Current: " + location);
        if (location.startsWith('#/tv.html') || location.startsWith('#/details') || location.startsWith('#/home.html') || location.startsWith('#/search.html')){
            console.debug('Connecting Observer');
            observer.observe(document.body, {childList: true, subtree: true});
        }
        else{
            console.debug('Disconnecting Observer');
            observer.disconnect();
        }
    }

    function injectDisplayOrderOptions(MutationList, observer){
        console.debug("Mutation Observer Triggered");
        const selectDisplayOrder = document.getElementById('selectDisplayOrder');

        if (!selectDisplayOrder){
            console.debug('selectDisplayOrder not found');
            return;
        }
        console.debug('selectDisplayOrder found');
        console.debug('Injecting Options')
        observer.disconnect();
        const options = [
            {value: 'alternate', text: 'Alternate'},
            {value: 'regional', text: 'Regional'},
            {value: 'altdvd', text: 'Alternate DVD'}
        ]
        //check if options already exist
        if (selectDisplayOrder.options.length > 8){
            console.debug('Options already exist');
            observer.observe(document.body, {childList: true, subtree: true});
            return;
        }
        options.forEach(option => {
            const optionElement = document.createElement('option');
            optionElement.value = option.value;
            optionElement.text = option.text;
            selectDisplayOrder.appendChild(optionElement);
        });
        observer.observe(document.body, {childList: true, subtree: true});
    }
})();

@crobibero crobibero merged commit 236d28e into jellyfin:master May 17, 2024
4 checks passed
@scampower3 scampower3 deleted the support-alt-order branch May 17, 2024 13:56
@scampower3 scampower3 added the feature This PR or Issue requests or introduces a new feature label May 22, 2024
@Blazeflack
Copy link

@scampower3 I don't suppose your nifty user-script will work on Jellyfin 10.8.11? I am sadly forced to stick with that version as I use Jellyfin on a Synology NAS and want to use hardware transcoding.

@scampower3
Copy link
Member Author

scampower3 commented May 31, 2024

Should work just fine, but the extra options that the script adds is for TheTvdb plugin 12.0.0.0

@onivlis38
Copy link

I'm a bit confused here, if I want to use TVDBs alternate order, do I need to use this script, or are the changes already in the plugin itself?

@scampower3
Copy link
Member Author

Need to use the script until Jellyfin 10.10 is released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This PR or Issue requests or introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow using alternate order
5 participants