Esempio n. 1
0
        internal void SavePlaylistNonEnglishLibrary(Dictionary <string, MusicPlaylist> _dictionary)
        {
            AudioFolder temp = new AudioFolder(this.location, this.title);

            foreach (var item in Enum.GetValues(typeof(Languages)))
            {
                if (_dictionary.ContainsKey(item.ToString()))
                {
                    string header   = item.ToString().Substring(0, 2);
                    string fileName = "index." + header + ".json";
                    if (DiskIO.IsFileExist(ContentLocation, fileName))
                    {
                        temp = DiskIO.DeserializeAudioFolderFromFile(ContentLocation, fileName);
                        temp.SetLocationTitle(this.location, this.title);
                        if (temp.HasPlaylistWithID(_dictionary[item.ToString()].id))
                        {
                            temp.RemovePlaylistWithID(_dictionary[item.ToString()].id);
                        }
                        temp.library.Add(_dictionary[item.ToString()]);
                        temp.SavePlaylistLibrary(fileName);
                    }
                    else
                    {
                        temp.library = new List <MusicPlaylist>();
                        temp.library.Add(_dictionary[item.ToString()]);
                        temp.SavePlaylistLibrary(fileName);
                    }
                }
            }
        }
Esempio n. 2
0
        internal FileCopier[] ExportFilesTo(string _contentLoc, string[] _languages)
        {
            string            newWorkArea    = _contentLoc + "\\" + title;
            List <FileCopier> allFilesToCopy = new List <FileCopier>();

            // create root folder
            DiskIO.CreateDirectory(newWorkArea);
            DiskIO.DeleteAllFiles(newWorkArea);
            // create each playlist folder
            foreach (MusicPlaylist p in this.library)
            {
                string playlistNewLocation = newWorkArea + "\\" + p.id;
                DiskIO.CreateDirectory(playlistNewLocation);
                // determine music files to copy
                foreach (MusicFile file in p.GetMusicFilesInfo())
                {
                    // add music file
                    allFilesToCopy.Add(new FileCopier(file.file, playlistNewLocation + "\\" + DiskIO.GetFileName(file.file)));
                    // change the file path to the new path for further library json saving
                    file.file = DiskIO.GetFileName(file.file);
                }
                // add playlist cover to copy
                if (p.cover != "")
                {
                    allFilesToCopy.Add(new FileCopier(p.cover, playlistNewLocation + "\\cover.jpg"));
                    // change the cover path to the new path for further library json saving
                    p.cover = "\\cover.jpg";
                }
                p.playlist = "\\index.m3u";
            }
            // save changed paths and music files into exported location
            this.SavePlaylistLibraryAtLocation(newWorkArea, "index.en.json");

            // copy all requested non-English langs
            foreach (string lang in _languages)
            {
                string abbriv = "index." + lang.Substring(0, 2).ToLower() + ".json";
                if (DiskIO.IsFileExist(ContentLocation, abbriv))
                {
                    AudioFolder temp = DiskIO.DeserializeAudioFolderFromFile(ContentLocation, abbriv);
                    foreach (MusicPlaylist x in temp.library)
                    {
                        x.playlist = "\\index.m3u";
                        if (x.cover != "")
                        {
                            x.cover = "\\cover.jpg";
                        }
                    }
                    DiskIO.SaveAsJSONFile(temp, newWorkArea, abbriv);
                }
            }
            return(allFilesToCopy.ToArray());
        }
Esempio n. 3
0
        internal static AudioFolder SerializeFromJSON(string _audioLocation, string _audioFolderName, string _fileName)
        {
            AudioFolder retVal = new AudioFolder(_audioLocation, _audioFolderName);

            if (DiskIO.IsFileExist(_audioLocation + "\\" + _audioFolderName, _fileName))
            {
                retVal = DiskIO.DeserializeAudioFolderFromFile(_audioLocation + "\\" + _audioFolderName, _fileName);
                foreach (MusicPlaylist pls in retVal.library)
                {
                    pls.LoadMusicFileInfos(_audioLocation + "\\" + _audioFolderName + "\\" + pls.id, "index.json");
                }
            }
            retVal.SetLocationTitle(_audioLocation, _audioFolderName);
            return(retVal);
        }
Esempio n. 4
0
        internal void RemovePlaylistNonEnglishData(int _id)
        {
            AudioFolder temp = new AudioFolder(this.location, this.title);

            foreach (var item in Enum.GetValues(typeof(Languages)))
            {
                string header   = item.ToString().Substring(0, 2);
                string fileName = "index." + header + ".json";
                if (DiskIO.IsFileExist(ContentLocation, fileName))
                {
                    temp = DiskIO.DeserializeAudioFolderFromFile(ContentLocation, fileName);
                    temp.SetLocationTitle(this.location, this.title);
                    if (temp.HasPlaylistWithID(_id))
                    {
                        temp.RemovePlaylistWithID(_id);
                    }
                    DiskIO.SaveAsJSONFile(temp, this.ContentLocation, fileName);
                }
            }
        }
Esempio n. 5
0
        internal Dictionary <string, MusicPlaylist> ReadNonEnglishDataLibrary(int _id)
        {
            Dictionary <string, MusicPlaylist> retVal = new Dictionary <string, MusicPlaylist>();
            AudioFolder temp = new AudioFolder(this.location, this.title);

            foreach (var item in Enum.GetValues(typeof(Languages)))
            {
                string header   = item.ToString().Substring(0, 2);
                string fileName = "index." + header + ".json";
                if (DiskIO.IsFileExist(ContentLocation, fileName))
                {
                    temp = DiskIO.DeserializeAudioFolderFromFile(ContentLocation, fileName);
                    temp.SetLocationTitle(this.location, this.title);
                    if (temp.HasPlaylistWithID(_id))
                    {
                        retVal.Add(item.ToString(), temp.FindPlaylistWithID(_id));
                    }
                }
            }
            return(retVal);
        }