Fix to return proper BrowseMetaData for Root-folder

(Fixes DLNA for  PS3)
pull/702/head
Fredrik Zetterlund 10 years ago
parent 66ad1699e2
commit d0ac58768f

@ -190,6 +190,8 @@ namespace MediaBrowser.Dlna.ContentDirectory
if (string.Equals(flag, "BrowseMetadata")) if (string.Equals(flag, "BrowseMetadata"))
{ {
var folder = item as Folder; var folder = item as Folder;
if (folder == null) if (folder == null)
@ -198,10 +200,12 @@ namespace MediaBrowser.Dlna.ContentDirectory
} }
else else
{ {
var childrenResult = (await GetChildrenSorted(folder, user, sortCriteria, start, requested).ConfigureAwait(false)); var childrenResult = (await GetChildrenSorted(folder, user, sortCriteria, start, requested).ConfigureAwait(false));
totalCount = childrenResult.TotalRecordCount; totalCount = childrenResult.TotalRecordCount;
result.DocumentElement.AppendChild(_didlBuilder.GetFolderElement(result, folder, totalCount, filter)); result.DocumentElement.AppendChild(_didlBuilder.GetFolderElement(result, folder, totalCount, filter, id));
} }
provided++; provided++;
} }
@ -237,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", totalCount.ToString(_usCulture)), new KeyValuePair<string,string>("TotalMatches", id == "0" ? "1" :totalCount.ToString(_usCulture)),
new KeyValuePair<string,string>("UpdateID", _systemUpdateId.ToString(_usCulture)) new KeyValuePair<string,string>("UpdateID", _systemUpdateId.ToString(_usCulture))
}; };
} }

@ -362,7 +362,7 @@ namespace MediaBrowser.Dlna.Didl
container.AppendChild(res); container.AppendChild(res);
} }
public XmlElement GetFolderElement(XmlDocument doc, Folder folder, int childCount, Filter filter) 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");
@ -380,6 +380,12 @@ 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);
AddCover(folder, container); AddCover(folder, container);

Loading…
Cancel
Save