Package sonos

Source Code of sonos.XMLTester


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&apos;%20But%20A%20&apos;G&apos;%20Thang%20%5bfeat.%20Snoop%20Dogg%5d.mp3\"/><CurrentTrackDuration val=\"0:03:58\"/><CurrentTrackMetaData val=\"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;-1&quot; parentID=&quot;-1&quot; restricted=&quot;true&quot;&gt;&lt;res protocolInfo=&quot;x-file-cifs:*:audio/mpeg:*&quot; duration=&quot;0:03:58&quot;&gt;x-file-cifs://LAPPY486/Music/0%20Unsorted,%20Singles/Dr.%20Dre%20-%20Nuthin&amp;apos;%20But%20A%20&amp;apos;G&amp;apos;%20Thang%20%5bfeat.%20Snoop%20Dogg%5d.mp3&lt;/res&gt;&lt;r:streamContent&gt;&lt;/r:streamContent&gt;&lt;r:radioShowMd&gt;&lt;/r:radioShowMd&gt;&lt;upnp:albumArtURI&gt;/getaa?u=x-file-cifs%3a%2f%2fLAPPY486%2fMusic%2f0%2520Unsorted,%2520Singles%2fDr.%2520Dre%2520-%2520Nuthin&amp;apos;%2520But%2520A%2520&amp;apos;G&amp;apos;%2520Thang%2520%255bfeat.%2520Snoop%2520Dogg%255d.mp3&amp;amp;v=8&lt;/upnp:albumArtURI&gt;&lt;dc:title&gt;Nuthin&amp;apos; But A &amp;apos;G&amp;apos; Thang [feat. Snoop Dogg]&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.musicTrack&lt;/upnp:class&gt;&lt;dc:creator&gt;Dr. Dre&lt;/dc:creator&gt;&lt;r:albumArtist&gt;Dr. Dre&lt;/r:albumArtist&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;\"/><r:NextTrackURI val=\"\"/><r:NextTrackMetaData val=\"\"/><r:EnqueuedTransportURI val=\"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\"/><r:EnqueuedTransportURIMetaData val=\"&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;S://LAPPY486/Music/0%20Unsorted,%20Singles/Dr.%20Dre%20-%20Nuthin&amp;apos;%20But%20A%20&amp;apos;G&amp;apos;%20Thang%20%5bfeat.%20Snoop%20Dogg%5d.mp3&quot; parentID=&quot;A:ALBUMARTIST/Dr.%20Dre/&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;Nuthin&amp;apos; But A &amp;apos;G&amp;apos; Thang [feat. Snoop Dogg]&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.musicTrack&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;RINCON_AssociatedZPUDN&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;\"/></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&amp;v=8</upnp:albumArtURI><dc:title>How Do U Want It? [feat. K-Ci &amp; 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=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;>";
         
        //  sonosxml = sonosxml.replaceAll("&quot;", '"'+"").replaceAll("&gt;",">");
     
       //   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("&quot;", '"'+"").replaceAll("&lt;", "<").replaceAll("&gt;",">").replaceAll("&amp;", "&").replaceAll("&apos;", "'");   
    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&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>";
   
   
   
    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();
    }
    */
   
  }

}
 
TOP

Related Classes of sonos.XMLTester

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.