forked from stickman89/Luna
-
Notifications
You must be signed in to change notification settings - Fork 8
Add OSMC launcher & some small fixes #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
agboom
wants to merge
3
commits into
TheChoconut:matrix
Choose a base branch
from
agboom:matrix
base: matrix
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,20 @@ | ||
| #!/usr/bin/sh | ||
|
|
||
| resume() { | ||
| killall -CONT kodi.bin | ||
| } | ||
|
|
||
| trap resume EXIT | ||
|
|
||
| killall -STOP kodi.bin | ||
|
|
||
| # prevent black screen after playing video | ||
| echo 1 > /sys/class/graphics/fb0/blank | ||
| echo "rm default" > /sys/class/vfm/map | ||
| echo add default decoder ppmgr deinterlace amlvideo amvideo > /sys/class/vfm/map | ||
|
|
||
| mv logfile logfile.old | ||
| LD_PRELOAD="/usr/local/lib/libmoonlight-aml.so /usr/osmc/lib/libamavutils.so /usr/osmc/lib/libamadec.so /usr/osmc/lib/libamcodec.so" \ | ||
| moonlight stream \ | ||
| -platform aml \ | ||
| -app "$@" >> logfile 2>&1 |
This file contains hidden or 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 @@ | ||
| #!/usr/bin/sh |
This file contains hidden or 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 @@ | ||
| #!/usr/bin/sh |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -59,20 +59,21 @@ def list_games(self): | |
| list_regex = r'\d+\.\s+([^\n]*)' | ||
|
|
||
| try: | ||
| moonlightOut = subprocess.check_output(['moonlight', 'list'], cwd=binary_path, timeout=5, encoding='utf-8', start_new_session=True) | ||
| host = self.plugin.getSetting('host_addr') | ||
| moonlightOut = subprocess.check_output(['moonlight', 'list', host], cwd=binary_path, timeout=5, encoding='utf-8', start_new_session=True) | ||
|
|
||
| if 'must pair' in moonlightOut: | ||
| return True | ||
|
|
||
| return re.findall(list_regex, moonlightOut) | ||
| except: | ||
| except Exception: | ||
| return False | ||
|
|
||
| def quit_game(self): | ||
| binary_path = self.config_helper.binary_path | ||
| try: | ||
| subprocess.run(['moonlight', 'quit'], cwd=binary_path, timeout=5, start_new_session=True) | ||
| except: | ||
| except Exception: | ||
| return False | ||
|
|
||
| return True | ||
|
|
@@ -104,14 +105,29 @@ def launch_game(self, game_id): | |
|
|
||
| xbmc.audioSuspend() | ||
| t0 = time.monotonic() | ||
| host = self.plugin.getSetting('host_addr') | ||
| subprocess.run([scripts_path + 'prescript.sh', binary_path, codec], cwd=scripts_path, start_new_session=True) | ||
| launch_cmd = subprocess.Popen([scripts_path + 'launch.sh', game_id], cwd=binary_path, start_new_session=True) | ||
| launch_cmd = subprocess.Popen( | ||
| [scripts_path + 'launch.sh', game_id, host], | ||
| cwd=scripts_path, | ||
| start_new_session=True, | ||
| stdout=subprocess.PIPE, | ||
| stderr=subprocess.PIPE, | ||
| ) | ||
| # pipe launch script output to Kodi logger | ||
| # moonlight launcher output should be logged to a file to prevent chatty Kodi logs (see any launch.sh) | ||
| with launch_cmd.stdout: | ||
| for line in iter(launch_cmd.stdout.readline, b''): | ||
| self.logger.info(f'{line}') | ||
| with launch_cmd.stderr: | ||
| for line in iter(launch_cmd.stderr.readline, b''): | ||
| self.logger.error(f'{line}') | ||
|
Comment on lines
+117
to
+124
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This helps me to debug things if the launch script fails. |
||
| launch_cmd.wait() | ||
| subprocess.run([scripts_path + 'postscript.sh', binary_path], cwd=scripts_path, start_new_session=True) | ||
|
|
||
| except Exception as e: | ||
| print("Failed to execute moonlight process.") | ||
| print(e) | ||
| self.logger.error("Failed to execute moonlight process.") | ||
| self.logger.error(str(e)) | ||
| finally: | ||
| xbmc.audioResume() | ||
| xbmc.executebuiltin("InhibitScreensaver(false)") | ||
|
|
||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds the configured host address as argument to moonlight. Without it, Luna would err on my system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is because I don't have any mDNS configured on my network. Is this something we need to take into account?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking more closely, I think this is because the written config file is not read. Luna writes
moonlight.confto one of these paths:/etc/moonlight.conf/usr/local/bin/moonlight.conf)~/.kodi/addons/script.luna/moonlight.conf).According to the docs, MLE only tries to read from the first one by default or from
$XDG_CONFIG_HOME/moonlight/moonlight.conf.So I think I need to change this to either pass the config path explicitly, or write the config file to
$XDG_CONFIG_HOME/moonlight/moonlight.confalways. What do you think?