Skip to content

Commit

Permalink
Better configuration file format
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Sep 17, 2021
1 parent ef80ad1 commit cfb1ce3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Macast.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
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)


try:
locale = Setting.get_locale()
lang = gettext.translation('macast', localedir=get_base_path('i18n'), languages=[locale])
Expand All @@ -29,6 +31,7 @@ def get_base_path(path="."):
logger.error("Macast Loading Default Language en_US")

if __name__ == '__main__':
Setting.load()
mpv_path = 'mpv'
if sys.platform == 'darwin':
mpv_path = get_base_path('bin/MacOS/mpv')
Expand Down
4 changes: 2 additions & 2 deletions i18n/zh_CN/LC_MESSAGES/macast.po
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ msgstr "打开配置目录"
msgid "Check For Updates"
msgstr "检查更新"

msgid "About"
msgstr "关于"
msgid "Help"
msgstr "帮助"

msgid "Macast New Update {}"
msgstr "Macast有新版本 {}"
Expand Down
4 changes: 2 additions & 2 deletions macast/macast.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def build_setting_menu(self):
], self.on_menubar_icon_change_click))
self.open_config_menuitem = MenuItem(_("Open Config Directory"), self.on_open_config_click)
self.check_update_menuitem = MenuItem(_("Check For Updates"), self.on_check_click)
self.about_menuitem = MenuItem(_("About"), self.on_about_click)
self.about_menuitem = MenuItem(_("Help"), self.on_about_click)

self.menubar_icon_menuitem.items()[self.setting_menubar_icon].checked = True
player_settings = self.dlna_service.renderer.renderer_setting.build_menu()
Expand Down Expand Up @@ -588,7 +588,7 @@ def on_start_at_login_click(self, item):
self.notification(_("Error"), _(res[1]))

def on_about_click(self, _):
self.open_browser('https://github.com/xfangfang/Macast')
self.open_browser('https://xfangfang.github.io/Macast/')

def on_toggle_service_click(self, item):
if Setting.is_service_running():
Expand Down
2 changes: 1 addition & 1 deletion macast/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def save():
if not os.path.exists(SETTING_DIR):
os.makedirs(SETTING_DIR)
with open(Setting.setting_path, "w") as f:
json.dump(obj=Setting.setting, fp=f)
json.dump(obj=Setting.setting, fp=f, sort_keys=True, indent=4)

@staticmethod
def load():
Expand Down
3 changes: 3 additions & 0 deletions macast_renderer/mpv.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self, lang=gettext.gettext, path="mpv"):
self.mpv_sock = '/tmp/macast_mpvsocket{}'.format(mpv_rand)
self.path = path
self.proc = None
self.title = Setting.get_friendly_name()
self.mpv_thread = None
self.ipc_thread = None
self.ipc_sock = None
Expand Down Expand Up @@ -99,6 +100,7 @@ def set_media_url(self, data):
def set_media_title(self, data):
""" data : string
"""
self.title = data
self.send_command(['set_property', 'title', data])

def set_media_position(self, data):
Expand Down Expand Up @@ -408,6 +410,7 @@ def reload(self):
def loadfile():
logger.debug("mpv loadfile")
self.send_command(['loadfile', uri, 'replace'])
self.send_command(['set_property', 'title', self.title])
cherrypy.engine.unsubscribe('mpvipc_start', loadfile)

def resatrt():
Expand Down

0 comments on commit cfb1ce3

Please sign in to comment.