INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Command line functions  (Read 4489 times)

TBoyInPuna

  • Recent member
  • *
  • Posts: 22
Command line functions
« 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?
Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13870
Re: Command line functions
« Reply #1 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/
Logged

TBoyInPuna

  • Recent member
  • *
  • Posts: 22
Re: Command line functions
« Reply #2 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.
Logged

TBoyInPuna

  • Recent member
  • *
  • Posts: 22
Re: Command line functions
« Reply #3 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!
Logged

zeltak

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 494
Re: Command line functions
« Reply #4 on: November 01, 2018, 11:43:31 pm »

cool

can you share the python script?

best

Z
Logged

laba

  • Recent member
  • *
  • Posts: 9
Re: Command line functions
« Reply #5 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.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42372
  • Shoes gone again!
Re: Command line functions
« Reply #6 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
Logged
Matt Ashland, JRiver Media Center

laba

  • Recent member
  • *
  • Posts: 9
Re: Command line functions
« Reply #7 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.
Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13870
Re: Command line functions
« Reply #8 on: December 09, 2019, 11:54:27 am »

Cool, thanks for sharing!
Logged

docles

  • Recent member
  • *
  • Posts: 39
Re: Command line functions
« Reply #9 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.
Logged
Pages: [1]   Go Up