Ejemplo n.º 1
0
        public static AlsongLyric Parse(XmlNode xmlNode)
        {
            AlsongLyric lyric = null;

            if (xmlNode.Name == "ST_SEARCHLYRIC_LIST")
            {
                lyric = new AlsongLyric
                {
                    LyricID = xmlNode["lyricID"].InnerText,
                    Title   = xmlNode["title"].InnerText,
                    Artist  = xmlNode["artist"].InnerText,
                    Album   = xmlNode["album"].InnerText,
                };
            }
            else if (xmlNode.Name == "GetLyric7Result")
            {
                lyric = new AlsongLyric
                {
                    LyricID = xmlNode["strInfoID"].InnerText,
                    Title   = xmlNode["strTitle"].InnerText,
                    Artist  = xmlNode["strArtist"].InnerText,
                    Album   = xmlNode["strAlbum"].InnerText,

                    Lyric = ParseLyric(xmlNode["strLyric"].InnerText),
                };
            }

            return(string.IsNullOrWhiteSpace(lyric?.Title) ? null : lyric);
        }
Ejemplo n.º 2
0
        public static AlsongLyric[] SearchByFile(string filePath)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(filePath) || !File.Exists(filePath))
                {
                    return(null);
                }

                var ext = Path.GetExtension(filePath);
                if (ext != ".mp3" && ext != ".ogg" && ext != ".wma" && ext != ".flac")
                {
                    return(null);
                }

                var checkSum = GetChecksum(filePath);
                if (checkSum == null)
                {
                    return(null);
                }

                var data = Encoding.UTF8.GetBytes($@"<?xml version=""1.0"" encoding=""UTF-8""?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=""http://www.w3.org/2003/05/soap-envelope""
xmlns:SOAP-ENC=""http://www.w3.org/2003/05/soap-encoding""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:ns2=""ALSongWebServer/Service1Soap""
xmlns:ns1=""ALSongWebServer""
xmlns:ns3=""ALSongWebServer/Service1Soap12"">
    <SOAP-ENV:Body>
        <ns1:GetLyric7>
            <ns1:encData>{EncData}</ns1:encData>
            <ns1:stQuery>
                <ns1:strChecksum>{checkSum}</ns1:strChecksum>
                <ns1:strVersion>3.46</ns1:strVersion>
                <ns1:strMACAddress></ns1:strMACAddress>
                <ns1:strIPAddress></ns1:strIPAddress>
            </ns1:stQuery>
        </ns1:GetLyric7>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>");

                var lyric = AlsongLyric.Parse(CallSoap("GetLyric7", data).SelectSingleNode("//*[local-name()='GetLyric7Result']"));
                return(lyric == null ? null : new AlsongLyric[] { lyric });
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        public static AlsongLyric[] SearchByText(string artist, string title, int page)
        {
            try
            {
                var data = Encoding.UTF8.GetBytes($@"<?xml version=""1.0"" encoding=""UTF-8""?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=""http://www.w3.org/2003/05/soap-envelope""
xmlns:SOAP-ENC=""http://www.w3.org/2003/05/soap-encoding""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:ns2=""ALSongWebServer/Service1Soap""
xmlns:ns1=""ALSongWebServer""
xmlns:ns3=""ALSongWebServer/Service1Soap12"">
    <SOAP-ENV:Body>
        <ns1:GetResembleLyricList2>
            <ns1:encData>{EncData}</ns1:encData>
            <ns1:title>{new XText(title).ToString()}</ns1:title>
            <ns1:artist>{new XText(artist).ToString()}</ns1:artist>
            <ns1:pageNo>{page}</ns1:pageNo>
        </ns1:GetResembleLyricList2>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>");

                return(CallSoap("GetResembleLyricList2", data).SelectNodes("//*[local-name()='ST_SEARCHLYRIC_LIST']")?.Cast <XmlNode>().Select(e => AlsongLyric.Parse(e)).Where(e => e != null).ToArray());
            }
            catch
            {
                return(null);
            }
        }