Exemplo n.º 1
0
        internal SongItem(SongInfo songInfo, string userName)
        {
            Status   = SongStatus.WaitingDownload;
            UserName = userName;
            Info     = songInfo;

            Lyric = (songInfo.Lyric == null) ? Lrc.NoLyric : Lrc.InitLrc(songInfo.Lyric);
        }
Exemplo n.º 2
0
Arquivo: Lrc.cs Projeto: perichr/DGJv3
        /// <summary>
        /// 获得歌词信息
        /// </summary>
        /// <param name="LrcText">歌词文本</param>
        /// <returns>返回歌词信息(Lrc实例)</returns>
        public static Lrc InitLrc(string LrcText)
        {
            Lrc lrc = new Lrc();
            Dictionary <double, string> dicword = new Dictionary <double, string>();

            string[] lines = LrcText.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);

            foreach (string line in lines)
            {
                if (line.StartsWith("[ti:"))
                {
                    lrc.Title = SplitInfo(line);
                }
                else if (line.StartsWith("[ar:"))
                {
                    lrc.Artist = SplitInfo(line);
                }
                else if (line.StartsWith("[al:"))
                {
                    lrc.Album = SplitInfo(line);
                }
                else if (line.StartsWith("[by:"))
                {
                    lrc.LrcBy = SplitInfo(line);
                }
                else if (line.StartsWith("[offset:"))
                {
                    lrc.Offset = SplitInfo(line);
                }
                else
                {
                    try
                    {
                        Regex  regexword = new Regex(@".*\](.*)");
                        Match  mcw       = regexword.Match(line);
                        string word      = mcw.Groups[1].Value;
                        if (word.Replace(" ", "") == "")
                        {
                            continue; // 如果为空歌词则跳过不处理
                        }
                        Regex           regextime = new Regex(@"\[([0-9.:]*)\]", RegexOptions.Compiled);
                        MatchCollection mct       = regextime.Matches(line);
                        foreach (Match item in mct)
                        {
                            double time = TimeSpan.Parse("00:" + item.Groups[1].Value).TotalSeconds;
                            dicword.Add(time, word);
                        }
                    }
                    catch
                    {
                        continue;
                    }
                }
            }
            lrc.LrcWord = dicword.OrderBy(t => t.Key).ToDictionary(t => t.Key, p => p.Value);
            return(lrc);
        }
Exemplo n.º 3
0
        internal SongItem(SongInfo songInfo, string userName)
        {
            Status = SongStatus.WaitingDownload;

            UserName = userName;

            Module   = songInfo.Module;
            SongId   = songInfo.Id;
            SongName = songInfo.Name;
            Singers  = songInfo.Singers;
            Lyric    = (songInfo.Lyric == null) ? Lrc.NoLyric : Lrc.InitLrc(songInfo.Lyric);
            Note     = songInfo.Note;
        }