1- #import logging
2- import os
31import sys
42from html import unescape
5-
6- from typing import Union
7- from typing import NamedTuple
3+ from os import getenv
4+ from os . path import join , dirname
5+ from typing import Union , NamedTuple
86
97from .player .android import AndroidChoosePlayer
108from .player .common import Player
1513from .player .wmplayer import WMPlayer
1614
1715is_android = hasattr (sys , "getandroidapilevel" )
16+ is_windows = sys .platform .startswith ("win" )
17+ is_linux = sys .platform .startswith ("linux" )
18+ is_mac_os = sys .platform .startswith ("darwin" )
19+ is_bsd = "freebsd" in sys .platform or sys .platform .startswith ("dragonfly" )
1820
1921try :
2022 from orjson import loads as json_loads
21- # logging.debug("Using orjson")
2223except ImportError :
2324 from json import loads as json_loads
24- # logging.debug("Using default json")
2525
2626
2727def detect_player () -> Union [Player , None ]:
@@ -47,51 +47,35 @@ def detect_player() -> Union[Player, None]:
4747 return None
4848
4949
50- def is_windows ():
51- return sys .platform .startswith ("win" )
52-
53-
54- def is_linux ():
55- return sys .platform .startswith ("linux" )
56-
57-
58- def is_mac_os ():
59- return sys .platform .startswith ("darwin" )
60-
61-
62- def is_bsd ():
63- return "freebsd" in sys .platform or sys .platform .startswith ("dragonfly" )
64-
65-
6650class VLCPaths (NamedTuple ):
6751 vlc_intf_path : str
6852 vlc_intf_user_path : str
6953 vlc_module_path : str
7054
7155
7256def get_vlc_intf_user_path (player_path : str ) -> VLCPaths :
73- if is_linux () :
57+ if is_linux :
7458 if 'snap' in player_path :
7559 vlc_intf_path = '/snap/vlc/current/usr/lib/vlc/lua/intf/'
76- vlc_intf_user_path = os . path . join (os . getenv ('HOME' , '.' ), "snap/vlc/current/.local/share/vlc/lua/intf/" )
60+ vlc_intf_user_path = join (getenv ('HOME' , '.' ), "snap/vlc/current/.local/share/vlc/lua/intf/" )
7761 else :
7862 vlc_intf_path = "/usr/lib/vlc/lua/intf/"
79- vlc_intf_user_path = os . path . join (os . getenv ('HOME' , '.' ), ".local/share/vlc/lua/intf/" )
80- elif is_mac_os () :
63+ vlc_intf_user_path = join (getenv ('HOME' , '.' ), ".local/share/vlc/lua/intf/" )
64+ elif is_mac_os :
8165 vlc_intf_path = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/"
82- vlc_intf_user_path = os . path . join (
83- os . getenv ('HOME' , '.' ), "Library/Application Support/org.videolan.vlc/lua/intf/" )
84- elif is_bsd () :
66+ vlc_intf_user_path = join (
67+ getenv ('HOME' , '.' ), "Library/Application Support/org.videolan.vlc/lua/intf/" )
68+ elif is_bsd :
8569 # *BSD ports/pkgs install to /usr/local by default.
8670 # This should also work for all the other BSDs, such as OpenBSD or DragonFly.
8771 vlc_intf_path = "/usr/local/lib/vlc/lua/intf/"
88- vlc_intf_user_path = os . path . join (os . getenv ('HOME' , '.' ), ".local/share/vlc/lua/intf/" )
72+ vlc_intf_user_path = join (getenv ('HOME' , '.' ), ".local/share/vlc/lua/intf/" )
8973 elif "vlcportable.exe" in player_path .lower ():
90- vlc_intf_path = os . path . dirname (player_path ).replace ("\\ " , "/" ) + "/App/vlc/lua/intf/"
74+ vlc_intf_path = dirname (player_path ).replace ("\\ " , "/" ) + "/App/vlc/lua/intf/"
9175 vlc_intf_user_path = vlc_intf_path
9276 else :
93- vlc_intf_path = os . path . dirname (player_path ).replace ("\\ " , "/" ) + "/lua/intf/"
94- vlc_intf_user_path = os . path . join (os . getenv ('APPDATA' , '.' ), "VLC\\ lua\\ intf\\ " )
77+ vlc_intf_path = dirname (player_path ).replace ("\\ " , "/" ) + "/lua/intf/"
78+ vlc_intf_user_path = join (getenv ('APPDATA' , '.' ), "VLC\\ lua\\ intf\\ " )
9579
9680 vlc_module_path = vlc_intf_path + "modules/?.luac"
9781
0 commit comments