INTERACT FORUM

Please login or register.

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

Author Topic: MCWS Get File command for playing now file ?  (Read 3225 times)

eddyshere

  • Galactic Citizen
  • ****
  • Posts: 469
MCWS Get File command for playing now file ?
« on: May 28, 2016, 08:00:11 am »

I'm wondering if there is an MCWS command/parameter which I could use similar to : GetImage which gets an image for a file in the database But with which I could always return the image of an actual playing now file ? if in addition it could be done with zone selection it would be great.
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5242
  • "Linux Merit Badge" Recipient
Re: MCWS Get File command for playing now file ?
« Reply #1 on: May 28, 2016, 08:22:58 am »

So the way I handled this in my own scripting is to pull the playback info (which is available by zone) and parse it.  Embedded in the playback info is a link to the image file for the currently playing track, which you can then pull down.  Its takes some parsing, but I do it successfully in my conky plugin.  Here's the relevant code snippet (it's in bash so that may not be useful to you if you're not on Linux, but will give you the idea of an implementation):

Code: [Select]
#!/bin/bash
#Fetch the xml
wget -q localhost\:52199/MCWS/v1/Playback/Info\?Zone\=\-1 -O ~/.MCWS/Info     
#Lift out the image URL
URL=$(sed -n 's:.*<Item Name="ImageURL">\(.*\)</Item>.*:\1:p' ~/.MCWS/Info)
#Fetch the Image
wget localhost:52199/$URL -O ~/.MCWS/img.jpg

It's not beautiful or particularly robust, but it should point you in the right direction.
Logged

eddyshere

  • Galactic Citizen
  • ****
  • Posts: 469
Re: MCWS Get File command for playing now file ?
« Reply #2 on: May 28, 2016, 08:33:39 am »

Thanks a lot...I can take it from there I guess. I'm not a programming expert rather an advanced dummy autodidacted through hours of trial and error.

Actually I use a two way driver on my automation system which can send escaped strings in UDP or TCP to any IP server and display the answer back.

If I manage to get the XML I can already work with it and pick out the info I need. Your code snipplet surely helps me getting started !
Logged

eddyshere

  • Galactic Citizen
  • ****
  • Posts: 469
Re: MCWS Get File command for playing now file ?
« Reply #3 on: May 28, 2016, 03:21:29 pm »

OK so here I'm at my limits.Sorry if this is a dumb question but

I understand that MCWS is "running" on a REST server which i can adress through aweb browser or a cmd line.Thatworks without a problem. Now my automation system's two way driver is a telnet-kind of service. When I adress the server I receive the following message back :
HTTP/1.1 501 Server Error
Server:Windows, UPnP/1.1DLNADOC/1.50,Jriver21

Am I correct assuming that the server cannot be adressed directly in "raw" or telnet mode.

Or other way to ask, can I interact with the MCWS api or JRiver with a program aka putty ?

Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5242
  • "Linux Merit Badge" Recipient
Re: MCWS Get File command for playing now file ?
« Reply #4 on: May 28, 2016, 03:47:33 pm »

I'm close to the edge of my knowledge as well; MCWS is (as I understand it) a pure web protocol, it answers web queries; it doesn't contain a telnet or ssh server to my knowledge.  If there's a way to address it directly via telnet I don't know it, but maybe someone else here does.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: MCWS Get File command for playing now file ?
« Reply #5 on: May 28, 2016, 04:33:56 pm »

Am I correct assuming that the server cannot be adressed directly in "raw" or telnet mode.

Or other way to ask, can I interact with the MCWS api or JRiver with a program aka putty ?

MCWS is not an interactive service.  It doesn't have a menu.  It doesn't have a command line that accepts commands and responds.  It's a web service.

Perhaps you can use curl or wget or something with your automation system.

Brian.
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72549
  • Where did I put my teeth?
Re: MCWS Get File command for playing now file ?
« Reply #6 on: May 28, 2016, 05:48:40 pm »

On a machine which is running MC, try this in a browser:

http://localhost:52199/MCWS/v1/
Logged
Pages: [1]   Go Up