Ejemplo n.º 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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        internal static VideoFolder DeserializeVideoFolderFromFile(string _path, string _name)
        {
            string      content = File.ReadAllText(_path + "\\" + _name);
            VideoFolder obj     = JsonConvert.DeserializeObject <VideoFolder>(content);

            return(obj);
        }
Ejemplo n.º 3
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());
        }
Ejemplo n.º 4
0
 public ProjectFolder(string _title, string _location)
 {
     this.title    = _title;
     this.location = _location;
     playlists     = new AudioFolder(ContentLocation, AUDIO_FOLDER_NAME);
     movies        = new VideoFolder(ContentLocation, VIDEO_FOLDER_NAME);
     articles      = new PDFFolder(ContentLocation, PDF_FOLDER_NAME);
     announces     = new VideoFolder(ContentLocation, ANNOUNC_FOLDER_NAME);
     questions     = new SurveyFolder(ContentLocation, SURVEY_FOLDER_NAME);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 6
0
        public ProjectFolder(string _mcmFilePath)
        {
            string mcmContent = DiskIO.ReadTextFile(_mcmFilePath);

            string[] tempArr = mcmContent.Split(';');
            this.title    = tempArr[0];
            this.location = tempArr[1];

            playlists = new AudioFolder(ContentLocation, AUDIO_FOLDER_NAME);
            playlists = AudioFolder.SerializeFromJSON(ContentLocation, AUDIO_FOLDER_NAME, "index.en.json");
            movies    = new VideoFolder(ContentLocation, VIDEO_FOLDER_NAME);
            movies    = VideoFolder.SerializeFromJSON(ContentLocation, VIDEO_FOLDER_NAME, "index.en.json");
            announces = new VideoFolder(ContentLocation, ANNOUNC_FOLDER_NAME);
            announces = VideoFolder.SerializeFromJSON(ContentLocation, ANNOUNC_FOLDER_NAME, "index.en.json");
            articles  = new PDFFolder(ContentLocation, PDF_FOLDER_NAME);
            articles  = PDFFolder.SerializeFromJSON(ContentLocation, PDF_FOLDER_NAME, "index.en.json");
            questions = new SurveyFolder(ContentLocation, SURVEY_FOLDER_NAME);
            questions = SurveyFolder.SerializeFromJSON(ContentLocation, SURVEY_FOLDER_NAME, "index.en.json");
        }
Ejemplo n.º 7
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);
                }
            }
        }
Ejemplo n.º 8
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);
        }