INTERACT FORUM

Please login or register.

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

Author Topic: MCWS: Queries broken for quoted/encoded urls?  (Read 775 times)

DrKNo

  • World Citizen
  • ***
  • Posts: 201
MCWS: Queries broken for quoted/encoded urls?
« on: January 15, 2019, 08:15:03 am »

I'm currently writing a project including the JRiver MCWS API, a physical jukebox thingie that I'd like to share here once it's done. I ran into problems using the MCWS interface. I'm not quite sure whether that's due to my own incompetence, but I would be really happy if a dev could look into it quickly. I cannot get url-encoded queries to work

This here works:
http://192.168.178.99:52199/MCWS/v1/Files/Search?Action=play&Query=[Artist]=[Robyn]%20[Album]=[Honey]

This one doesn't:
http://192.168.178.99:52199/MCWS/v1/Files/Search?Action=Play&Query=%5BArtist%5D%3D%5BRobyn%5D+%5BAlbum%5D%3D%5BHoney%5D

additionally, the second example shows strange / apparently undetermined behavior in MC. If the "Now playing" list, of the target zone is empty, nothing happens. If it contains songs, random songs from that list start to play, without changes to the list itself. I believe that encoding URLs is the "correct" way to go, especially as fields like "artist" can include problematic symbols like an ampersand can pop up in queries.  I'm using a current JRiver 2014, I tested this on thoroughly MAC and less thoroughly on Windows. I'm happy to share the code privately in a pm, if necessary. It is a bit of a mess still =)
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 41958
  • Shoes gone again!
Re: MCWS: Queries broken for quoted/encoded urls?
« Reply #1 on: January 15, 2019, 08:27:20 am »

I think that search resolves to this, which doesn't make sense:
[Artist]=[Robyn]+[Album]=[Honey]

Maybe you wanted a space between [Robyn] and [Album]?
Logged
Matt Ashland, JRiver Media Center

DrKNo

  • World Citizen
  • ***
  • Posts: 201
Re: MCWS: Queries broken for quoted/encoded urls?
« Reply #2 on: January 15, 2019, 09:19:19 am »

Interesting... I used python libs to encode that from the upper query. I'll check and report, thank you for your time, Matt.
Logged

DrKNo

  • World Citizen
  • ***
  • Posts: 201
Re: MCWS: Queries broken for quoted/encoded urls?
« Reply #3 on: January 15, 2019, 01:17:28 pm »

So, you were right of course. Apparently, the urllib from python replaces the space between the brackets with a plus instead of a %20, while it while it treats the other spaces as expected. I believe I had the same problem with a Java lib a while ago, so that might be a cave for future hackers. Thanks for spotting the problem.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 41958
  • Shoes gone again!
Re: MCWS: Queries broken for quoted/encoded urls?
« Reply #4 on: January 15, 2019, 01:32:55 pm »

Glad you got it working :)
Logged
Matt Ashland, JRiver Media Center

DrKNo

  • World Citizen
  • ***
  • Posts: 201
Re: MCWS: Queries broken for quoted/encoded urls?
« Reply #5 on: January 18, 2019, 07:09:09 pm »

The problem stems from the unclear translation of spaces into either %20 or just + symbols. The standard is ambiguous, and strictly speaking, both are allowed in the query/parameter section of the URL. Pythons request library encodes spaces in paramters with +. JRiver expects %20 though. For a solution, see here:

https://stackoverflow.com/questions/21823965/use-20-instead-of-for-space-in-python-query-parameters

Logged
Pages: [1]   Go Up