lol

add Plex kodi addon (#435793)

authored by

Aaron Andersen and committed by
GitHub
8f2652b4 dea2d6b9

+132
+51
pkgs/applications/video/kodi/addons/plex-for-kodi/default.nix
··· 1 + { 2 + lib, 3 + addonDir, 4 + buildKodiAddon, 5 + fetchFromGitHub, 6 + addonUpdateScript, 7 + kodi-six, 8 + six, 9 + requests, 10 + }: 11 + 12 + buildKodiAddon rec { 13 + pname = "plex"; 14 + namespace = "script.plex"; 15 + version = "0.7.9-rev4"; 16 + 17 + src = fetchFromGitHub { 18 + owner = "pannal"; 19 + repo = "plex-for-kodi"; 20 + rev = "v${version}"; 21 + sha256 = "sha256-rNxTz3SKHHBm0WDCoZ/foJN2pBBiyI3a/tOdQdOCuXA="; 22 + }; 23 + 24 + # Plex for Kodi writes to its own directory by default, needs to be patched to a non-store path. 25 + # Once https://github.com/pannal/plex-for-kodi/pull/219 is merged, this can be replaced with a smaller patch that just sets the environment variable INSTALLATION_DIR_AVOID_WRITE, e.g. adding to main.py: 26 + # import os; os.environ("INSTALLATION_DIR_AVOID_WRITE") = True 27 + patches = [ ./plex-template-dir.patch ]; 28 + 29 + propagatedBuildInputs = [ 30 + six 31 + requests 32 + kodi-six 33 + ]; 34 + 35 + passthru = { 36 + updateScript = addonUpdateScript { 37 + attrPath = "kodi.packages.plex"; 38 + }; 39 + }; 40 + 41 + postInstall = '' 42 + mv /build/source/addon.xml $out${addonDir}/${namespace}/ 43 + ''; 44 + 45 + meta = with lib; { 46 + homepage = "https://www.plex.tv"; 47 + description = "Unofficial Plex for Kodi add-on"; 48 + license = licenses.gpl2Only; 49 + maintainers = teams.kodi.members; 50 + }; 51 + }
+79
pkgs/applications/video/kodi/addons/plex-for-kodi/plex-template-dir.patch
··· 1 + diff --git a/lib/_included_packages/plexnet/gdm.py b/lib/_included_packages/plexnet/gdm.py 2 + index ccc540ae..3dce02a3 100644 3 + --- a/lib/_included_packages/plexnet/gdm.py 4 + +++ b/lib/_included_packages/plexnet/gdm.py 5 + @@ -28,7 +28,7 @@ class GDMDiscovery(object): 6 + from . import plexapp 7 + return util.INTERFACE.getPreference("gdm_discovery", True) and self.thread and self.thread.is_alive() 8 + 9 + - ''' 10 + + r''' 11 + def discover(self): 12 + # Only allow discovery if enabled and not currently running 13 + self._close = False 14 + diff --git a/lib/templating/core.py b/lib/templating/core.py 15 + index 30a53392..e0249e1d 100644 16 + --- a/lib/templating/core.py 17 + +++ b/lib/templating/core.py 18 + @@ -7,6 +7,7 @@ from kodi_six import xbmcvfs, xbmc 19 + from ibis.context import ContextDict 20 + from lib.logging import log as LOG, log_error as ERROR 21 + from .util import deep_update 22 + +from ..util import PROFILE 23 + from lib.os_utils import fast_iglob 24 + from .filters import * 25 + 26 + @@ -59,11 +60,22 @@ class TemplateEngine(object): 27 + TEMPLATES = None 28 + 29 + def init(self, target_dir, template_dir, custom_template_dir): 30 + - self.target_dir = target_dir 31 + + # Redirect template write target_dir to writable addon_data 32 + + writable_base = os.path.join(PROFILE, "resources/skins/Main/1080i") 33 + + os.makedirs(writable_base, exist_ok=True) 34 + + # Link media dir into addon dir, so templates can access it via relative path 35 + + link_path = os.path.join(PROFILE, "resources/skins/Main/media") 36 + + if not os.path.exists(link_path): 37 + + os.symlink( 38 + + os.path.join(os.path.dirname(target_dir), "media"), 39 + + link_path, 40 + + True 41 + + ) 42 + + self.target_dir = writable_base 43 + self.template_dir = template_dir 44 + self.custom_template_dir = custom_template_dir 45 + self.get_available_templates() 46 + - paths = [custom_template_dir, template_dir] 47 + + paths = [custom_template_dir, self.template_dir] 48 + 49 + LOG("Looking for templates in: {}", paths) 50 + self.prepare_loader(paths) 51 + diff --git a/lib/windows/kodigui.py b/lib/windows/kodigui.py 52 + index be7ef154..e8cc09b9 100644 53 + --- a/lib/windows/kodigui.py 54 + +++ b/lib/windows/kodigui.py 55 + @@ -4,6 +4,7 @@ from __future__ import absolute_import 56 + import threading 57 + import time 58 + import traceback 59 + +import os 60 + 61 + from kodi_six import xbmc 62 + from kodi_six import xbmcgui 63 + @@ -41,13 +42,14 @@ class BaseFunctions(object): 64 + 65 + @classmethod 66 + def open(cls, **kwargs): 67 + - window = cls(cls.xmlFile, cls.path, cls.theme, cls.res, **kwargs) 68 + + window = cls(cls.xmlFile, util.PROFILE, cls.theme, cls.res, **kwargs) 69 + window.modal() 70 + return window 71 + 72 + @classmethod 73 + def create(cls, show=True, **kwargs): 74 + - window = cls(cls.xmlFile, cls.path, cls.theme, cls.res, **kwargs) 75 + + window = cls(cls.xmlFile, util.PROFILE, cls.theme, cls.res, **kwargs) 76 + + 77 + if show: 78 + window.show() 79 + if xbmcgui.getCurrentWindowId() < 13000:
+2
pkgs/top-level/kodi-packages.nix
··· 129 129 130 130 netflix = callPackage ../applications/video/kodi/addons/netflix { }; 131 131 132 + plex-for-kodi = callPackage ../applications/video/kodi/addons/plex-for-kodi { }; 133 + 132 134 orftvthek = callPackage ../applications/video/kodi/addons/orftvthek { }; 133 135 134 136 radioparadise = callPackage ../applications/video/kodi/addons/radioparadise { };