INTERACT FORUM
Windows => Third Party Plug-ins, Programs, and Skins => Topic started by: PaulSinnema 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
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:
<?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.
-
Try escaping the # in [Track #] w/%23.
-
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:
string escapedUriString = Uri.EscapeUriString(url);
The url goes in like:
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:
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
-
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:
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:
/// <summary>
/// Return all the parameters as a string in format "?parameter1=value¶meter2=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