Added support for creating a .app file (#184)

* Added support for creating a .app file

* Updated webclient to use get_resources properly and added an extra check for mpv_location

* code fixes and removed unneccesary check for platform

* changed mpv location conditional to check if it's frozen

* forgot to use get_resource for packaged mpv

* added platform check for get_resource
This commit is contained in:
Bruk Berhane Asfaw 2021-03-23 09:08:53 -07:00 committed by GitHub
parent b078f0091b
commit 4eda21e688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 2 deletions

BIN
jellyfin.icns Normal file

Binary file not shown.

View File

@ -2,6 +2,7 @@ import logging
import os
import sys
import time
import platform
from threading import RLock, Lock, Event
from queue import Queue
@ -123,6 +124,10 @@ class PlayerManager(object):
def __init__(self):
self._video = None
mpv_options = OrderedDict()
mpv_location = settings.mpv_ext_path
# Use bundled path for MPV if not specified by user, on Mac OS, and frozen
if mpv_location is None and platform.system() == "Darwin" and getattr(sys, 'frozen', False):
mpv_location = get_resource('mpv')
self.timeline_trigger = None
self.action_trigger = None
self.external_subtitles = {}
@ -149,7 +154,7 @@ class PlayerManager(object):
{
"start_mpv": settings.mpv_ext_start,
"ipc_socket": settings.mpv_ext_ipc,
"mpv_location": settings.mpv_ext_path,
"mpv_location": mpv_location,
"player-operation-mode": "cplayer",
}
)

View File

@ -6,6 +6,7 @@ from threading import Lock
import logging
import sys
import os.path
import platform
from .conf import settings
from datetime import datetime
@ -234,6 +235,10 @@ def get_resource(*path):
else:
application_path = os.path.dirname(os.path.abspath(__file__))
# ! Test code for Mac
if getattr(sys, 'frozen', False) and platform.system() == 'Darwin':
application_path = os.path.join(os.path.dirname(sys.executable), "../Resources")
return os.path.join(application_path, *path)

View File

@ -57,7 +57,7 @@ class Server(threading.Thread):
app = Flask(
__name__,
static_url_path="",
static_folder=get_resource("webclient_view", "webclient"),
static_folder=get_resource("webclient_view", "webclient")
)
@app.after_request

22
setup-mac.py Normal file
View File

@ -0,0 +1,22 @@
from setuptools import setup
APP = ['/usr/local/bin/jellyfin-mpv-desktop']
OPTIONS = {
'argv_emulation' : True,
'iconfile' : 'jellyfin.icns',
'resources' : [
'/usr/local/bin/mpv',
'/usr/local/bin/jellyfin-mpv-shim',
'/usr/local/lib/python3.9/site-packages/jellyfin_mpv_shim/webclient_view'
],
'packages': [
'pkg_resources'
]
}
setup(
app=APP,
name='Jellyfin MPV Desktop',
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)