16
16
17
17
18
18
class Helper (object ):
19
+ _addon = xbmcaddon .Addon ('script.module.inputstreamhelper' )
20
+ _addon_profile = xbmc .translatePath (_addon .getAddonInfo ('profile' ))
21
+ _language = _addon .getLocalizedString
22
+
19
23
def __init__ (self , protocol , drm = None ):
20
- self ._addon = xbmcaddon .Addon ('script.module.inputstreamhelper' )
21
- self ._addon_profile = xbmc .translatePath (self ._addon .getAddonInfo ('profile' ))
22
- self ._language = self ._addon .getLocalizedString
23
24
self ._os = platform .system ()
24
25
self ._log ('Platform information: {0}' .format (platform .uname ()))
25
26
@@ -43,6 +44,7 @@ def __init__(self, protocol, drm=None):
43
44
else :
44
45
self .drm = config .DRM_SCHEMES [drm ]
45
46
47
+
46
48
class InputStreamException (Exception ):
47
49
pass
48
50
@@ -62,50 +64,38 @@ def _cmd_exists(cmd):
62
64
# https://stackoverflow.com/questions/377017/test-if-executable-exists-in-python
63
65
return subprocess .call ('type ' + cmd , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE ) == 0
64
66
65
- def _arch (self ):
66
- """Map together and return the system architecture."""
67
- arch = platform .machine ()
68
- if arch in config .X86_MAP :
69
- return config .X86_MAP [arch ]
70
- elif 'armv' in arch :
71
- arm_arch = 'armv' + arch .split ('v' )[1 ][:- 1 ]
72
- return arm_arch
73
-
74
- return arch
75
-
76
- def _log (self , string ):
77
- """InputStream Helper log method."""
78
- logging_prefix = '[{0}-{1}]' .format (self ._addon .getAddonInfo ('id' ), self ._addon .getAddonInfo ('version' ))
79
- msg = '{0}: {1}' .format (logging_prefix , string )
80
- xbmc .log (msg = msg , level = xbmc .LOGDEBUG )
81
-
82
- def _diskspace (self ):
67
+ @classmethod
68
+ def _diskspace (cls ):
83
69
"""Return the free disk space available (in bytes) in cdm_path."""
84
- statvfs = os .statvfs (self ._cdm_path ())
70
+ statvfs = os .statvfs (cls ._cdm_path ())
85
71
return statvfs .f_frsize * statvfs .f_bavail
86
72
87
- def _temp_path (self ):
88
- temp_path = os .path .join (self ._addon_profile , 'tmp' )
73
+ @classmethod
74
+ def _temp_path (cls ):
75
+ temp_path = os .path .join (cls ._addon_profile , 'tmp' )
89
76
if not xbmcvfs .exists (temp_path ):
90
77
xbmcvfs .mkdir (temp_path )
91
78
92
79
return temp_path
93
80
94
- def _mnt_path (self ):
95
- mnt_path = os .path .join (self ._temp_path (), 'mnt' )
81
+ @classmethod
82
+ def _mnt_path (cls ):
83
+ mnt_path = os .path .join (cls ._temp_path (), 'mnt' )
96
84
if not xbmcvfs .exists (mnt_path ):
97
85
xbmcvfs .mkdir (mnt_path )
98
86
99
87
return mnt_path
100
88
101
- def _cdm_path (self ):
102
- cdm_path = os .path .join (self ._addon_profile , 'cdm' )
89
+ @classmethod
90
+ def _cdm_path (cls ):
91
+ cdm_path = os .path .join (cls ._addon_profile , 'cdm' )
103
92
if not xbmcvfs .exists (cdm_path ):
104
93
xbmcvfs .mkdir (cdm_path )
105
94
106
95
return cdm_path
107
96
108
- def _ia_cdm_path (self ):
97
+ @classmethod
98
+ def _ia_cdm_path (cls ):
109
99
"""Return the specified CDM path for inputstream.adaptive."""
110
100
addon = xbmcaddon .Addon ('inputstream.adaptive' )
111
101
cdm_path = xbmc .translatePath (addon .getSetting ('DECRYPTERPATH' ))
@@ -114,14 +104,32 @@ def _ia_cdm_path(self):
114
104
115
105
return cdm_path
116
106
117
- def _kodi_version (self ):
107
+ @classmethod
108
+ def _kodi_version (cls ):
118
109
version = xbmc .getInfoLabel ('System.BuildVersion' )
119
110
return version .split (' ' )[0 ]
120
111
121
112
def _inputstream_version (self ):
122
113
addon = xbmcaddon .Addon (self ._inputstream_addon )
123
114
return addon .getAddonInfo ('version' )
124
115
116
+ def _arch (self ):
117
+ """Map together and return the system architecture."""
118
+ arch = platform .machine ()
119
+ if arch in config .X86_MAP :
120
+ return config .X86_MAP [arch ]
121
+ elif 'armv' in arch :
122
+ arm_arch = 'armv' + arch .split ('v' )[1 ][:- 1 ]
123
+ return arm_arch
124
+
125
+ return arch
126
+
127
+ def _log (self , string ):
128
+ """InputStream Helper log method."""
129
+ logging_prefix = '[{0}-{1}]' .format (self ._addon .getAddonInfo ('id' ), self ._addon .getAddonInfo ('version' ))
130
+ msg = '{0}: {1}' .format (logging_prefix , string )
131
+ xbmc .log (msg = msg , level = xbmc .LOGDEBUG )
132
+
125
133
def _parse_chromeos_offset (self , bin_path ):
126
134
"""Calculate the Chrome OS losetup start offset using fdisk/parted."""
127
135
if self ._cmd_exists ('fdisk' ):
0 commit comments