-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added config class to make it easier to parse variables into correct …
…data type
- Loading branch information
1 parent
ddde009
commit d56dd29
Showing
5 changed files
with
55 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,3 +162,4 @@ cython_debug/ | |
.DS_Store | ||
static/ | ||
iptv.m3u | ||
epg.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
from configparser import ConfigParser | ||
from distutils.util import strtobool | ||
|
||
class Config: | ||
_config: ConfigParser | ||
|
||
def __init__(self, root_path: str): | ||
self._config = ConfigParser(allow_no_value=True) | ||
self._config.read(os.path.join(root_path, 'config.ini')) | ||
|
||
@property | ||
def M3U_LOCATION(self): | ||
return os.getenv('M3U_LOCATION', self._config.get('APP', 'M3U_LOCATION')) | ||
|
||
@property | ||
def XMLTV_LOCATION(self): | ||
return os.getenv('XMLTV_LOCATION', self._config.get('APP', 'XMLTV_LOCATION')) or '' | ||
|
||
@property | ||
def M3U_PORT(self): | ||
return int(os.getenv('M3U_PORT', self._config.get('APP', 'M3U_PORT')) or 0) | ||
|
||
@property | ||
def M3U_HOST(self): | ||
return os.getenv('M3U_HOST', self._config.get('APP', 'M3U_HOST')) | ||
|
||
@property | ||
def LISTEN_PORT(self): | ||
return int(os.getenv('LISTEN_PORT', self._config.get('APP', 'LISTEN_PORT'))) | ||
|
||
@property | ||
def USE_HTTPS(self): | ||
return strtobool(os.getenv('USE_HTTPS', self._config.get('APP', 'USE_HTTPS')) or 'False') == 1 | ||
|
||
@property | ||
def RELOAD_INTERVAL_MIN(self): | ||
return int(os.getenv('RELOAD_INTERVAL_MIN', self._config.get('APP', 'RELOAD_INTERVAL_MIN'))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters