Moin DigiHouse,
ich bin jetzt dabei die Scripte zusammenzubringen und zu vervollständigen.
Dabei habe ich noch eine Frage, wie muss sich $MetaData zusammenstellen?
Nebenbei sind mir noch ein paar Sachen aufgefallen,
die sich je nach bekommenden Daten etwas anders verhalten.
Edit:das bisherige Script zum testen hinzugefügt.
MFG MNB
<?
$nxml = '<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:BrowseResponse xmlns:m="urn:schemas-upnp-org:service:ContentDirectory:1">
<Result xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string"><DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"
xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
xmlns:microsoft="urn:schemas-microsoft-com:WMPNSS-1-0/"
xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"
><item id="6_eff1f3a5_7c0784c9-569" refID="4-569" restricted="1" parentID="6_eff1f3a5_7c0784c9"><dc:title>Mr. Saxobeat</dc:title><dc:creator>Alexandra Stan</dc:creator><res size="3122982" duration="0:03:11.608" bitrate="16000" protocolInfo="http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000" sampleFrequency="44100" bitsPerSample="16" nrAudioChannels="2" microsoft:codec="{00000055-0000-0010-8000-00AA00389B71}">http://127.0.0.1:10243/WMPNSSv4/3561040673/1_Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.mp3</res><res duration="0:03:11.608" bitrate="176400" protocolInfo="http-get:*:audio/L16;rate=44100;channels=2:DLNA.ORG_PN=LPCM;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01700000000000000000000000000000" sampleFrequency="44100" bitsPerSample="16" nrAudioChannels="2" microsoft:codec="{00000001-0000-0010-8000-00AA00389B71}">http://127.0.0.1:10243/WMPNSSv4/3561040673/Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.mp3?formatID=39</res><res duration="0:03:11.608" bitrate="88200" protocolInfo="http-get:*:audio/L16;rate=44100;channels=1:DLNA.ORG_PN=LPCM;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01700000000000000000000000000000" sampleFrequency="44100" bitsPerSample="16" nrAudioChannels="1" microsoft:codec="{00000001-0000-0010-8000-00AA00389B71}">http://127.0.0.1:10243/WMPNSSv4/3561040673/Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.mp3?formatID=37</res><res duration="0:03:11.608" bitrate="24000" protocolInfo="http-get:*:audio/mp4:DLNA.ORG_PN=AAC_ISO_320;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01700000000000000000000000000000" sampleFrequency="48000" nrAudioChannels="2" microsoft:codec="{00001610-0000-0010-8000-00AA00389B71}">http://127.0.0.1:10243/WMPNSSv4/3561040673/Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.m4a?formatID=25</res><res duration="0:03:11.608" bitrate="32000" protocolInfo="http-get:*:audio/vnd.dolby.dd-raw:DLNA.ORG_PN=AC3;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01700000000000000000000000000000" sampleFrequency="48000" nrAudioChannels="2" microsoft:codec="{E06D802C-DB46-11CF-B4D1-00805F6CBBEA}">http://127.0.0.1:10243/WMPNSSv4/3561040673/Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.mp3?formatID=28</res><res duration="0:03:11.608" bitrate="24000" protocolInfo="http-get:*:audio/vnd.dlna.adts:DLNA.ORG_PN=AAC_ADTS_320;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01700000000000000000000000000000" sampleFrequency="48000" nrAudioChannels="2" microsoft:codec="{00001610-0000-0010-8000-00AA00389B71}">http://127.0.0.1:10243/WMPNSSv4/3561040673/Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.adts?formatID=30</res><res duration="0:03:11.608" bitrate="8000" protocolInfo="http-get:*:audio/x-ms-wma:DLNA.ORG_PN=WMABASE;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01700000000000000000000000000000" sampleFrequency="44100" nrAudioChannels="2" microsoft:codec="{00000161-0000-0010-8000-00AA00389B71}">http://127.0.0.1:10243/WMPNSSv4/3561040673/Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.wma?formatID=118</res><upnp:class>object.item.audioItem.musicTrack</upnp:class><upnp:genre>Dance</upnp:genre><dc:publisher>RMNradio</dc:publisher><upnp:artist role="AlbumArtist">Alexandra Stan</upnp:artist><upnp:artist role="Performer">Alexandra Stan</upnp:artist><upnp:author role="Composer">[Unbekannter Komponist]</upnp:author><upnp:album>Saxobeats</upnp:album><upnp:originalTrackNumber>0</upnp:originalTrackNumber><dc:date>2011-01-02</dc:date><upnp:actor role="Alexandra Stan">Alexandra Stan</upnp:actor><dc:description>www.radio-fx.de</dc:description><upnp:albumArtURI dlna:profileID="JPEG_SM">http://127.0.0.1:10243/WMPNSSv4/3561040673/0_Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.jpg?albumArt=true</upnp:albumArtURI><upnp:albumArtURI dlna:profileID="JPEG_TN">http://127.0.0.1:10243/WMPNSSv4/3561040673/Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.jpg?albumArt=true,formatID=32,width=160,height=160</upnp:albumArtURI><desc id="artist" nameSpace="urn:schemas-microsoft-com:WMPNSS-1-0/" xmlns:microsoft="urn:schemas-microsoft-com:WMPNSS-1-0/"><microsoft:artistAlbumArtist>Alexandra Stan</microsoft:artistAlbumArtist><microsoft:artistPerformer>Alexandra Stan</microsoft:artistPerformer></desc><desc id="author" nameSpace="urn:schemas-microsoft-com:WMPNSS-1-0/" xmlns:microsoft="urn:schemas-microsoft-com:WMPNSS-1-0/"><microsoft:authorComposer>[Unbekannter Komponist]</microsoft:authorComposer></desc><desc id="Year" nameSpace="urn:schemas-microsoft-com:WMPNSS-1-0/" xmlns:microsoft="urn:schemas-microsoft-com:WMPNSS-1-0/"><microsoft:year>2011</microsoft:year></desc><desc id="folderPath" nameSpace="urn:schemas-microsoft-com:WMPNSS-1-0/" xmlns:microsoft="urn:schemas-microsoft-com:WMPNSS-1-0/"><microsoft:folderPath>Freigegebene Musik\MP3´s - 05 fertig</microsoft:folderPath></desc><desc id="fileInfo" nameSpace="urn:schemas-microsoft-com:WMPNSS-1-0/" xmlns:microsoft="urn:schemas-microsoft-com:WMPNSS-1-0/"><microsoft:fileIdentifier>AMGa_id=R 2287667;AMGp_id=P 2354320;AMGt_id=T 24415507</microsoft:fileIdentifier></desc></item>
</DIDL-Lite></Result>
<NumberReturned xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="ui4">1</NumberReturned>
<TotalMatches xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="ui4">1</TotalMatches>
<UpdateID xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="ui4">9</UpdateID>
</m:BrowseResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>';
$nxml = '<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:BrowseResponse xmlns:m="urn:schemas-upnp-org:service:ContentDirectory:1">
<Result xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string"><DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"
xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
xmlns:microsoft="urn:schemas-microsoft-com:WMPNSS-1-0/"
xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"
><item id="6_eff1f3a5_7c0784c9-569" refID="4-569" restricted="1" parentID="6_eff1f3a5_7c0784c9"><dc:title>Mr. Saxobeat</dc:title><dc:creator>Alexandra Stan</dc:creator><res size="3122982" duration="0:03:11.608" bitrate="16000" protocolInfo="http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000" sampleFrequency="44100" bitsPerSample="16" nrAudioChannels="2" microsoft:codec="{00000055-0000-0010-8000-00AA00389B71}">http://127.0.0.1:10243/WMPNSSv4/3561040673/1_Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.mp3</res><res duration="0:03:11.608" bitrate="176400" protocolInfo="http-get:*:audio/L16;rate=44100;channels=2:DLNA.ORG_PN=LPCM;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01700000000000000000000000000000" sampleFrequency="44100" bitsPerSample="16" nrAudioChannels="2" microsoft:codec="{00000001-0000-0010-8000-00AA00389B71}">http://127.0.0.1:10243/WMPNSSv4/3561040673/Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.mp3?formatID=39</res><res duration="0:03:11.608" bitrate="88200" protocolInfo="http-get:*:audio/L16;rate=44100;channels=1:DLNA.ORG_PN=LPCM;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01700000000000000000000000000000" sampleFrequency="44100" bitsPerSample="16" nrAudioChannels="1" microsoft:codec="{00000001-0000-0010-8000-00AA00389B71}">http://127.0.0.1:10243/WMPNSSv4/3561040673/Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.mp3?formatID=37</res><res duration="0:03:11.608" bitrate="24000" protocolInfo="http-get:*:audio/mp4:DLNA.ORG_PN=AAC_ISO_320;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01700000000000000000000000000000" sampleFrequency="48000" nrAudioChannels="2" microsoft:codec="{00001610-0000-0010-8000-00AA00389B71}">http://127.0.0.1:10243/WMPNSSv4/3561040673/Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.m4a?formatID=25</res><res duration="0:03:11.608" bitrate="32000" protocolInfo="http-get:*:audio/vnd.dolby.dd-raw:DLNA.ORG_PN=AC3;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01700000000000000000000000000000" sampleFrequency="48000" nrAudioChannels="2" microsoft:codec="{E06D802C-DB46-11CF-B4D1-00805F6CBBEA}">http://127.0.0.1:10243/WMPNSSv4/3561040673/Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.mp3?formatID=28</res><res duration="0:03:11.608" bitrate="24000" protocolInfo="http-get:*:audio/vnd.dlna.adts:DLNA.ORG_PN=AAC_ADTS_320;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01700000000000000000000000000000" sampleFrequency="48000" nrAudioChannels="2" microsoft:codec="{00001610-0000-0010-8000-00AA00389B71}">http://127.0.0.1:10243/WMPNSSv4/3561040673/Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.adts?formatID=30</res><res duration="0:03:11.608" bitrate="8000" protocolInfo="http-get:*:audio/x-ms-wma:DLNA.ORG_PN=WMABASE;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01700000000000000000000000000000" sampleFrequency="44100" nrAudioChannels="2" microsoft:codec="{00000161-0000-0010-8000-00AA00389B71}">http://127.0.0.1:10243/WMPNSSv4/3561040673/Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.wma?formatID=118</res><upnp:class>object.item.audioItem.musicTrack</upnp:class><upnp:genre>Dance</upnp:genre><dc:publisher>RMNradio</dc:publisher><upnp:artist role="AlbumArtist">Alexandra Stan</upnp:artist><upnp:artist role="Performer">Alexandra Stan</upnp:artist><upnp:author role="Composer">[Unbekannter Komponist]</upnp:author><upnp:album>Saxobeats</upnp:album><upnp:originalTrackNumber>0</upnp:originalTrackNumber><dc:date>2011-01-02</dc:date><upnp:actor role="Alexandra Stan">Alexandra Stan</upnp:actor><dc:description>www.radio-fx.de</dc:description><upnp:albumArtURI dlna:profileID="JPEG_SM">http://127.0.0.1:10243/WMPNSSv4/3561040673/0_Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.jpg?albumArt=true</upnp:albumArtURI><upnp:albumArtURI dlna:profileID="JPEG_TN">http://127.0.0.1:10243/WMPNSSv4/3561040673/Nl9lZmYxZjNhNV83YzA3ODRjOS01Njk.jpg?albumArt=true,formatID=32,width=160,height=160</upnp:albumArtURI><desc id="artist" nameSpace="urn:schemas-microsoft-com:WMPNSS-1-0/" xmlns:microsoft="urn:schemas-microsoft-com:WMPNSS-1-0/"><microsoft:artistAlbumArtist>Alexandra Stan</microsoft:artistAlbumArtist><microsoft:artistPerformer>Alexandra Stan</microsoft:artistPerformer></desc><desc id="author" nameSpace="urn:schemas-microsoft-com:WMPNSS-1-0/" xmlns:microsoft="urn:schemas-microsoft-com:WMPNSS-1-0/"><microsoft:authorComposer>[Unbekannter Komponist]</microsoft:authorComposer></desc><desc id="Year" nameSpace="urn:schemas-microsoft-com:WMPNSS-1-0/" xmlns:microsoft="urn:schemas-microsoft-com:WMPNSS-1-0/"><microsoft:year>2011</microsoft:year></desc><desc id="folderPath" nameSpace="urn:schemas-microsoft-com:WMPNSS-1-0/" xmlns:microsoft="urn:schemas-microsoft-com:WMPNSS-1-0/"><microsoft:folderPath>Freigegebene Musik\MP3´s - 05 fertig</microsoft:folderPath></desc><desc id="fileInfo" nameSpace="urn:schemas-microsoft-com:WMPNSS-1-0/" xmlns:microsoft="urn:schemas-microsoft-com:WMPNSS-1-0/"><microsoft:fileIdentifier>AMGa_id=R 2287667;AMGp_id=P 2354320;AMGt_id=T 24415507</microsoft:fileIdentifier></desc></item>
</DIDL-Lite></Result>
<NumberReturned xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="ui4">1</NumberReturned>
<TotalMatches xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="ui4">1</TotalMatches>
<UpdateID xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="ui4">9</UpdateID>
</m:BrowseResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>';
$nxml = '<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:BrowseResponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
<Result><DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"><container id="0$1" childCount="1" parentID="0" restricted="true"><dc:title>Recently Played</dc:title><upnp:albumArtURI xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" dlna:profileID="PNG_TN">http://192.168.1.84:5001/get/0$1/thumbnail0000Recently+Played</upnp:albumArtURI><upnp:class>object.container.storageFolder</upnp:class></container><container id="0$2" childCount="1" parentID="0" restricted="true"><dc:title>New Media</dc:title><upnp:albumArtURI xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" dlna:profileID="PNG_TN">http://192.168.1.84:5001/get/0$2/thumbnail0000New+Media</upnp:albumArtURI><upnp:class>object.container.storageFolder</upnp:class></container><container id="0$3" childCount="37" parentID="0" restricted="true"><dc:title>!(0TV) Various</dc:title><upnp:albumArtURI xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" dlna:profileID="JPEG_TN">http://192.168.1.84:5001/get/0$3/thumbnail0000%21%280TV%29+Various</upnp:albumArtURI><dc:date>2014-02-14T10:43:31</dc:date><upnp:class>object.container.storageFolder</upnp:class></container><container id="0$4" childCount="1" parentID="0" restricted="true"><dc:title>!(0) Movies</dc:title><upnp:albumArtURI xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" dlna:profileID="JPEG_TN">http://192.168.1.84:5001/get/0$4/thumbnail0000%21%280%29+Movies</upnp:albumArtURI><dc:date>2014-02-10T08:57:37</dc:date><upnp:class>object.container.storageFolder</upnp:class></container><container id="0$5" childCount="13" parentID="0" restricted="true"><dc:title>DLNAtest</dc:title><upnp:albumArtURI xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" dlna:profileID="JPEG_TN">http://192.168.1.84:5001/get/0$5/thumbnail0000DLNAtest</upnp:albumArtURI><dc:date>2014-01-31T07:54:33</dc:date><upnp:class>object.container.storageFolder</upnp:class></container><container id="0$6" childCount="7" parentID="0" restricted="true"><dc:title>Web</dc:title><upnp:albumArtURI xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" dlna:profileID="JPEG_TN">http://192.168.1.84:5001/get/0$6/thumbnail0000Web</upnp:albumArtURI><upnp:class>object.container.storageFolder</upnp:class></container><container id="0$7" childCount="3" parentID="0" restricted="true"><dc:title>#- Cache -#</dc:title><upnp:albumArtURI xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" dlna:profileID="JPEG_TN">http://192.168.1.84:5001/get/0$7/thumbnail0000%23-+Cache+-%23</upnp:albumArtURI><upnp:class>object.container.storageFolder</upnp:class></container></DIDL-Lite></Result>
<NumberReturned>7</NumberReturned>
<TotalMatches>7</TotalMatches>
<UpdateID>1</UpdateID>
</u:BrowseResponse>
</s:Body>
</s:Envelope>';
$xml = '
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:BrowseResponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
<Result>
<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/">
<container id="co960" parentID="co857" restricted="0" searchable="1">
<dc:title>ATB Sunset Beach DJ Session</dc:title>
<dc:creator>Unknown</dc:creator>
<upnp:artist></upnp:artist>
<upnp:genre>Unknown</upnp:genre>
<upnp:class>object.container.storageFolder</upnp:class>
</container>
<container id="co961" parentID="co857" restricted="0" searchable="1">
<dc:title>Future Memories</dc:title>
<dc:creator>Unknown</dc:creator>
<upnp:artist></upnp:artist>
<upnp:genre>Unknown</upnp:genre>
<upnp:class>object.container.storageFolder</upnp:class>
</container>
<item id="d8844-co857" parentID="co857" restricted="0">
<dc:title>01 - Could You Believe (Airplay Mix)</dc:title>
<dc:creator>ATB</dc:creator>
<dc:date>2010-01-01</dc:date>
<upnp:artist role="AlbumArtist">ATB</upnp:artist>
<upnp:artist role="Composer">Jennifer Karr</upnp:artist>
<upnp:artist role="Performer">ATB</upnp:artist>
<upnp:album>ATB Sunset Beach DJ Session</upnp:album>
<upnp:genre>Dance & DJ</upnp:genre>
<upnp:albumArtURI dlna:profileID="JPEG_TN">http://192.168.178.64:26125/aa/221781/740880359/cover.jpg?size=0</upnp:albumArtURI>
<upnp:originalTrackNumber>1</upnp:originalTrackNumber>
<upnp:originalDiscNumber>1</upnp:originalDiscNumber>
<upnp:originalDiscCount>1</upnp:originalDiscCount>
<res duration="0:03:29.000" size="7360435" bitrate="35101" bitsPerSample="16" sampleFrequency="44100" nrAudioChannels="2" protocolInfo="http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01">http://192.168.178.64:26125/content/c2/b16/f44100/d8844-co857.mp3</res>
<upnp:class>object.item.audioItem.musicTrack</upnp:class>
</item>
<item id="d8846-co857" parentID="co857" restricted="0">
<dc:title>01 - L.A. Nights</dc:title>
<dc:creator>ATB</dc:creator>
<dc:date>2009-01-01</dc:date>
<upnp:artist role="AlbumArtist">ATB</upnp:artist>
<upnp:artist role="Composer">André Tanneberger</upnp:artist>
<upnp:artist role="Performer">ATB</upnp:artist>
<upnp:album>Future Memories</upnp:album>
<upnp:genre>Dance & DJ</upnp:genre>
<upnp:albumArtURI dlna:profileID="JPEG_TN">http://192.168.178.64:26125/aa/51525/2480797350/cover.jpg?size=0</upnp:albumArtURI>
<upnp:originalTrackNumber>1</upnp:originalTrackNumber>
<upnp:originalDiscNumber>1</upnp:originalDiscNumber>
<upnp:originalDiscCount>1</upnp:originalDiscCount>
<res duration="0:04:32.000" size="9074176" bitrate="33275" bitsPerSample="16" sampleFrequency="44100" nrAudioChannels="2" protocolInfo="http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01">http://192.168.178.64:26125/content/c2/b16/f44100/d8846-co857.mp3</res>
<res duration="0:04:32.000" size="48103792" bitrate="176400" bitsPerSample="16" sampleFrequency="44100" nrAudioChannels="2" protocolInfo="http-get:*:audio/wav:DLNA.ORG_PN=WAV;DLNA.ORG_OP=01">http://192.168.178.64:26125/content/c2/b16/f44100/d8846-co857.forced.wav</res>
<res duration="0:04:32.000" size="48103748" bitrate="176400" bitsPerSample="16" sampleFrequency="44100" nrAudioChannels="2" protocolInfo="http-get:*:audio/L16:DLNA.ORG_PN=LPCM;DLNA.ORG_OP=01;DLNA.ORG_CI=1">http://192.168.178.64:26125/content/c2/b16/f44100/d8846-co857.forced.l16</res>
<res duration="0:04:32.000" size="9074176" bitrate="33275" bitsPerSample="16" sampleFrequency="44100" nrAudioChannels="2" protocolInfo="http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01">http://192.168.178.64:26125/content/c2/b16/f44100/d8846-co857.mp3</res>
<upnp:class>object.item.audioItem.musicTrack</upnp:class>
</item>
<item id="d8845-co857" parentID="co857" restricted="0">
<dc:title>02 - Right Back (Original Mix)</dc:title>
<dc:creator>ATB</dc:creator><dc:date>2010-01-01</dc:date>
<upnp:artist role="AlbumArtist">ATB</upnp:artist>
<upnp:artist role="Composer">Yuri Kane</upnp:artist>
<upnp:artist role="Performer">Yuri Kane</upnp:artist>
<upnp:album>ATB Sunset Beach DJ Session</upnp:album>
<upnp:genre>Dance & DJ</upnp:genre>
<upnp:albumArtURI dlna:profileID="JPEG_TN">http://192.168.178.64:26125/aa/221781/740880359/cover.jpg?size=0</upnp:albumArtURI>
<upnp:originalTrackNumber>2</upnp:originalTrackNumber>
<upnp:originalDiscNumber>1</upnp:originalDiscNumber>
<upnp:originalDiscCount>1</upnp:originalDiscCount>
<res duration="0:05:56.000" size="11797385" bitrate="33070" bitsPerSample="16" sampleFrequency="44100" nrAudioChannels="2" protocolInfo="http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01">http://192.168.178.64:26125/content/c2/b16/f44100/d8845-co857.mp3</res>
<res duration="0:05:56.000" size="62927920" bitrate="176400" bitsPerSample="16" sampleFrequency="44100" nrAudioChannels="2" protocolInfo="http-get:*:audio/wav:DLNA.ORG_PN=WAV;DLNA.ORG_OP=01">http://192.168.178.64:26125/content/c2/b16/f44100/d8845-co857.forced.wav</res>
<res duration="0:05:56.000" size="62927876" bitrate="176400" bitsPerSample="16" sampleFrequency="44100" nrAudioChannels="2" protocolInfo="http-get:*:audio/L16:DLNA.ORG_PN=LPCM;DLNA.ORG_OP=01;DLNA.ORG_CI=1">http://192.168.178.64:26125/content/c2/b16/f44100/d8845-co857.forced.l16</res>
<res duration="0:05:56.000" size="11797385" bitrate="33070" bitsPerSample="16" sampleFrequency="44100" nrAudioChannels="2" protocolInfo="http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01">http://192.168.178.64:26125/content/c2/b16/f44100/d8845-co857.mp3</res>
<upnp:class>object.item.audioItem.musicTrack</upnp:class>
</item>
<item id="d8847-co857" parentID="co857" restricted="0">
<dc:title>02 - What About Us</dc:title><dc:creator>ATB</dc:creator><dc:date>2009-01-01</dc:date><upnp:artist role="AlbumArtist">ATB</upnp:artist><upnp:artist role="Composer">Rudi Dittmann</upnp:artist><upnp:artist role="Performer">ATB</upnp:artist><upnp:album>Future Memories</upnp:album><upnp:genre>Dance & DJ</upnp:genre><upnp:albumArtURI dlna:profileID="JPEG_TN">http://192.168.178.64:26125/aa/51525/2480797350/cover.jpg?size=0</upnp:albumArtURI><upnp:originalTrackNumber>2</upnp:originalTrackNumber><upnp:originalDiscNumber>1</upnp:originalDiscNumber><upnp:originalDiscCount>1</upnp:originalDiscCount><res duration="0:05:35.000" size="11756320" bitrate="35074" bitsPerSample="16" sampleFrequency="44100" nrAudioChannels="2" protocolInfo="http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01">http://192.168.178.64:26125/content/c2/b16/f44100/d8847-co857.mp3</res><res duration="0:05:35.000" size="59126676" bitrate="176400" bitsPerSample="16" sampleFrequency="44100" nrAudioChannels="2" protocolInfo="http-get:*:audio/wav:DLNA.ORG_PN=WAV;DLNA.ORG_OP=01">http://192.168.178.64:26125/content/c2/b16/f44100/d8847-co857.forced.wav</res><res duration="0:05:35.000" size="59126632" bitrate="176400" bitsPerSample="16" sampleFrequency="44100" nrAudioChannels="2" protocolInfo="http-get:*:audio/L16:DLNA.ORG_PN=LPCM;DLNA.ORG_OP=01;DLNA.ORG_CI=1">http://192.168.178.64:26125/content/c2/b16/f44100/d8847-co857.forced.l16</res><res duration="0:05:35.000" size="11756320" bitrate="35074" bitsPerSample="16" sampleFrequency="44100" nrAudioChannels="2" protocolInfo="http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01">http://192.168.178.64:26125/content/c2/b16/f44100/d8847-co857.mp3</res><upnp:class>object.item.audioItem.musicTrack</upnp:class></item>
</DIDL-Lite>
</Result>
<NumberReturned>7</NumberReturned>
<TotalMatches>7</TotalMatches>
<UpdateID>1</UpdateID>
</u:BrowseResponse>
</s:Body>
</s:Envelope>';
//DIDL umwandeln
$DIDL = (xml2array($xml));
//print_r($DIDL);
//Array $Liste erstellen
$liste = BrowseList($DIDL);
print_r($liste);
//Functions---------------------------------------------------------------------
function xml2array($contents, $get_attributes=1, $priority = 'tag') {
if(!$contents) return array();
if(!function_exists('xml_parser_create')) {
//print "'xml_parser_create()' function not found!";
return array();
}
$contents = str_replace(array("<", ">", """, "&", "%3a", "%2f", "%25"), array("<", ">", "\"", "&", ":", "/", "%"), $contents);
//Get the XML parser of PHP - PHP must have this module for the parser to work
$parser = xml_parser_create('');
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, trim($contents), $xml_values);
xml_parser_free($parser);
if(!$xml_values) return;//Hmm...
//Initializations
$xml_array = array();
$parents = array();
$opened_tags = array();
$arr = array();
$current = &$xml_array; //Refference
//Go through the tags.
$repeated_tag_index = array();//Multiple tags with same name will be turned into an array
foreach($xml_values as $data) {
unset($attributes,$value);//Remove existing values, or there will be trouble
//This command will extract these variables into the foreach scope
// tag(string), type(string), level(int), attributes(array).
extract($data);//We could use the array by itself, but this cooler.
$result = array();
$attributes_data = array();
if(isset($value)) {
if($priority == 'tag') $result = $value;
else $result['value'] = $value; //Put the value in a assoc array if we are in the 'Attribute' mode
}
//Set the attributes too.
if(isset($attributes) and $get_attributes) {
foreach($attributes as $attr => $val) {
if($priority == 'tag') $attributes_data[$attr] = $val;
else $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr'
}
}
//See tag status and do the needed.
if($type == "open") {//The starting of the tag '<tag>'
$parent[$level-1] = &$current;
if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag
$current[$tag] = $result;
if($attributes_data) $current[$tag. '_attr'] = $attributes_data;
$repeated_tag_index[$tag.'_'.$level] = 1;
$current = &$current[$tag];
} else { //There was another element with the same tag name
if(isset($current[$tag][0])) {//If there is a 0th element it is already an array
$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
} else {//This section will make the value an array if multiple tags with the same name appear together
$current[$tag] = array($current[$tag],$result);//This will combine the existing item and the new item together to make an array
if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well
$current[$tag]['0_attr'] = $current[$tag.'_attr'];
unset($current[$tag.'_attr']);
}
}
if($attributes_data) $current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
$repeated_tag_index[$tag.'_'.$level]++;
$last_item_index = $repeated_tag_index[$tag.'_'.$level]-1;
$current = &$current[$tag][$last_item_index];
}
} elseif($type == "complete") { //Tags that ends in 1 line '<tag/>'
// turn empty array to empty string
if (is_array($result) && empty($result)) {
$result = '';
}
//See if the key is already taken.
if(!isset($current[$tag])) { //New Key
$current[$tag] = $result;
$repeated_tag_index[$tag.'_'.$level] = 1;
if($priority == 'tag' and $attributes_data) $current[$tag. '_attr'] = $attributes_data;
} else { //If taken, put all things inside a list(array)
if(isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array...
// ...push the new element into that array.
$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
if($priority == 'tag' and $get_attributes and $attributes_data) {
$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
}
$repeated_tag_index[$tag.'_'.$level]++;
} else { //If it is not an array...
$current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value
$repeated_tag_index[$tag.'_'.$level] = 1;
if($priority == 'tag' and $get_attributes) {
if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well
$current[$tag]['0_attr'] = $current[$tag.'_attr'];
unset($current[$tag.'_attr']);
}
if($attributes_data) {
$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
}
}
$repeated_tag_index[$tag.'_'.$level]++; //0 and 1 index is already taken
}
}
} elseif($type == 'close') { //End of tag '</tag>'
$current = &$parent[$level-1];
}
}
return($xml_array);
}
function array_search_key($array,$search, $first_key_only = 1 )
{
$key = preg_grep('/'.$search.'/', array_keys($array));
reset($key);
$first_key = key($key);
if (isset($first_key)){
if($first_key_only == 1)
return($key[$first_key]);
return($key);
}
return false;
}
function array_check($array,$key)
{
if (is_array ($array))
{
return (isset($array[$key]) || array_key_exists($key,$array));
}
return (false);
}
function BrowseList($array)
{
if(!$array) return array();
//zum testen
$MetaData="blablabla";
//Suche der Result im Array
//sollte noch verbessert werden
$key = array_search_key($array, "Envelope$");
$key2 = array_search_key($array[$key], "Body$");
$key3 = array_search_key($array[$key][$key2], "BrowseResponse$");
$key4 = array_search_key($array[$key][$key2][$key3], "Result$");
$DIDL = $array[$key][$key2][$key3][$key4]["DIDL-Lite"];
$liste = array();
$i = 0;
if(array_check($DIDL,'container'))
{
$keys = array_search_key($DIDL['container'],"[0-9]$",0);
$count = count($keys);
if ($count==1){
$i=0;
$liste[$i]['typ'] = 'container';
$liste[$i]['metadata'] = $MetaData;
if(isset($DIDL['container_attr']['id']))
$liste[$i]['id'] = $DIDL['container_attr']['id'];
if(isset($DIDL['container_attr']['refID']))
$liste[$i]['refid'] = $DIDL['container_attr']['refID'];
if(isset($DIDL['container_attr']['parentID']))
$liste[$i]['parentid'] = $DIDL['container_attr']['parentID'];
if(isset($DIDL['container_attr']['restricted']))
$liste[$i]['restricted'] = $DIDL['container_attr']['restricted'];
$key = array_search_key($DIDL['container'],"artist$");
if($key)
$liste[$i]['artist'] = $DIDL['container'][$key];
$key = array_search_key($DIDL['container'],"album$");
if($key)
$liste[$i]['album'] = $DIDL['container'][$key];
$key = array_search_key($DIDL['container'],"title$");
if($key)
$liste[$i]['title'] = $DIDL['container'][$key];
}
else
{
for ($i=0; $i < $count; $i++)
{
$liste[$i]['typ'] = 'container';
$liste[$i]['metadata'] = $MetaData;
if(isset($DIDL['container'][$i."_attr"]['id']))
$liste[$i]['id'] = $DIDL['container'][$i."_attr"]['id'];
if(isset($DIDL['container'][$i."_attr"]['refID']))
$liste[$i]['refid'] = $DIDL['container'][$i."_attr"]['refID'];
if(isset($DIDL['container'][$i."_attr"]['parentID']))
$liste[$i]['parentid'] = $DIDL['container'][$i."_attr"]['parentID'];
if(isset($DIDL['container'][$i."_attr"]['restricted']))
$liste[$i]['restricted'] = $DIDL['container'][$i."_attr"]['restricted'];
$key = array_search_key($DIDL['container'][$i],"artist$");
if($key)
$liste[$i]['artist'] = $DIDL['container'][$i][$key];
$key = array_search_key($DIDL['container'][$i],"album$");
if($key)
$liste[$i]['album'] = $DIDL['container'][$i][$key];
$key = array_search_key($DIDL['container'][$i],"title$");
if($key)
$liste[$i]['title'] = $DIDL['container'][$i][$key];
}
}
}
if(array_check($DIDL,'item'))
{
$keys = array_search_key($DIDL['item'],"[0-9]$",0);
$count = (count($keys));
$n = $i;
if ($count==1){
$i=0;
$liste[$n+$i]['typ'] = 'item';
$liste[$n+$i]['metadata'] = $MetaData;
if(isset($DIDL['item_attr']['id']))
$liste[$n+$i]['id'] = $DIDL['item_attr']['id'];
if(isset($DIDL['item_attr']['refID']))
$liste[$n+$i]['refid'] = $DIDL['item_attr']['refID'];
if(isset($DIDL['item_attr']['parentID']))
$liste[$n+$i]['parentid'] = $DIDL['item_attr']['parentID'];
if(isset($DIDL['item_attr']['restricted']))
$liste[$n+$i]['restricted'] = $DIDL['item_attr']['restricted'];
$key = array_search_key($DIDL['item'],"artist$");
if($key){
if(array_check($DIDL['item'][$key],'0'))
$liste[$n+$i]['artist'] = $DIDL['item'][$key]['0'];
else
$liste[$n+$i]['artist'] = $DIDL['item'][$key];
}
$key = array_search_key($DIDL['item'],"album$");
if($key)
$liste[$n+$i]['album'] = $DIDL['item'][$key];
$key = array_search_key($DIDL['item'],"title$");
if($key)
$liste[$n+$i]['title'] = $DIDL['item'][$key];
if(array_check($DIDL['item']['res'],'0')){
//kann noch verbessert werden, da mehrere Recourcen zur Verfügung stehen
$liste[$n+$i]['resource'] = $DIDL['item']['res']['0'];
if(isset($DIDL['item']['res']['0_attr']['duration']))
$liste[$n+$i]['duration'] = $DIDL['item']['res']['0_attr']['duration'];
if(isset($DIDL['item']['res']['0_attr']['size']))
$liste[$n+$i]['size'] = $DIDL['item']['res']['0_attr']['size'];
if(isset($DIDL['item']['res']['0_attr']['bitrate']))
$liste[$n+$i]['bitrate'] = $DIDL['item']['res']['0_attr']['bitrate'];
}
else {
if(array_check($DIDL['item'],'res')){
$liste[$n+$i]['resource'] = $DIDL['item']['res'];
if(isset($DIDL['item']['res_attr']['duration']))
$liste[$n+$i]['duration'] = $DIDL['item']['res_attr']['duration'];
if(isset($DIDL['item']['res_attr']['size']))
$liste[$n+$i]['size'] = $DIDL['item']['res_attr']['size'];
if(isset($DIDL['item']['res_attr']['bitrate']))
$liste[$n+$i]['bitrate'] = $DIDL['item']['res_attr']['bitrate'];
}
}
$key = array_search_key($DIDL['item'],"albumArtURI$");
if($key)
$liste[$n+$i]['albumArtURI'] = $DIDL['item'][$key];
$key = array_search_key($DIDL['item'],"genre$");
if($key)
$liste[$n+$i]['genre'] = $DIDL['item'][$key];
$key = array_search_key($DIDL['item'],"date$");
if($key)
$liste[$n+$i]['date'] = $DIDL['item'][$key];
$key = array_search_key($DIDL['item'],"originalTrackNumber$");
if($key)
$liste[$n+$i]['originalTrackNumber'] = $DIDL['item'][$key];
$key = array_search_key($DIDL['item'],"class$");
if($key)
$liste[$n+$i]['class'] = $DIDL['item'][$key];
}
else
{
for ($i=0; $i < $count; $i++)
{
$liste[$n+$i]['typ'] = 'item';
$liste[$n+$i]['metadata'] = $MetaData;
if(isset($DIDL['item'][$i.'_attr']['id']))
$liste[$n+$i]['id'] = $DIDL['item'][$i.'_attr']['id'];
if(isset($DIDL['item'][$i.'_attr']['refID']))
$liste[$n+$i]['refid'] = $DIDL['item'][$i.'_attr']['refID'];
if(isset($DIDL['item'][$i.'_attr']['parentID']))
$liste[$n+$i]['parentid'] = $DIDL['item'][$i.'_attr']['parentID'];
if(isset($DIDL['item'][$i.'_attr']['restricted']))
$liste[$n+$i]['restricted'] = $DIDL['item'][$i.'_attr']['restricted'];
$key = array_search_key($DIDL['item'][$i],"artist$");
if($key){
if(array_check($DIDL['item'][$i][$key],'0'))
$liste[$n+$i]['artist'] = $DIDL['item'][$i][$key]['0'];
else
$liste[$n+$i]['artist'] = $DIDL['item'][$i][$key];
}
$key = array_search_key($DIDL['item'][$i],"album$");
if($key)
$liste[$n+$i]['album'] = $DIDL['item'][$i][$key];
$key = array_search_key($DIDL['item'][$i],"title$");
if($key)
$liste[$n+$i]['title'] = $DIDL['item'][$i][$key];
if(array_check($DIDL['item'][$i]['res'],'0')){
//kann noch verbessert werden, da mehrere Recourcen zur Verfügung stehen
$liste[$n+$i]['resource'] = $DIDL['item'][$i]['res']['0'];
if(isset($DIDL['item'][$i]['res']['0_attr']['duration']))
$liste[$n+$i]['duration'] = $DIDL['item'][$i]['res']['0_attr']['duration'];
if(isset($DIDL['item'][$i]['res']['0_attr']['size']))
$liste[$n+$i]['size'] = $DIDL['item'][$i]['res']['0_attr']['size'];
if(isset($DIDL['item'][$i]['res']['0_attr']['bitrate']))
$liste[$n+$i]['bitrate'] = $DIDL['item'][$i]['res']['0_attr']['bitrate'];
}
else {
if(array_check($DIDL['item'][$i],'res')){
$liste[$n+$i]['resource'] = $DIDL['item'][$i]['res'];
if(isset($DIDL['item'][$i]['res_attr']['duration']))
$liste[$n+$i]['duration'] = $DIDL['item'][$i]['res_attr']['duration'];
if(isset($DIDL['item'][$i]['res_attr']['size']))
$liste[$n+$i]['size'] = $DIDL['item'][$i]['res_attr']['size'];
if(isset($DIDL['item'][$i]['res_attr']['bitrate']))
$liste[$n+$i]['bitrate'] = $DIDL['item'][$i]['res_attr']['bitrate'];
}
}
$key = array_search_key($DIDL['item'][$i],"albumArtURI$");
if($key)
$liste[$n+$i]['albumArtURI'] = $DIDL['item'][$i][$key];
$key = array_search_key($DIDL['item'][$i],"genre$");
if($key)
$liste[$n+$i]['genre'] = $DIDL['item'][$i][$key];
$key = array_search_key($DIDL['item'][$i],"date$");
if($key)
$liste[$n+$i]['date'] = $DIDL['item'][$i][$key];
$key = array_search_key($DIDL['item'][$i],"originalTrackNumber$");
if($key)
$liste[$n+$i]['originalTrackNumber'] = $DIDL['item'][$i][$key];
$key = array_search_key($DIDL['item'][$i],"class$");
if($key)
$liste[$n+$i]['class'] = $DIDL['item'][$i][$key];
}
}
}
return ($liste);
}
?>