INTERACT FORUM

More => Old Versions => JRiver Media Center 24 for Linux => Topic started by: TBoyInPuna on October 23, 2018, 09:02:57 pm

Title: Command line functions
Post by: TBoyInPuna on October 23, 2018, 09:02:57 pm
In Windows there is support to use the CLI to play next,  play previous, pause, etc.
Is there equivalent function for the Linux version?
Title: Re: Command line functions
Post by: bob on October 29, 2018, 10:50:43 am
In Windows there is support to use the CLI to play next,  play previous, pause, etc.
Is there equivalent function for the Linux version?
Not directly since there is no Stub version of MC for linux but you can do simple curl command line's to localhost on port 52199 using MCWS to do the same.
Self-documented here:
http://localhost:52199/MCWS/v1/
Title: Re: Command line functions
Post by: TBoyInPuna on November 01, 2018, 03:01:21 pm
Thank you very much!  I have switched from W10 to Ubuntu, and I was really missing this functionality, which I invoke via hotkeys.  I'll work on adapting to this method.
Title: Re: Command line functions
Post by: TBoyInPuna on November 01, 2018, 07:39:46 pm
This worked great.

I wrote a little Python program to invoke the proper URL.  I can invoke it from an application shortcut (hotkey) in XFCE and it all works exactly as I want.

Thanks again!
Title: Re: Command line functions
Post by: zeltak on November 01, 2018, 11:43:31 pm
cool

can you share the python script?

best

Z
Title: Re: Command line functions
Post by: laba on December 09, 2019, 09:14:55 am
Is the list of functions at http://localhost:52199/MCWS/v1/ the only things that can be done with this method or is it possible to hack it to use any of the commands such as MCC_IMPORT_AUTO_RUN_NOW listed at https://wiki.jriver.com/index.php/Media_Center_Core_Commands#Tools ?

I would like to be able to quickly trigger auto-import as in the attached gif. Is there a way to do that with a command?

Thank you.
Title: Re: Command line functions
Post by: Matt on December 09, 2019, 09:32:59 am
Is the list of functions at http://localhost:52199/MCWS/v1/ the only things that can be done with this method or is it possible to hack it to use any of the commands such as MCC_IMPORT_AUTO_RUN_NOW listed at https://wiki.jriver.com/index.php/Media_Center_Core_Commands#Tools ?

I would like to be able to quickly trigger auto-import as in the attached gif. Is there a way to do that with a command?

Thank you.

If it helps, you can start auto-import with this:
http://localhost:52199/MCWS/v1/Control/MCC?Command=23020
Title: Re: Command line functions
Post by: laba on December 09, 2019, 11:51:14 am
If it helps, you can start auto-import with this:
http://localhost:52199/MCWS/v1/Control/MCC?Command=23020

That helps! Brilliant, thank you. That also tells me that the other MCC commands can be used in the same way, in case I find those useful.

For anyone interested, I used the above URL to make a one-click process to run the auto-import. This can be done with any of the other functions too, I assume.

I created a new bash script and saved it in ~/.local/bin with the name jmc-import

That script contains the following code:

Code: [Select]
#!/bin/bash

# determine if JRiver Media Center 24 process is running and if so, run auto-import:

if pgrep -x mediacenter24 >/dev/null

then
  echo
  echo "***** JRiver Media Center is running *****"

# trigger JRiver Media Center auto-import and supress output by using the -s flag and sending to /dev/null

  curl -s http://localhost:52199/MCWS/v1/Control/MCC?Command=23020 > /dev/null
  echo
  echo '***** JRiver Media Center auto-import triggered *****'
  echo

else
  echo
  echo "***** JRiver Media Center is not running *****"
  echo

# pop-up error message:

  notify-send --expire-time=3000 'JRiver Media Center' 'IS NOT RUNNING'

fi

Some of that code is to make it prettier if the script is run in the command line. The pop-up notification is to notify if MC24 isn't running as the auto import won't work if so.


I then created a new desktop file jmc-import.desktop in ~/.local/share/applications and inserted the following:

Code: [Select]
#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Name=jmc-import
Exec=/home/<user>/.local/bin/jmc-import
Icon=/path/to/preferred/icon/import.png
Name[en_GB]=jmc-import

That puts a clickable desktop shortcut to trigger the script into the applications menu, which I then added to my taskbar favourites next to the MC24 icon so I can trigger the auto-import with a single mouse click.
Title: Re: Command line functions
Post by: bob on December 09, 2019, 11:54:27 am
Cool, thanks for sharing!
Title: Re: Command line functions
Post by: docles on August 06, 2022, 01:16:54 pm
I try to make it work on a MC28 located on a VPS under ubuntu.

when connected graphically (X-windows) to the VPS, I can launch the Import

Within a command line or a bash, doesn't work.

Any ideas to help ?

Thanks

docles

That helps! Brilliant, thank you. That also tells me that the other MCC commands can be used in the same way, in case I find those useful.

For anyone interested, I used the above URL to make a one-click process to run the auto-import. This can be done with any of the other functions too, I assume.

I created a new bash script and saved it in ~/.local/bin with the name jmc-import

That script contains the following code:

Code: [Select]
#!/bin/bash

# determine if JRiver Media Center 24 process is running and if so, run auto-import:

if pgrep -x mediacenter24 >/dev/null

then
  echo
  echo "***** JRiver Media Center is running *****"

# trigger JRiver Media Center auto-import and supress output by using the -s flag and sending to /dev/null

  curl -s http://localhost:52199/MCWS/v1/Control/MCC?Command=23020 > /dev/null
  echo
  echo '***** JRiver Media Center auto-import triggered *****'
  echo

else
  echo
  echo "***** JRiver Media Center is not running *****"
  echo

# pop-up error message:

  notify-send --expire-time=3000 'JRiver Media Center' 'IS NOT RUNNING'

fi

Some of that code is to make it prettier if the script is run in the command line. The pop-up notification is to notify if MC24 isn't running as the auto import won't work if so.


I then created a new desktop file jmc-import.desktop in ~/.local/share/applications and inserted the following:

Code: [Select]
#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Name=jmc-import
Exec=/home/<user>/.local/bin/jmc-import
Icon=/path/to/preferred/icon/import.png
Name[en_GB]=jmc-import

That puts a clickable desktop shortcut to trigger the script into the applications menu, which I then added to my taskbar favourites next to the MC24 icon so I can trigger the auto-import with a single mouse click.