Esempio n. 1
0
        public static void Generate_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            Object[]  arguments = e.Argument as Object[];
            LyricItem item      = arguments[0] as LyricItem;
            String    fileName  = arguments[1] as String;

            worker.ReportProgress(0, item.Provider.Name);

            LyricContent lyricContent = item.Provider.Retrieve(item);

            switch (Path.GetExtension(fileName))
            {
            case ".txt":
                TextLyricWriter writer = new TextLyricWriter(lyricContent);

                writer.WriteTo(fileName);

                break;

            default:
                break;
            }

            e.Result = fileName;
        }
Esempio n. 2
0
        public LyricContent Retrieve(LyricItem item)
        {
            if (item.Provider.Name != this.Name)
            {
                throw new NotSupportedException("The lyric item data was not from the current provider.");
            }

            String html = WebOperations.GetContentAsString(item.URI.ToString(), Encoding.UTF8);

            Match match = JLyricProvider.LyricParseRegex.Match(html);

            String title    = item.SongTitle;
            String artist   = item.SongArtist;
            String writer   = match.Groups["Writer"].Value;
            String composer = match.Groups["Composer"].Value;

            String[] lyric = match.Groups["Lyric"].Value.Split(new String[] { "<br>" }, StringSplitOptions.None);

            return(new LyricContent(title, artist, writer, composer, lyric, item));
        }
Esempio n. 3
0
 public LyricContent(String title, String artist, String writer, String composer, String[] lyric, LyricItem item)
 {
     this.Title    = title;
     this.Artist   = artist;
     this.Writer   = writer;
     this.Composer = composer;
     this.Lyric    = lyric;
     this.Item     = item;
 }