INTERACT FORUM

Please login or register.

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

Author Topic: Webservice does not sort output (or is it me?)  (Read 2032 times)

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Webservice does not sort output (or is it me?)
« on: April 23, 2012, 10:52:41 am »

Hi,

I found the ~sort syntax here: http://wiki.jriver.com/index.php/Smartlist_and_Search_-_Rules_and_Modifiers. I've tried it but it does not seem to sort anything. Am I making a mistake? Here's an example of what I'm sending MC

Code: [Select]
http://192.168.56.1:52199/MCWS/v1/Files/Search?Query=%5BArtist%5D=%22Supertramp%22%20%5BAlbum%5D=%22Crime%20of%20the%20Century%22%20~sort=%5BTrack%20#%5D&Zone=0&ZoneType=ID
And this is what I get as a response:

Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<MPL Version="2.0" Title="MCWS - Files - 11556">
<Item>
<Field Name="Key">4177</Field>
<Field Name="Filename">D:\MP3\Supertramp\Crime of the Century\Supertramp - Asylum.mp3</Field>
<Field Name="Name">Asylum</Field>
<Field Name="Artist">Supertramp</Field>
<Field Name="Album">Crime of the Century</Field>
<Field Name="Genre">Rock</Field>
<Field Name="Date">27030</Field>
<Field Name="Bitrate">192</Field>
<Field Name="Image File">INTERNAL</Field>
<Field Name="Rating">5</Field>
<Field Name="Duration">402,0240000000000009</Field>
<Field Name="Track #">4</Field>
...
</Item>
<Item>
<Field Name="Key">4179</Field>
<Field Name="Filename">D:\MP3\Supertramp\Crime of the Century\Supertramp - Bloody Well Right.mp3</Field>
<Field Name="Name">Bloody Well Right</Field>
<Field Name="Artist">Supertramp</Field>
<Field Name="Album">Crime of the Century</Field>
<Field Name="Genre">Rock</Field>
<Field Name="Date">27030</Field>
<Field Name="Bitrate">192</Field>
<Field Name="Image File">INTERNAL</Field>
<Field Name="Rating">5</Field>
<Field Name="Duration">271,9080000000000154</Field>
<Field Name="Track #">2</Field>
...
</Item>
<Item>
<Field Name="Key">4180</Field>
<Field Name="Filename">D:\MP3\Supertramp\Crime of the Century\Supertramp - Crime Of The Century.jpg</Field>
<Field Name="Name">Crime Of The Century</Field>
<Field Name="Artist">Supertramp</Field>
<Field Name="Album">Crime of the Century</Field>
<Field Name="Comment">Van Dani</Field>
<Field Name="Date">38428</Field>
<Field Name="Rating">5</Field>
<Field Name="Track #">0</Field>
...
</Item>

...

</MPL>

Is it a bug or is it me?

Regards
Paul

PS: I am aware that Matt is working on a problem that involves escaping. Maybe that introduces this problem too.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Webservice does not sort output (or is it me?)
« Reply #1 on: April 23, 2012, 02:31:56 pm »

Try escaping the # in [Track #] w/%23.
Logged
The opinions I express represent my own folly.

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: Webservice does not sort output (or is it me?)
« Reply #2 on: April 24, 2012, 01:49:53 am »

Hi MrC,

Just tried that (manually) and yes now the sort works. Now I have a real problem on my hands. The escaping is done with a routine from the Phone Framework like so:

Code: [Select]
string escapedUriString = Uri.EscapeUriString(url);
The url goes in like:

Code: [Select]
http://192.168.1.114:52199/MCWS/v1/Files/Search?Action=Play&Query=[Artist]="Supertramp" [Album]="Crime of the Century" ~sort=[Track #]&Zone=0&ZoneType=ID
and comes out like:

Code: [Select]
http://192.168.1.114:52199/MCWS/v1/Files/Search?Action=Play&Query=%5BArtist%5D=%22Supertramp%22%20%5BAlbum%5D=%22Crime%20of%20the%20Century%22%20~sort=%5BTrack%20#%5D&Zone=0&ZoneType=ID
I don't think I have any influence on how that routine escapes the string.

Regards
Paul
Logged

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: Webservice does not sort output (or is it me?)
« Reply #3 on: April 24, 2012, 02:06:54 am »

Hi MrC,

I think I've solved it. Instead of escaping the whole querystring at once I've now implemented escaping of only the parts in the query string. The url now comes out like this:

Code: [Select]
http://192.168.75.1:52199/MCWS/v1/Files/Search?Action%3DPlay&Query%3D%5BArtist%5D%3D%22Supertramp%22%20%5BAlbum%5D%3D%22Crime%20of%20the%20Century%22%20~sort%3D%5BTrack%20%23%5D&Zone=0&ZoneType=ID
I've altered the ToString() of my MCParameters (Dictionary) class like so:

Code: [Select]
/// <summary>
/// Return all the parameters as a string in format "?parameter1=value&parameter2=value&etc..."
/// </summary>
/// <returns></returns>
public override string ToString()
{
StringBuilder result = new StringBuilder();
string separator = "?";

foreach (KeyValuePair<string, object> parameter in this)
{
string parameterPart = Uri.EscapeDataString(parameter.Key + "=" + parameter.Value);
// result.Append(separator).Append(parameter.Key).Append("=").Append(parameter.Value);
result.Append(separator).Append(parameterPart);
separator = "&";
}

if (MCStatic.CurrentZone != null)
{
result.Append(separator).Append("Zone=").Append(MCStatic.CurrentZone.Id).Append("&").Append("ZoneType=ID");
}

return result.ToString();
}

The sort works fine now. Thanks again.

Regards
Paul
Logged
Pages: [1]   Go Up