Exemplo n.º 1
0
        static void Main(string[] args)
        {
            string caminhoPath = @"C:\Users\anogueira\Downloads\Lista\";

            string[] files = Directory.GetFiles(caminhoPath, "*.m3u");


            IList <M3UFile> m3uFiles = new List <M3UFile>();

            foreach (string file in files)
            {
                M3UFile m3u = new M3UFile(file);
                m3uFiles.Add(m3u);
                Console.WriteLine($"Arquivo: {file} Total da lista: {m3u.Count}");
            }

            if (m3uFiles.Count > 0)
            {
                int count = 0;
                foreach (var m3u in m3uFiles)
                {
                    m3u.Save(caminhoPath + count + ".m3u");
                    count++;
                }
            }

            Console.ReadKey();
        }
Exemplo n.º 2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (_m3uFile != null)
     {
         using (var sfd = new SaveFileDialog()
         {
             Filter = "M3U File (*.m3u)|*.m3u", Title = "Save Playlist"
         })
         {
             if (sfd.ShowDialog() == DialogResult.OK)
             {
                 _m3uFile.Save(sfd.FileName);
             }
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// save current playlist as a M3U file
        /// </summary>
        private void SaveCurrentPlToFile()
        {
            string lblAudioFileType = rm.GetString("plAudioFilterType");

            using (var sfd = new SaveFileDialog {
                Filter = lblAudioFileType + " (*.m3u)|*.m3u", Title = rm.GetString("savePlDlgTitle")
            })
            {
                sfd.InitialDirectory = "";
                sfd.OverwritePrompt  = true;
                sfd.RestoreDirectory = true;
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    _m3uFile = null;

                    try
                    {
                        _m3uFile = new M3UFile();
                        foreach (ListViewItem lvItem in l.Items)
                        {
                            /*AudioFileInfo afInfo = new AudioFileInfo(
                             *  Path.GetFileName(lvItem.SubItems[2].Text), lvItem.SubItems[2].Text);
                             * afInfo.SetDuration();*/

                            M3UEntry _m3uEntry = new M3UEntry(TimeSpan.Zero,
                                                              lvItem.SubItems[0].Text,
                                                              new Uri(lvItem.SubItems[2].Text));
                            _m3uFile.Add(_m3uEntry);
                        }
                        // save files into playlist file
                        _m3uFile.Save(sfd.FileName);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error saving playlist to file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            //Console.WriteLine("Hello World!");
            string inputFolder  = @"C:\Users\d.egorychev\Music\unsorted";
            string outputFolder = @"C:\Users\d.egorychev\Music\sorted";

            if (args.Length == 2)
            {
                inputFolder  = args[0];
                outputFolder = args[1];
            }
            string[] allfolders = Directory.GetDirectories(inputFolder);
            foreach (string folder in allfolders)
            {
                M3UFile  playlist = new M3UFile(new FileInfo(outputFolder + "\\" + folder.Substring(folder.LastIndexOf('\\')) + ".m3u"));
                string[] AllFiles = Directory.GetFiles(folder, "*.flac", SearchOption.AllDirectories);
                foreach (string filename in AllFiles)
                {
                    var    tfile  = TagLib.File.Create(filename);
                    string artist = "noname_author";
                    if ((tfile.Tag.AlbumArtists[0] != null) || (tfile.Tag.AlbumArtists[0] != ""))
                    {
                        artist = String.Join('-', tfile.Tag.AlbumArtists);
                    }
                    string album = "noname_album";
                    if ((tfile.Tag.Album != null) || (tfile.Tag.Album != ""))
                    {
                        album = tfile.Tag.Album;
                    }

                    string PathDeb = artist + "\\" + album + filename.Substring(filename.LastIndexOf('\\'));
                    foreach (var ch in "~#%&*{}:<>?+|\"")
                    {
                        PathDeb = PathDeb.Replace(ch, '�');
                    }
                    foreach (var ch in new string[] { "...", ".." })
                    {
                        PathDeb = PathDeb.Replace(ch, "�");
                    }
                    FileInfo newPath = new FileInfo(outputFolder + "\\" + PathDeb);

                    Directory.CreateDirectory(newPath.DirectoryName);
                    File.Copy(filename, newPath.FullName, true);

                    MediaItem MI = new MediaItem {
                        Location = PathDeb
                    };
                    playlist.Files.Add(MI);

                    Console.WriteLine(newPath);
                }
                playlist.Save();
            }

            //var tfile = TagLib.File.Create(@"C:\Users\d.egorychev\Music\Nathan Dawe - Flowers (feat. Jaykae).flac");
            //string title = tfile.Tag.Title;
            //TimeSpan duration = tfile.Properties.Duration;
            //Console.WriteLine("Title: {0}, duration: {1}", title, duration);
            Console.WriteLine("Done!");
            Console.ReadLine();
        }