package sonos;
import java.net.URLDecoder;
import java.util.Map;
import org.xml.sax.SAXException;
import common.Sender;
import common.TrackMetaData;
public class XMLTester {
public static void main(String[] args) {
// TODO Auto-generated method stub
String sonosxml = "<Event xmlns=\"urn:schemas-upnp-org:metadata-1-0/AVT/\" xmlns:r=\"urn:schemas-rinconnetworks-com:metadata-1-0/\"><InstanceID val=\"0\"><TransportState val=\"PLAYING\"/><CurrentPlayMode val=\"NORMAL\"/><NumberOfTracks val=\"13\"/><CurrentTrack val=\"13\"/><CurrentSection val=\"0\"/><CurrentTrackURI val=\"x-file-cifs://LAPPY486/Music/0%20Unsorted,%20Singles/Dr.%20Dre%20-%20Nuthin'%20But%20A%20'G'%20Thang%20%5bfeat.%20Snoop%20Dogg%5d.mp3\"/><CurrentTrackDuration val=\"0:03:58\"/><CurrentTrackMetaData val=\"<DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="-1" parentID="-1" restricted="true"><res protocolInfo="x-file-cifs:*:audio/mpeg:*" duration="0:03:58">x-file-cifs://LAPPY486/Music/0%20Unsorted,%20Singles/Dr.%20Dre%20-%20Nuthin&apos;%20But%20A%20&apos;G&apos;%20Thang%20%5bfeat.%20Snoop%20Dogg%5d.mp3</res><r:streamContent></r:streamContent><r:radioShowMd></r:radioShowMd><upnp:albumArtURI>/getaa?u=x-file-cifs%3a%2f%2fLAPPY486%2fMusic%2f0%2520Unsorted,%2520Singles%2fDr.%2520Dre%2520-%2520Nuthin&apos;%2520But%2520A%2520&apos;G&apos;%2520Thang%2520%255bfeat.%2520Snoop%2520Dogg%255d.mp3&amp;v=8</upnp:albumArtURI><dc:title>Nuthin&apos; But A &apos;G&apos; Thang [feat. Snoop Dogg]</dc:title><upnp:class>object.item.audioItem.musicTrack</upnp:class><dc:creator>Dr. Dre</dc:creator><r:albumArtist>Dr. Dre</r:albumArtist></item></DIDL-Lite>\"/><r:NextTrackURI val=\"\"/><r:NextTrackMetaData val=\"\"/><r:EnqueuedTransportURI val=\"x-file-cifs://LAPPY486/Music/0%20Unsorted,%20Singles/Dr.%20Dre%20-%20Nuthin'%20But%20A%20'G'%20Thang%20%5bfeat.%20Snoop%20Dogg%5d.mp3\"/><r:EnqueuedTransportURIMetaData val=\"<DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="S://LAPPY486/Music/0%20Unsorted,%20Singles/Dr.%20Dre%20-%20Nuthin&apos;%20But%20A%20&apos;G&apos;%20Thang%20%5bfeat.%20Snoop%20Dogg%5d.mp3" parentID="A:ALBUMARTIST/Dr.%20Dre/" restricted="true"><dc:title>Nuthin&apos; But A &apos;G&apos; Thang [feat. Snoop Dogg]</dc:title><upnp:class>object.item.audioItem.musicTrack</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">RINCON_AssociatedZPUDN</desc></item></DIDL-Lite>\"/></InstanceID></Event>";
// String sonosxml = "<DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\" xmlns:r=\"urn:schemas-rinconnetworks-com:metadata-1-0/\" xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"><item id=\"-1\" parentID=\"-1\" restricted=\"true\"><res protocolInfo=\"x-file-cifs:*:audio/mpeg:*\" duration=\"0:04:47\">x-file-cifs://LAPPY486/Music/2Pac/Greatest%20Hits%20%5bDeath%20Row%5d/07%20How%20Do%20U%20Want%20It-.mp3</res><r:streamContent></r:streamContent><upnp:albumArtURI>/getaa?u=x-file-cifs%3a%2f%2fLAPPY486%2fMusic%2f2Pac%2fGreatest%2520Hits%2520%255bDeath%2520Row%255d%2f07%2520How%2520Do%2520U%2520Want%2520It-.mp3&v=8</upnp:albumArtURI><dc:title>How Do U Want It? [feat. K-Ci & JoJo]</dc:title><upnp:class>object.item.audioItem.musicTrack</upnp:class><dc:creator>2Pac</dc:creator><upnp:album>Greatest Hits [Death Row]</upnp:album><upnp:originalTrackNumber>7</upnp:originalTrackNumber><r:albumArtist>2Pac</r:albumArtist></item></DIDL-Lite>";
// String sonosxml = "<DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/">>";
// sonosxml = sonosxml.replaceAll(""", '"'+"").replaceAll(">",">");
// System.out.println(sonosxml);
// <Event xmlns="urn:schemas-upnp-org:metadata-1-0/AVT/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/"><InstanceID val="0"><TransportState val="PLAYING"/><CurrentPlayMode val="NORMAL"/><NumberOfTracks val="14"/><CurrentTrack val="14"/><CurrentSection val="0"/><CurrentTrackURI val="x-file-cifs://LAPPY486/Music/The%20Beatles/Let%20It%20Be%20Naked/06%20I%20Got%20A%20Feeling.mp3"/><CurrentTrackDuration val="0:03:30"/> </InstanceID></Event>
//sonosxml=URLDecoder.decode(sonosxml.replaceAll("\"", '"'+""));
sonosxml = sonosxml.replaceAll("\"", '"'+"");
String fullsonosxml = sonosxml.replaceAll(""", '"'+"").replaceAll("<", "<").replaceAll(">",">").replaceAll("&", "&").replaceAll("'", "'");
sonosxml = fullsonosxml.substring(fullsonosxml.indexOf("<DIDL-Lite"),fullsonosxml.indexOf("DIDL-Lite>")+10);
String sonosxmltrue="<DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\" xmlns:r=\"urn:schemas-rinconnetworks-com:metadata-1-0/\" xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"><item id=\"-1\" parentID=\"-1\" restricted=\"true\"><res protocolInfo=\"x-file-cifs:*:audio/mpeg:*\" duration=\"0:03:58\">x-file-cifs://LAPPY486/Music/0%20Unsorted,%20Singles/Dr.%20Dre%20-%20Nuthin'%20But%20A%20'G'%20Thang%20%5bfeat.%20Snoop%20Dogg%5d.mp3</res><r:streamContent></r:streamContent><r:radioShowMd></r:radioShowMd><upnp:albumArtURI>/getaa?u=x-file-cifs%3a%2f%2fLAPPY486%2fMusic%2f0%2520Unsorted,%2520Singles%2fDr.%2520Dre%2520-%2520Nuthin'%2520But%2520A%2520'G'%2520Thang%2520%255bfeat.%2520Snoop%2520Dogg%255d.mp3&v=8</upnp:albumArtURI><dc:title>Nuthin' But A 'G' Thang [feat. Snoop Dogg]</dc:title><upnp:class>object.item.audioItem.musicTrack</upnp:class><dc:creator>Dr. Dre</dc:creator><r:albumArtist>Dr. Dre</r:albumArtist></item></DIDL-Lite>";
System.out.println(sonosxml);
System.out.println(sonosxmltrue);
TrackMetaData tmd = XMLParser.parseTrackMetaData(sonosxml);
Sender sender = Sender.getXMLSender();
sender.sendDataToSite(tmd);
/*
//sonosxml=URLDecoder.decode(sonosxml.replaceAll("\"", '"'+""));
//System.out.println(sonosxml);
try {
TrackMetaData tmd = XMLParser.parseTrackMetaData(sonosxml);
System.out.println(tmd.getAlbumArtist()+tmd.getTitle()+tmd.getAlbum());
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
}
}