Beispiel #1
0
        internal void SaveMoviesNonEnglishLibrary(Dictionary <string, MovieFile> _dictionary)
        {
            VideoFolder temp = new VideoFolder(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.DeserializeVideoFolderFromFile(ContentLocation, fileName);
                        temp.SetLocationTitle(this.location, this.title);
                        if (temp.HasMovieWithID(_dictionary[item.ToString()].id))
                        {
                            temp.RemoveMovieWithID(_dictionary[item.ToString()].id);
                        }
                        temp.library.Add(_dictionary[item.ToString()]);
                        temp.SaveMoviesLibrary(fileName);
                    }
                    else
                    {
                        temp.library = new List <MovieFile>();
                        temp.library.Add(_dictionary[item.ToString()]);
                        temp.SaveMoviesLibrary(fileName);
                    }
                }
            }
        }
Beispiel #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);
            foreach (MovieFile p in this.library)
            {
                // create each movie folder
                string movieNewLocation = newWorkArea + "\\" + p.id;
                DiskIO.CreateDirectory(movieNewLocation);
                // add video files to copy
                allFilesToCopy.Add(new FileCopier(p.video.path, movieNewLocation + "\\" + DiskIO.GetFileName(p.video.path)));
                // change the file path to the new path for further library json saving
                p.video.path = DiskIO.GetFileName(p.video.path);
                // add trailer if exist
                if (!string.IsNullOrEmpty(p.trailer.path))
                {
                    allFilesToCopy.Add(new FileCopier(p.trailer.path, movieNewLocation + "\\" + DiskIO.GetFileName(p.trailer.path)));
                    p.trailer.path = DiskIO.GetFileName(p.trailer.path);
                }
                if (!string.IsNullOrEmpty(p.cover))
                {
                    // add video cover to copy
                    allFilesToCopy.Add(new FileCopier(p.cover, movieNewLocation + "\\cover.jpg"));
                    // change the cover path to the new path for further library json saving
                    p.cover = "\\cover.jpg";
                }
            }
            // save changed paths and music files into exported location
            this.SaveMovieLibraryAtLocation(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))
                {
                    VideoFolder temp = DiskIO.DeserializeVideoFolderFromFile(ContentLocation, abbriv);
                    foreach (MovieFile p in temp.library)
                    {
                        p.video.path = "\\" + DiskIO.GetFileName(p.video.path);
                        if (!string.IsNullOrEmpty(p.trailer.path))
                        {
                            p.trailer.path = "\\" + DiskIO.GetFileName(p.trailer.path);
                        }
                        if (!string.IsNullOrEmpty(p.cover))
                        {
                            p.cover = "\\cover.jpg";
                        }
                    }
                    DiskIO.SaveAsJSONFile(temp, newWorkArea, abbriv);
                }
            }
            return(allFilesToCopy.ToArray());
        }
Beispiel #3
0
        internal static List <MusicFile> DeserializeFilesFromJSON(string _fullPath, string _fileName)
        {
            Dictionary <string, List <MusicFile> > retVal = new Dictionary <string, List <MusicFile> >();

            if (DiskIO.IsFileExist(_fullPath, _fileName))
            {
                retVal = DiskIO.DeserializeTracksFromFile(_fullPath, _fileName);
            }
            return(retVal["tracks"]);
        }
Beispiel #4
0
        internal static SurveyFolder SerializeFromJSON(string _surLocation, string _surFolderName, string _fileName)
        {
            SurveyFolder retVal = new SurveyFolder(_surLocation, _surFolderName);

            if (DiskIO.IsFileExist(_surLocation + "\\" + _surFolderName, _fileName))
            {
                retVal = DiskIO.DeserializeSurveyFolderFromFile(_surLocation + "\\" + _surFolderName, _fileName);
            }
            retVal.SetLocationTitle(_surLocation, _surFolderName);
            return(retVal);
        }
Beispiel #5
0
        internal static VideoFolder SerializeFromJSON(string _videoLocation, string _videoFolderName, string _fileName)
        {
            VideoFolder retVal = new VideoFolder(_videoLocation, _videoFolderName);

            if (DiskIO.IsFileExist(_videoLocation + "\\" + _videoFolderName, _fileName))
            {
                retVal = DiskIO.DeserializeVideoFolderFromFile(_videoLocation + "\\" + _videoFolderName, _fileName);
            }
            retVal.SetLocationTitle(_videoLocation, _videoFolderName);
            return(retVal);
        }
Beispiel #6
0
        internal static PDFFolder SerializeFromJSON(string _pdfLocation, string _pdfFolderName, string _fileName)
        {
            PDFFolder retVal = new PDFFolder(_pdfLocation, _pdfFolderName);

            if (DiskIO.IsFileExist(_pdfLocation + "\\" + _pdfFolderName, _fileName))
            {
                retVal = DiskIO.DeserializePDFFolderFromFile(_pdfLocation + "\\" + _pdfFolderName, _fileName);
            }
            retVal.SetLocationTitle(_pdfLocation, _pdfFolderName);
            return(retVal);
        }
Beispiel #7
0
 public AudioFolder(string _location, string _title)
 {
     library  = new List <MusicPlaylist>();
     title    = _title;
     location = _location;
     if (DiskIO.IsFileExist(ContentLocation, "index.en.json"))
     {
         // go back
         //DiskIO.DeserializeObjectFromJSONFile(this, ContentLocation, "index.en.json");
     }
 }
Beispiel #8
0
        internal static bool IsValidProjectDirectory(string _pathTodirectory)
        {
            bool retVal = DiskIO.IsDirectoryExist(_pathTodirectory, "files") &&
                          DiskIO.IsFileExist(_pathTodirectory, "index.json") &&
                          DiskIO.IsDirectoryExist(_pathTodirectory + "\\" + "files", AUDIO_FOLDER_NAME) &&
                          DiskIO.IsDirectoryExist(_pathTodirectory + "\\" + "files", VIDEO_FOLDER_NAME) &&
                          DiskIO.IsDirectoryExist(_pathTodirectory + "\\" + "files", PDF_FOLDER_NAME) &&
                          DiskIO.IsDirectoryExist(_pathTodirectory + "\\" + "files", ANNOUNC_FOLDER_NAME);

            return(retVal);
        }
Beispiel #9
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());
        }
Beispiel #10
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);
        }
Beispiel #11
0
        internal void RemoveMovieNonEnglishData(int _id)
        {
            VideoFolder temp = new VideoFolder(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.DeserializeVideoFolderFromFile(ContentLocation, fileName);
                    temp.SetLocationTitle(this.location, this.title);
                    if (temp.HasMovieWithID(_id))
                    {
                        temp.RemoveMovieWithID(_id);
                    }
                    DiskIO.SaveAsJSONFile(temp, this.ContentLocation, fileName);
                }
            }
        }
Beispiel #12
0
        internal Dictionary <string, MovieFile> ReadNonEnglishDataLibrary(int _id)
        {
            Dictionary <string, MovieFile> retVal = new Dictionary <string, MovieFile>();
            VideoFolder temp = new VideoFolder(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.DeserializeVideoFolderFromFile(ContentLocation, fileName);
                    temp.SetLocationTitle(this.location, this.title);
                    if (temp.HasMovieWithID(_id))
                    {
                        retVal.Add(item.ToString(), temp.FindMovieWithID(_id));
                    }
                }
            }
            return(retVal);
        }