added IsIdRoot helper
This commit is contained in:
parent
85e3a90398
commit
402e80dac3
|
@ -241,7 +241,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
{
|
{
|
||||||
new KeyValuePair<string,string>("Result", resXML),
|
new KeyValuePair<string,string>("Result", resXML),
|
||||||
new KeyValuePair<string,string>("NumberReturned", provided.ToString(_usCulture)),
|
new KeyValuePair<string,string>("NumberReturned", provided.ToString(_usCulture)),
|
||||||
new KeyValuePair<string,string>("TotalMatches", id == "0" ? "1" :totalCount.ToString(_usCulture)),
|
new KeyValuePair<string,string>("TotalMatches", DidlBuilder.IsIdRoot(id) ? "1" :totalCount.ToString(_usCulture)),
|
||||||
new KeyValuePair<string,string>("UpdateID", _systemUpdateId.ToString(_usCulture))
|
new KeyValuePair<string,string>("UpdateID", _systemUpdateId.ToString(_usCulture))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -535,10 +535,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
|
|
||||||
private BaseItem GetItemFromObjectId(string id, User user)
|
private BaseItem GetItemFromObjectId(string id, User user)
|
||||||
{
|
{
|
||||||
return string.IsNullOrWhiteSpace(id) || string.Equals(id, "0", StringComparison.OrdinalIgnoreCase)
|
return DidlBuilder.IsIdRoot(id)
|
||||||
|
|
||||||
// Samsung sometimes uses 1 as root
|
|
||||||
|| string.Equals(id, "1", StringComparison.OrdinalIgnoreCase)
|
|
||||||
|
|
||||||
? user.RootFolder
|
? user.RootFolder
|
||||||
: ParseItemId(id, user);
|
: ParseItemId(id, user);
|
||||||
|
|
|
@ -362,12 +362,35 @@ namespace MediaBrowser.Dlna.Didl
|
||||||
container.AppendChild(res);
|
container.AppendChild(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsIdRoot(string id)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(id) ||
|
||||||
|
|
||||||
|
string.Equals(id, "0", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|
||||||
|
// Samsung sometimes uses 1 as root
|
||||||
|
|| string.Equals(id, "1", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public XmlElement GetFolderElement(XmlDocument doc, Folder folder, int childCount, Filter filter, string requestedId = null)
|
public XmlElement GetFolderElement(XmlDocument doc, Folder folder, int childCount, Filter filter, string requestedId = null)
|
||||||
{
|
{
|
||||||
var container = doc.CreateElement(string.Empty, "container", NS_DIDL);
|
var container = doc.CreateElement(string.Empty, "container", NS_DIDL);
|
||||||
container.SetAttribute("restricted", "0");
|
container.SetAttribute("restricted", "0");
|
||||||
container.SetAttribute("searchable", "1");
|
container.SetAttribute("searchable", "1");
|
||||||
container.SetAttribute("childCount", childCount.ToString(_usCulture));
|
container.SetAttribute("childCount", childCount.ToString(_usCulture));
|
||||||
|
|
||||||
|
if (string.Equals(requestedId, "0"))
|
||||||
|
{
|
||||||
|
container.SetAttribute("id", "0");
|
||||||
|
container.SetAttribute("parentID", "-1");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
container.SetAttribute("id", folder.Id.ToString("N"));
|
container.SetAttribute("id", folder.Id.ToString("N"));
|
||||||
|
|
||||||
var parent = folder.Parent;
|
var parent = folder.Parent;
|
||||||
|
@ -379,11 +402,6 @@ namespace MediaBrowser.Dlna.Didl
|
||||||
{
|
{
|
||||||
container.SetAttribute("parentID", parent.Id.ToString("N"));
|
container.SetAttribute("parentID", parent.Id.ToString("N"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requestedId == "0")
|
|
||||||
{
|
|
||||||
container.SetAttribute("id","0");
|
|
||||||
container.SetAttribute("parentID", "-1");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AddCommonFields(folder, container, filter);
|
AddCommonFields(folder, container, filter);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user