Beispiel #1
0
        public static bool Load()
        {
            bool ret = true;



            string syncFile = MyFile.EnsureDataFile("sync", Config.settings.exportExt, "sync");

            if (File.Exists(syncFile))
            {
                // load settings
                syncSettings = (SyncSettings)MyDeserialize.FromFile(Config.settings.exportFormat, syncFile, syncSettings);

                if (syncSettings.guid == null || syncSettings.about == null)
                {
                    syncSettings.Initialize();
                }
            }
            else
            {
                syncSettings.Initialize();
            }


            return(ret);
        }
Beispiel #2
0
        public VideoInfo ParseOtherHandrake(string fileFullName, VideoItemFile videoItemFile)
        {
            VideoInfo videoInfo = new VideoInfo();

            videoInfo.Initialize();

            string contents = MyFile.ReadAllText(fileFullName);

            if (String.IsNullOrEmpty(contents))
            {
                return(videoInfo);
            }

            Regex regexSize = new Regex(@"\+ Crop and Scale \(([0-9]{3,4}):([0-9]{3,4}):", RegexOptions.IgnoreCase);
            Match matchSize = regexSize.Match(contents);

            if (matchSize.Success && matchSize.Groups.Count == 3)
            {
                int width = 0;
                int.TryParse(matchSize.Groups[1].Value, out width);
                videoInfo.videoItem.encoding.width = width;
                int height = 0;
                int.TryParse(matchSize.Groups[2].Value, out height);
                videoInfo.videoItem.encoding.height = height;
            }

            if (contents.IndexOf("x264", StringComparison.OrdinalIgnoreCase) != -1)
            {
                videoInfo.videoItem.encoding.codec = "x264";
            }

            // hmm .. not alawys valid ..
            // Regex regexBitrate = new Regex(@"\+ bitrate ([0-9]{3,5}) kbps", RegexOptions.IgnoreCase);
            // so try summing all track instead
            int             bitrateVideoAudio = 0;
            Regex           regexBitrate      = new Regex(@"bytes, ([0-9]{3,5})\.[0-9]{2} kbps, fifo", RegexOptions.IgnoreCase);
            MatchCollection matchBitrates     = regexBitrate.Matches(contents);

            foreach (Match matchBitrate in matchBitrates)
            {
                if (matchBitrate.Success && matchBitrate.Groups.Count == 2)
                {
                    for (int index = matchBitrate.Groups.Count - 1; index >= 1; index--)
                    {
                        int bitrate = 0;
                        int.TryParse(matchBitrate.Groups[index].Value, out bitrate);
                        bitrateVideoAudio += bitrate;
                    }
                }
            }
            // MyLog.Add(videoItemFile.FullName + " bitrate : " + bitrateVideoAudio.ToString());
            if (bitrateVideoAudio > 100)
            {
                videoInfo.videoItem.encoding.bitrate = bitrateVideoAudio * 1024;
            }


            return(videoInfo);
        }
Beispiel #3
0
        protected bool LoadSelectedFilter()
        {
            if (comboBoxFilters.Items.Count == 0)
            {
                return(false);
            }
            if (subFormFilterForm == null)
            {
                return(false);
            }

            string filterName = comboBoxFilters.Text;

            if (filterName.Length == 0)
            {
                return(false);
            }
            if (filterName == "<_reset_>")
            {
                subFormFilterForm.ResetForm();
                return(true);
            }
            if (filterName == "<filter when closed>")
            {
                filterName = "filter when closed";
            }
            else if (filterName == "<last saved filter>")
            {
                filterName = "last saved filter";
            }

            FilterInfo filterInfo = new FilterInfo(); // subFormFilterForm.GetFilterForm();
            string     dataFile   = MyFile.EnsureDataFile("Filter", Config.settings.exportExt, "filters", filterName);

            // MessageBox.Show(dataFile);
            if (File.Exists(dataFile))
            {
                // load filter preset
                filterInfo = (FilterInfo)MyDeserialize.FromFile(Config.settings.exportFormat, dataFile, filterInfo);

                if (filterInfo == null)
                {
                    MessageBox.Show("Unable to load Filter [" + filterName + "]");
                    return(false);
                }

                subFormFilterForm.ResetForm();

                subFormFilterForm.SetFilterForm(filterInfo);
                MyLog.Add("Loaded Filter Preset " + dataFile.Replace(MyFile.exeDirectory, ""));

                return(true);
            }
            return(false);
        }
Beispiel #4
0
        protected void BackgroundWorkerScanSource_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // delete prior statsfile, if any, so stats will be re-calced
            string statsFile = MyFile.EnsureDataFile("stats", Config.settings.exportExt, "stats");

            if (statsFile != null)
            {
                MyFile.DeleteFile(statsFile);
            }
            VideoInfos_RunWorkerCompleted("scan", "Scanning done", sender, e);
        }
Beispiel #5
0
        private VideoItemFileInfo RunFileWaitForExit(VideoItemFileInfo videoItemFileInfo, DoWorkEventArgs doWorkEvent)
        {
            VideoItemFileInfo resultsVideoItemFileInfo = new VideoItemFileInfo();

            // Abort the operation if the user has canceled.
            // Note that a call to CancelAsync may have set
            // CancellationPending to true just after the
            // last invocation of this method exits, so this
            // code will not have the opportunity to set the
            // DoWorkEventArgs.Cancel flag to true. This means
            // that RunWorkerCompletedEventArgs.Cancelled will
            // not be set to true in your RunWorkerCompleted
            // event handler. This is a race condition.

            if (backgroundWorker.CancellationPending)
            {
                doWorkEvent.Cancel = true;
                resultsVideoItemFileInfo.elapsed       = 0;
                resultsVideoItemFileInfo.videoInfo     = null;
                resultsVideoItemFileInfo.videoItemFile = null;
                return(resultsVideoItemFileInfo);
            }

            Stopwatch stopwatch = Stopwatch.StartNew();

            percentComplete = 0;
            string playing = videoItemFileInfo.videoItemFile.Name;

            if (playing.Length > 30)
            {
                playing = playing.Substring(0, 30) + ".. ";
            }
            backgroundWorker.ReportProgress(percentComplete, "Playing\n" + playing + "..");

            FileInfo fileInfo = videoItemFileInfo.GetFileInfo();
            bool     ret      = MyFile.RunFile(fileInfo);

            percentComplete = 100;
            backgroundWorker.ReportProgress(percentComplete, "Finished playing\n" + playing);


            stopwatch.Stop();

            resultsVideoItemFileInfo.elapsed       = (long)Math.Floor((decimal)stopwatch.ElapsedMilliseconds / 1000);
            resultsVideoItemFileInfo.videoInfo     = videoItemFileInfo.videoInfo;
            resultsVideoItemFileInfo.videoItemFile = videoItemFileInfo.videoItemFile;

            // meh, so completed msg shows
            Thread.Sleep(500);

            return(resultsVideoItemFileInfo);
        }
        public static bool Load()
        {
            bool      ret       = false;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            // MyLog.Add("Loading VideoItemStats");

            string dataFile = MyFile.EnsureDataFile("stats", Config.settings.exportExt, "stats");

            if (dataFile == null)
            {
                return(false);
            }

            // keep a backup of settings
            if (File.Exists(dataFile))
            {
                videoInfoStats = new VideoInfoStats();
                videoInfoStats = (VideoInfoStats)MyDeserialize.FromFile(Config.settings.exportFormat, dataFile, videoInfoStats);

                string   fromFIle = "from " + dataFile.Replace(MyFile.exeDirectory, "");
                FileInfo fileInfo = MyFile.FileInfo(dataFile);
                if (fileInfo != null)
                {
                    fromFIle += " " + MyFile.FormatSize(fileInfo.Length);
                }
                MyLog.Add("Loaded VideoInfoStats " + fromFIle);

                if (videoInfoStats != null && videoInfoStats.year != null && videoInfoStats.year.Count() > 0)
                {
                    ret = true;
                }
            }
            else
            {
                // MyLog.Add("No VideoInfoStats to load ");
            }

            stopWatch.Stop();

            if (ret)
            {
                MyLog.AddElapsed(stopWatch.Elapsed);
            }

            return(ret);
        }
Beispiel #7
0
        private void toolStripMenuItemOpenFolder_Click(object sender, EventArgs e)
        {
            // item unselected, so ignore
            if (listView.SelectedItems.Count == 0)
            {
                return;
            }

            // grab first one
            ListViewItem selectedItem = listView.SelectedItems[0];

            VideoInfo videoInfo = (VideoInfo)selectedItem.Tag;

            MyFile.OpenDirectory(videoInfo.videoDirectory);
        }
        public static bool Save()
        {
            string dataFile = MyFile.EnsureDataFile("stats", Config.settings.exportExt, "stats");

            if (dataFile == null)
            {
                return(false);
            }

            MyLog.RotateFiles(dataFile);

            MySerialize.ToFile(Config.settings.exportFormat, dataFile, videoInfoStats);

            return(true);
        }
Beispiel #9
0
        public static bool Save()
        {
            string syncFile = MyFile.EnsureDataFile("sync", Config.settings.exportExt, "sync");

            if (syncFile == null)
            {
                return(false);
            }

            MyLog.RotateFiles(syncFile);

            // save new settings
            MySerialize.ToFile(Config.settings.exportFormat, syncFile, syncSettings);

            return(true);
        }
Beispiel #10
0
        public bool Play(VideoInfo videoInfo, VideoItemFile videoItemFile)
        {
            bool ret = false;
            // if playing video, mark video item as played/watched
            // TODO btr way to normalize if a file is a video file
            string fileExt = videoItemFile.Extension.TrimStart('.');

            switch (fileExt)
            {
            case "avi":
            case "m4v":
            case "mov":
            case "mpg":
            case "mkv":
            case "mp4":
            case "mpeg":
                // run as background so can wait w/o blocking ui
                // after X secs timeout, mark as played/watched
                // .. but requires UseShellEx = false which requires more config/settings to specify video player
                // so for now, meh runs as background thread w/o wait
                VideoItemFileInfo videoItemFileInfo = new VideoItemFileInfo();
                videoItemFileInfo.videoInfo     = videoInfo;
                videoItemFileInfo.videoItemFile = videoItemFile;
                backgroundWorkerOpenFile.Run(videoItemFileInfo);
                break;

            default:
                string   fullName = videoInfo.GetFullName(videoItemFile);
                FileInfo fileInfo = MyFile.FileInfo(fullName);
                if (fileInfo == null)
                {
                    // MessageBox.Show("Error trying to open file\n"+fullName+"\nView log for details");
                    ret = false;
                }
                else
                {
                    ret = MyFile.RunFile(fileInfo);
                }
                break;
            }

            return(ret);
        }
        private void buttonSourceBrowse_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

            if (textBoxDirectory.Text != "" && textBoxDirectory.Text.Length > 2)
            {
                folderBrowserDialog.SelectedPath = textBoxDirectory.Text;
            }

            if (folderBrowserDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            else
            {
                textBoxDirectory.Text = folderBrowserDialog.SelectedPath;
                if (textBoxAlias.Text == "")
                {
                    string alias = folderBrowserDialog.SelectedPath.Substring(folderBrowserDialog.SelectedPath.LastIndexOf(@"\") + 1);
                    MyFormField.SetTextBoxText(textBoxAlias, MyFile.SafeFileName(alias));
                }
            }
        }
Beispiel #12
0
        public bool DeleteFilter(string preset)
        {
            bool ret = false;

            if (MessageBox.Show("Delete Filter Preset [" + preset + "]", "Filter Preset", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                string dataFile = MyFile.EnsureDataFile("Filter", Config.settings.exportExt, "filters", preset);
                // MessageBox.Show(dataFile);
                if (MyFile.DeleteFile(dataFile))
                {
                    // MessageBox.Show("Deleted Filter Preset [" + preset + "]");
                    comboBoxFilters.Items.Remove(comboBoxFilters.SelectedItem);
                    LoadFilters();
                    // subFormFilterForm.ResetForm();
                    ret = true;
                }
                else
                {
                    MessageBox.Show("Error deleting Filter Preset [" + preset + "]");
                }
            }
            return(ret);
        }
Beispiel #13
0
        public static bool ThumbnailsAlreadySet()
        {
            List <VideoInfo> videoInfos = ListVideoInfo.GetList();
            int nbrThumbnails           = videoInfos.Where(x => x.files.posterThumbnail != null).Count();

            long thumbnailCachesize = MyFile.DirectorySize(@"cache\gallery", "poster*.jpg");

            bool thumbnailsSet;

            // if thumbnails set in list (nbrThumbnails > 0), but cache empty (thumbnailCachesize == 0)
            // assume intent is to rebuild app thumbnails, so thumbnailsSet = false

            // so thumbnails set only if set in list and set in cache
            if (nbrThumbnails > 0 && thumbnailCachesize > 0)
            {
                thumbnailsSet = true;
            }
            else
            {
                thumbnailsSet = false;
            }
            return(thumbnailsSet);
        }
Beispiel #14
0
        public bool LoadFilters()
        {
            // also ensures directory filter exists
            string dataFile = MyFile.EnsureDataFile("Filter", Config.settings.exportExt, "filters");

            IEnumerable <string> files = MyFile.EnumerateFiles("filters", "Filter_*." + Config.settings.exportExt);

            comboBoxFilters.SuspendLayout();

            comboBoxFilters.Items.Clear();
            comboBoxFilters.Items.Add("<_reset_>");
            comboBoxFilters.Items.Add("<filter when closed>");
            comboBoxFilters.Items.Add("<last saved filter>");
            comboBoxFilters.SelectedIndex = 0;
            if (files.Count() > 0)
            {
                Regex regexIgnoreBackups = new Regex(@"\.[0-9]\." + Config.settings.exportExt);
                foreach (string file in files)
                {
                    if (regexIgnoreBackups.IsMatch(file))
                    {
                        continue;
                    }
                    string filterName = file.Replace(@"filters\", "");
                    filterName = filterName.Replace(@"." + Config.settings.exportExt, "");
                    filterName = filterName.Replace(@"Filter_", "");
                    if (filterName == "_reset_" || filterName == "filter when closed" || filterName == "last saved filter")
                    {
                        continue;
                    }
                    comboBoxFilters.Items.Add(filterName);
                }
            }

            comboBoxFilters.ResumeLayout();
            return(true);
        }