load player config from file
This commit is contained in:
parent
6cdbf4f1b9
commit
8268166b77
1 changed files with 24 additions and 10 deletions
|
@ -20,10 +20,15 @@ SYNC_GRACE_TIME = 5
|
|||
SYNC_JUMP_AHEAD = 1
|
||||
PORT = 9067
|
||||
DEBUG = False
|
||||
FONT = 'Menlo'
|
||||
FONT_SIZE = 30
|
||||
FONT_BORDER = 4
|
||||
SUB_MARGIN = 2 * 36 + 6
|
||||
|
||||
CONFIG = {
|
||||
"font": "Menlo",
|
||||
"font_size": 30,
|
||||
"font_border": 4,
|
||||
"sub_margin": 2 * 36 + 6,
|
||||
"sub_spacing": 0,
|
||||
"vf": None
|
||||
}
|
||||
|
||||
|
||||
def hide_gnome_overview():
|
||||
|
@ -74,18 +79,22 @@ class Sync(Thread):
|
|||
self.mpv = mpv.MPV(
|
||||
log_handler=mpv_log, input_default_bindings=True,
|
||||
input_vo_keyboard=True,
|
||||
sub_font_size=FONT_SIZE, sub_font=FONT,
|
||||
sub_border_size=FONT_BORDER,
|
||||
sub_margin_y=SUB_MARGIN,
|
||||
sub_font_size=CONFIG["font_size"], sub_font=CONFIG["font"],
|
||||
sub_border_size=CONFIG["font_border"],
|
||||
sub_margin_y=CONFIG["sub_margin"],
|
||||
sub_ass_line_spacing=CONFIG["sub_spacing"],
|
||||
)
|
||||
else:
|
||||
self.mpv = mpv.MPV(
|
||||
log_handler=mpv_log, input_default_bindings=True,
|
||||
input_vo_keyboard=True,
|
||||
sub_text_font_size=FONT_SIZE, sub_text_font=FONT,
|
||||
sub_border_size=FONT_BORDER,
|
||||
sub_margin_y=SUB_MARGIN,
|
||||
sub_text_font_size=CONFIG["font_size"], sub_text_font=CONFIG["font"],
|
||||
sub_border_size=CONFIG["font_border"],
|
||||
sub_margin_y=CONFIG["sub_margin"],
|
||||
sub_ass_line_spacing=CONFIG["sub_spacing"],
|
||||
)
|
||||
if CONFIG.get("vf"):
|
||||
self.mpv.vf = CONFIG["vf"]
|
||||
self.mpv.observe_property('time-pos', self.time_pos_cb)
|
||||
self.mpv.fullscreen = kwargs.get('fullscreen', False)
|
||||
self.mpv.loop_file = False
|
||||
|
@ -386,12 +395,17 @@ def main():
|
|||
parser.add_argument('--debug', action='store_true', help='debug', default=False)
|
||||
parser.add_argument('--hour', action='store_true', help='hour', default=False)
|
||||
parser.add_argument('--sax', action='store_true', help='hour', default=False)
|
||||
parser.add_argument('--config', help='config', default=None)
|
||||
args = parser.parse_args()
|
||||
|
||||
DEBUG = args.debug
|
||||
if DEBUG:
|
||||
log_format = '%(asctime)s:%(levelname)s:%(name)s:%(message)s'
|
||||
logging.basicConfig(level=logging.DEBUG, format=log_format)
|
||||
if args.config:
|
||||
with open(args.config) as fd:
|
||||
CONFIG.update(json.load(fd))
|
||||
|
||||
base = os.path.dirname(os.path.abspath(__file__))
|
||||
#os.chdir(base)
|
||||
|
||||
|
|
Loading…
Reference in a new issue