Example #1
0
        private void LoadMedia(string[] ps)
        {
            if (1 == ps.Length)
            {
                txtTitle.Text = MediaHelper.GetMediaName(ps[0]);
                GuessSource(txtTitle.Text);
            }

            if (!App.Settings.ProfileActive.WritePublish && ps.Length > 1)
            {
                if (MessageBox.Show(Resources.MainWindow_LoadMedia_, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    App.Settings.ProfileActive.WritePublish = true;
                }
            }

            List<TorrentCreateInfo> tps = new List<TorrentCreateInfo>();

            foreach (string p in ps)
            {
                if (File.Exists(p) || Directory.Exists(p))
                {
                    DebugHelper.WriteLine(string.Format("Queued {0} to create a torrent", p));
                    lbFiles.Items.Add(p);
                    TorrentCreateInfo tp = new TorrentCreateInfo(App.Settings.ProfileActive, p);
                    tps.Add(tp);

                    UpdateGuiControls();
                }
            }

            if (App.Settings.AnalyzeAuto)
            {
                WorkerTask wt = new WorkerTask(bwApp, TaskType.ANALYZE_MEDIA);
                wt.FileOrDirPaths = new List<string>(ps);
                AnalyzeMedia(wt);
            }
        }
Example #2
0
 private void btnAnalyze_Click(object sender, EventArgs e)
 {
     string[] files = new string[lbFiles.Items.Count];
     for (int i = 0; i < lbFiles.Items.Count; i++)
     {
         files[i] = lbFiles.Items[i].ToString();
     }
     WorkerTask wt = new WorkerTask(bwApp, TaskType.ANALYZE_MEDIA);
     wt.FileOrDirPaths = new List<string>(files);
     this.AnalyzeMedia(wt);
 }
Example #3
0
        private void CreateTorrentButton()
        {
            if (!bwApp.IsBusy)
            {
                List<TorrentCreateInfo> tps = new List<TorrentCreateInfo>();
                List<TorrentInfo> tiList = new List<TorrentInfo>();
                foreach (TorrentInfo ti in lbPublish.SelectedItems)
                {
                    tps.Add(new TorrentCreateInfo(App.Settings.ProfileActive, ti.Media.Location));
                    tiList.Add(ti);
                }
                if (tps.Count > 0)
                {
                    var wt = new WorkerTask(bwApp, TaskType.CREATE_TORRENT);
                    wt.MediaList = tiList;
                    wt.TorrentPackets = tps;
                    bwApp.RunWorkerAsync(wt);

                    btnCreateTorrent.Enabled = false;
                }
            }
        }
Example #4
0
        private WorkerTask WorkerAnalyzeMedia(WorkerTask wt)
        {
            App.LoadProxySettings();

            bwApp.ReportProgress((int)ProgressType.UPDATE_PROGRESSBAR_MAX, wt.MediaList.Count);

            foreach (TorrentInfo ti in wt.MediaList)
            {
                MediaInfo2 mi = ti.Media;

                bwApp.ReportProgress((int)ProgressType.UPDATE_STATUSBAR_DEBUG, "Reading " + Path.GetFileName(mi.Location) + " using MediaInfo...");

                if (mi.DiscType != SourceType.Bluray)
                {
                    mi.ReadMedia();
                    bwApp.ReportProgress((int)ProgressType.REPORT_MEDIAINFO_SUMMARY, mi);
                }

                // creates screenshot
                if (wt.MediaOptions.UploadScreenshots)
                {
                    ti.CreateScreenshots();
                    ti.UploadScreenshots();
                }
                else if (wt.MediaOptions.CreateScreenshots)
                {
                    ti.CreateScreenshots();
                }

                ti.PublishString = CreatePublishInitial(ti);
                bwApp.ReportProgress((int)ProgressType.REPORT_TORRENTINFO, ti);

                if (App.Settings.ProfileActive.WritePublish)
                {
                    // create textFiles of MediaInfo
                    string txtPath = Path.Combine(mi.TorrentCreateInfo.TorrentFolder, mi.Overall.FileName) + ".txt";

                    Helpers.CreateDirectoryIfNotExist(mi.TorrentCreateInfo.TorrentFolder);

                    using (StreamWriter sw = new StreamWriter(txtPath))
                    {
                        sw.WriteLine(ti.PublishString);
                    }
                }

                if (wt.MediaOptions.CreateTorrent)
                {
                    mi.TorrentCreateInfo.CreateTorrent(bwApp);
                }

                if (App.Settings.ProfileActive.XMLTorrentUploadCreate)
                {
                    string fp = Path.Combine(mi.TorrentCreateInfo.TorrentFolder, MediaHelper.GetMediaName(mi.TorrentCreateInfo.MediaLocation)) + ".xml";
                    FileSystem.GetXMLTorrentUpload(mi).Write2(fp);
                }

                bwApp.ReportProgress((int)ProgressType.INCREMENT_PROGRESS_WITH_MSG, mi.Title);
            }

            return wt;
        }
Example #5
0
        private object WorkerCreateTorrents(WorkerTask wt)
        {
            try
            {
                foreach (TorrentInfo ti in wt.MediaList)
                {
                    TorrentCreateInfo tci = ti.Media.TorrentCreateInfo;
                    tci.CreateTorrent(wt.MyWorker);
                    if (App.Settings.ProfileActive.XMLTorrentUploadCreate)
                    {
                        string fp = Path.Combine(tci.TorrentFolder, MediaHelper.GetMediaName(tci.MediaLocation)) + ".xml";
                        FileSystem.GetXMLTorrentUpload(ti.Media).Write(fp);
                    }
                }
            }
            catch (Exception ex)
            {
                bwApp.ReportProgress((int)ProgressType.UPDATE_STATUSBAR_DEBUG, ex.Message);
            }

            return null;
        }
Example #6
0
        private void AnalyzeMedia(WorkerTask wt)
        {
            if (!ValidateInput()) return;

            DialogResult dlgResult = DialogResult.OK;
            List<MediaInfo2> miList = new List<MediaInfo2>();

            MediaWizardOptions mwo = Adapter.GetMediaType(wt.FileOrDirPaths);

            if (mwo.ShowWizard)
            {
                ShowMediaWizard(ref mwo, wt.FileOrDirPaths);
            }

            wt.MediaOptions = mwo;
            if (mwo.PromptShown)
            {
                wt.MediaOptions = mwo;
                dlgResult = mwo.DialogResult;
            }
            else
            {
                // fill previous settings
                wt.MediaOptions.CreateTorrent = App.Settings.ProfileActive.CreateTorrent;
                wt.MediaOptions.CreateScreenshots = App.Settings.ProfileActive.CreateScreenshots;
                wt.MediaOptions.UploadScreenshots = App.Settings.ProfileActive.UploadScreenshots;
            }

            if (!mwo.PromptShown && App.Settings.ShowMediaWizardAlways)
            {
                MediaWizard mw = new MediaWizard(wt);
                dlgResult = mw.ShowDialog();
                if (dlgResult == DialogResult.OK)
                {
                    wt.MediaOptions = mw.Options;
                }
            }

            if (dlgResult == DialogResult.OK)
            {
                if (wt.MediaOptions.MediaTypeChoice == MediaType.MediaCollection)
                {
                    wt.FileOrDirPaths.Sort();
                    string firstPath = wt.FileOrDirPaths[0];
                    MediaInfo2 mi = this.PrepareNewMedia(wt, File.Exists(firstPath) ? Path.GetDirectoryName(wt.FileOrDirPaths[0]) : firstPath);
                    foreach (string p in wt.FileOrDirPaths)
                    {
                        if (File.Exists(p))
                        {
                            mi.FileCollection.Add(p);
                        }
                    }
                    miList.Add(mi);
                }
                else
                {
                    foreach (string fd in wt.FileOrDirPaths)
                    {
                        if (File.Exists(fd) || Directory.Exists(fd))
                        {
                            MakeGuiReadyForAnalysis();

                            MediaInfo2 mi = this.PrepareNewMedia(wt, fd);

                            mi.DiscType = MediaHelper.GetSourceType(fd);

                            if (mi.DiscType == SourceType.Bluray)
                            {
                                mi.Overall = new MediaFile(FileSystemHelper.GetLargestFilePathFromDir(fd), cboSource.Text);
                                mi.Overall.Summary = BDInfo(fd);
                            }

                            if (wt.IsSingleTask() && !string.IsNullOrEmpty(txtTitle.Text))
                            {
                                mi.SetTitle(txtTitle.Text);
                            }
                            miList.Add(mi);
                        }
                    }
                }

                // Attach the MediaInfo2 object in to TorrentInfo
                var tiList = miList.Select(mi => new TorrentInfo(bwApp, mi)).ToList();
                wt.MediaList = tiList;

                if (!bwApp.IsBusy)
                {
                    bwApp.RunWorkerAsync(wt);
                }

                UpdateGuiControls();
            }
        }
Example #7
0
        private MediaInfo2 PrepareNewMedia(WorkerTask wt, string p)
        {
            MediaType mt = wt.MediaOptions.MediaTypeChoice;
            MediaInfo2 mi = new MediaInfo2(wt.MediaOptions, p);
            mi.Extras = cboExtras.Text;
            if (cboSource.Text == "DVD")
            {
                mi.Source = Adapter.GetDVDString(p);
            }
            else
            {
                mi.Source = cboSource.Text;
            }
            mi.Menu = cboDiscMenu.Text;
            mi.Authoring = cboAuthoring.Text;
            mi.WebLink = txtWebLink.Text;
            mi.TorrentCreateInfo = new TorrentCreateInfo(App.Settings.ProfileActive, p);

            if (App.Settings.ProfileActive.Publisher == PublishInfoType.ExternalTemplate)
            {
                mi.TemplateLocation = Path.Combine(App.TemplatesDir, App.Settings.ProfileActive.PublisherExternalTemplateName);
            }

            return mi;
        }
Example #8
0
        public static WorkerTask CreateTask(TaskSettings ts)
        {
            WorkerTask task = new WorkerTask(ts);

            return(task);
        }
Example #9
0
 public MediaWizard(WorkerTask wt)
     : this()
 {
     PrepareUserActionMsg(wt.FileOrDirPaths);
 }
Example #10
0
        private void LoadMedia(string[] ps)
        {
            if (1 == ps.Length)
            {
                txtTitle.Text = MediaHelper.GetMediaName(ps[0]);
            }

            if (!Program.Settings.WritePublish && ps.Length > 1)
            {
                if (MessageBox.Show("Writing Publish info to File is recommended when analysing multiple files or folders. \n\nWould you like to turn this feature on?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Program.Settings.WritePublish = true;
                }
            }

            List<TorrentCreateInfo> tps = new List<TorrentCreateInfo>();

            foreach (string p in ps)
            {
                if (File.Exists(p) || Directory.Exists(p))
                {
                    // txtMediaLocation.Text = p;
                    FileSystem.AppendDebug(string.Format("Queued {0} to create a torrent", p));
                    lbFiles.Items.Add(p);
                    TorrentCreateInfo tp = new TorrentCreateInfo(GetTracker(), p);
                    tps.Add(tp);

                    UpdateGuiControls();
                }
            }

            if (Program.Settings.AnalyzeAuto)
            {
                WorkerTask wt = new WorkerTask(bwApp, TaskType.ANALYZE_MEDIA);
                wt.FileOrDirPaths = new List<string>(ps);
                AnalyzeMedia(wt);
            }
        }
Example #11
0
        private void AnalyzeMedia(WorkerTask wt)
        {
            if (!ValidateInput()) return;

            DialogResult dlgResult = DialogResult.OK;
            List<MediaInfo2> miList = new List<MediaInfo2>();

            MediaWizardOptions mwo = Adapter.GetMediaType(wt.FileOrDirPaths);

            wt.MediaTypeChoice = mwo.MediaTypeChoice;
            if (mwo.PromptShown)
            {
                wt.TorrentCreateAuto = mwo.CreateTorrent;
                wt.UploadScreenshot = mwo.ScreenshotsInclude;
                dlgResult = mwo.DialogResultMy;
            }
            else
            {
                // fill previous settings
                wt.TorrentCreateAuto = Program.Settings.TorrentCreateAuto;
                wt.UploadScreenshot = Program.Settings.ScreenshotsUpload;
            }

            if (!mwo.PromptShown && Program.Settings.ShowMediaWizardAlways)
            {
                MediaWizard mw = new MediaWizard(wt);
                dlgResult = mw.ShowDialog();
                if (dlgResult == DialogResult.OK)
                {
                    wt.TorrentCreateAuto = mw.Options.CreateTorrent;
                    wt.UploadScreenshot = mw.Options.ScreenshotsInclude;
                    wt.MediaTypeChoice = mw.Options.MediaTypeChoice;
                }
            }

            if (dlgResult == DialogResult.OK)
            {
                if (wt.MediaTypeChoice == MediaType.MediaCollection)
                {
                    wt.FileOrDirPaths.Sort();
                    string firstPath = wt.FileOrDirPaths[0];
                    MediaInfo2 mi = this.PrepareNewMedia(wt, File.Exists(firstPath) ? Path.GetDirectoryName(wt.FileOrDirPaths[0]) : firstPath);
                    foreach (string p in wt.FileOrDirPaths)
                    {
                        if (File.Exists(p))
                        {
                            mi.FileCollection.Add(p);
                        }
                    }
                    miList.Add(mi);
                }
                else
                {
                    foreach (string fd in wt.FileOrDirPaths)
                    {
                        if (File.Exists(fd) || Directory.Exists(fd))
                        {
                            MakeGUIReadyForAnalysis();

                            MediaInfo2 mi = this.PrepareNewMedia(wt, fd);

                            mi.DiscType = MediaHelper.GetSourceType(fd);

                            if (mi.DiscType == SourceType.Bluray)
                            {
                                mi.Overall = new MediaFile(FileSystemHelper.GetLargestFilePathFromDir(fd), cboSource.Text);
                                mi.Overall.Summary = BDInfo(fd);
                            }

                            if (wt.IsSingleTask() && !string.IsNullOrEmpty(txtTitle.Text))
                            {
                                mi.SetTitle(txtTitle.Text);

                                // if it is a DVD, set the title to be name of the folder.
                                this.Text = string.Format("{0} - {1}", Program.GetProductName(), MediaHelper.GetMediaName(mi.Location));
                            }
                            miList.Add(mi);
                        }
                    }
                }

                // Attach the MediaInfo2 object in to TorrentInfo
                List<TorrentInfo> tiList = new List<TorrentInfo>();
                foreach (MediaInfo2 mi in miList)
                {
                    TorrentInfo ti = new TorrentInfo(bwApp, mi);
                    tiList.Add(ti);
                }
                wt.MediaList = tiList;

                if (!bwApp.IsBusy)
                {
                    bwApp.RunWorkerAsync(wt);
                }

                UpdateGuiControls();
            }
        }
Example #12
0
        private List<TorrentInfo> WorkerAnalyzeMedia(WorkerTask wt)
        {
            Program.LoadProxySettings();

            List<TorrentInfo> tiListTemp = wt.MediaList;

            bwApp.ReportProgress((int)ProgressType.UPDATE_PROGRESSBAR_MAX, tiListTemp.Count);

            foreach (TorrentInfo ti in tiListTemp)
            {
                MediaInfo2 mi = ti.Media;

                bwApp.ReportProgress((int)ProgressType.UPDATE_STATUSBAR_DEBUG, "Reading " + Path.GetFileName(mi.Location) + " using MediaInfo...");

                if (mi.DiscType != SourceType.Bluray)
                {
                    mi.ReadMedia();
                    bwApp.ReportProgress((int)ProgressType.REPORT_MEDIAINFO_SUMMARY, mi);
                }

                // creates screenshot
                mi.UploadScreenshots = wt.UploadScreenshot;
                if (wt.UploadScreenshot)
                {
                    ti.CreateUploadScreenshots();
                }

                ti.PublishString = CreatePublishInitial(ti);
                bwApp.ReportProgress((int)ProgressType.REPORT_TORRENTINFO, ti);

                if (Program.Settings.WritePublish)
                {
                    // create textFiles of MediaInfo
                    string txtPath = Path.Combine(mi.TorrentCreateInfoMy.TorrentFolder, mi.Overall.FileName) + ".txt";

                    if (!Directory.Exists(mi.TorrentCreateInfoMy.TorrentFolder))
                    {
                        Directory.CreateDirectory(mi.TorrentCreateInfoMy.TorrentFolder);
                    }

                    using (StreamWriter sw = new StreamWriter(txtPath))
                    {
                        sw.WriteLine(ti.PublishString);
                    }
                }

                if (wt.TorrentCreateAuto)
                {
                    mi.TorrentCreateInfoMy.CreateTorrent(bwApp);
                }

                if (Program.Settings.XMLTorrentUploadCreate)
                {
                    string fp = Path.Combine(mi.TorrentCreateInfoMy.TorrentFolder, MediaHelper.GetMediaName(mi.TorrentCreateInfoMy.MediaLocation)) + ".xml";
                    FileSystem.GetXMLTorrentUpload(mi).Write2(fp);
                }

                bwApp.ReportProgress((int)ProgressType.INCREMENT_PROGRESS_WITH_MSG, mi.Title);
            }

            return tiListTemp;
        }
Example #13
0
        /// <summary>
        /// Gets new MediaInfo2 object from settings based on GUI Controls
        /// </summary>
        /// <param name="p">File or Folder path of the Media</param>
        /// <returns>MediaInfo2 object</returns>
        private MediaInfo2 PrepareNewMedia(WorkerTask wt, string p)
        {
            MediaType mt = wt.MediaTypeChoice;
            MediaInfo2 mi = new MediaInfo2(mt, p);
            mi.Extras = cboExtras.Text;
            if (cboSource.Text == "DVD")
            {
                mi.Source = Adapter.GetDVDString(p);
            }
            else
            {
                mi.Source = cboSource.Text;
            }
            mi.Menu = cboDiscMenu.Text;
            mi.Authoring = cboAuthoring.Text;
            mi.WebLink = txtWebLink.Text;
            mi.TorrentCreateInfoMy = new TorrentCreateInfo(GetTracker(), p);

            if (Program.Settings.PublishInfoTypeChoice == PublishInfoType.ExternalTemplate)
            {
                mi.TemplateLocation = Path.Combine(Program.TemplatesDir, cboTemplate.Text);
            }

            return mi;
        }
Example #14
0
 public MediaWizard(WorkerTask wt)
     : this()
 {
     PrepareUserActionMsg(wt.FileOrDirPaths);
 }