private void CreateTargetPlaylist(PlaylistItem[] inPlaylist, string sourceFile, string targetDirectory, IStorage storage)
        {
            var playlistHandler = PlaylistHandlerFactory.GetHandler(_targetPlaylistType.ToString().ToLower());

            var newPlaylistRawContent = playlistHandler.SetPlaylistItems(storage.File, inPlaylist, targetDirectory);
            var targetFileName        = $"{Path.GetFileNameWithoutExtension(sourceFile)}.{_targetPlaylistType.ToString().ToLower()}";

            storage.File.WriteAllText(Path.Combine(targetDirectory, targetFileName), newPlaylistRawContent);
            PlaylistCreated?.Invoke(this, new ProgressEventArgs(targetFileName, 1));
        }
Exemple #2
0
        public void Start(string playlistFileName, IMap <IEnumerable <PlaylistItem>, IEnumerable <MixxxPlaylistTrack> > mapper)
        {
            if (string.IsNullOrEmpty(playlistFileName))
            {
                throw new ArgumentNullException(nameof(playlistFileName));
            }
            var playlistItems    = _dataHandler.Get(Path.GetFileNameWithoutExtension(playlistFileName), mapper);
            var playlistHandler  = PlaylistHandlerFactory.GetHandler(Path.GetExtension(playlistFileName));
            var playlistContents = playlistHandler.SetPlaylistItems(_file, playlistItems.ToArray());

            _file.WriteAllText(playlistFileName, playlistContents.Replace("\0", ""));
        }
        private PlaylistItem[] ReadPlaylist(string file)
        {
            var playlistHandler = PlaylistHandlerFactory.GetHandler(Path.GetExtension(file));

            if (playlistHandler != null)
            {
                var playlistRawContent = _sourceStorage.File.ReadAllText(file);
                if (!string.IsNullOrEmpty(playlistRawContent))
                {
                    return(playlistHandler.GetPlaylistItems(playlistRawContent));
                }
            }
            return(null);
        }
        private bool PushPlaylistContentsToMixxx(string playlistContents, string playlistName, IMap <IEnumerable <PlaylistItem>, IEnumerable <MixxxPlaylistTrack> > mapper, bool deleteOnly = false)
        {
            var playlistHandler = PlaylistHandlerFactory.GetHandler(Path.GetExtension(playlistName));
            var playlistItems   = playlistHandler.GetPlaylistItems(playlistContents);

            if (_dataHandler.Delete(Path.GetFileNameWithoutExtension(playlistName)))
            {
                MixxxPlaylistDeleted?.Invoke(this,
                                             new MixxxProcessorProgressEventHandler(Path.GetFileNameWithoutExtension(playlistName)));
            }
            if (!deleteOnly)
            {
                if (_dataHandler.Create(Path.GetFileNameWithoutExtension(playlistName), playlistItems, mapper))
                {
                    MixxxPlaylistCreated?.Invoke(this,
                                                 new MixxxProcessorProgressEventHandler(Path.GetFileNameWithoutExtension(playlistName)));
                }
            }
            return(true);
        }