Ejemplo n.º 1
0
        /// <summary>
        /// Opens m3u8 file and loads the play list collection with the included songs
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenM3u8File_Button_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter = "Plex Export|*.m3u8";
            openFileDialog1.Title  = "Select a Playlist Export";

            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SelectedM3u8File = openFileDialog1.FileName;
                string line;
                using (Stream stream = openFileDialog1.OpenFile())
                {
                    using (StreamReader sr = new StreamReader(stream))
                    {
                        if (cbxDeleteOnLoad.Checked)
                        {
                            PlayList.ClearItems();
                        }

                        line = sr.ReadLine();
                        while (line != null)
                        {
                            if (line.StartsWith("#{\"Id\":"))
                            {
                                List <string> m3u8SongExportList = new List <string>();
                                m3u8SongExportList.Add(line);
                                m3u8SongExportList.Add(sr.ReadLine());
                                m3u8SongExportList.Add(sr.ReadLine());

                                PlayListSong thisSong = new PlayListSong(m3u8SongExportList);

                                PlayList.Add(thisSong);

                                //DownloadOutput.AppendText(Environment.NewLine + thisSong.Path);
                                //if (DownloadOutput.Lines.Count() != 0)
                                //    DownloadOutput.Text += Environment.NewLine;

                                //DownloadOutput.Text += thisSong.Title + thisSong.Extension;
                            }

                            line = sr.ReadLine();
                        }
                    }
                };
            }
        }