代码拉取完成,页面将自动刷新
# Copyright (c) 2021 by xfangfang. All Rights Reserved.
import os
import sys
import gettext
import logging
from macast import Setting, SETTING_DIR
from macast.macast import gui
logger = logging.getLogger("Macast")
logger.setLevel(logging.DEBUG)
def get_base_path(path="."):
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
base_path = sys._MEIPASS
else:
base_path = os.getcwd()
return os.path.join(base_path, path)
def set_mpv_default_path():
mpv_path = 'mpv'
if sys.platform == 'darwin':
mpv_path = get_base_path('bin/MacOS/mpv')
elif sys.platform == 'win32':
mpv_path = get_base_path('bin/mpv.exe')
Setting.mpv_default_path = mpv_path
return mpv_path
def get_lang():
locale = Setting.get_locale()
i18n_path = get_base_path('i18n')
if not os.path.exists(os.path.join(i18n_path, locale, 'LC_MESSAGES', 'macast.mo')):
locale = locale.split("_")[0]
logger.error("Macast Loading Language: {}".format(locale))
try:
lang = gettext.translation('macast', localedir=i18n_path, languages=[locale])
lang.install()
except Exception:
import builtins
builtins.__dict__['_'] = gettext.gettext
logger.error("Macast Loading Default Language en_US")
def clear_env():
# todo clear pyinstaller file on start
log_path = os.path.join(SETTING_DIR, 'macast.log')
try:
os.remove(log_path)
except:
pass
if __name__ == '__main__':
clear_env()
get_lang()
set_mpv_default_path()
gui(lang=_)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。