Example #1
0
        private static MediaWizardOptions ShowMediaWizard(ref MediaWizardOptions mwo, List <string> FileOrDirPaths)
        {
            MediaWizard mw = new MediaWizard(FileOrDirPaths);

            mwo.DialogResult = mw.ShowDialog();
            if (mwo.DialogResult == DialogResult.OK)
            {
                mwo = mw.Options;
            }
            mwo.PromptShown = true;
            return(mwo);
        }
Example #2
0
        private static void Main(string[] args)
        {
            string dirImages     = string.Empty;
            string dirRoot       = string.Empty;
            string mSettingsFile = string.Empty;
            string dirTorrents   = string.Empty;

            bool mFileCollection = false;
            bool mShowHelp       = false;

            var p = new OptionSet()
            {
                { "c", "Treat multiple files as a collection", v => mFileCollection = v != null },
                { "m|media=", "Location of the media file/folder", v => mMediaLoc = v },
                { "o|options=", "Location of the settings file", v => mSettingsFile = v },
                { "rd=", "Root directory for screenshots, torrent and all other output files. Overrides all other custom folders.", v => dirRoot = v },
                { "s", "Create and upload screenshots", v => mScreenshotsCreate = v != null },
                { "sd=", "Create screenshots in a custom folder and upload", v => dirImages = v },
                { "t", "Create torrent file in the parent folder of the media file", v => mTorrentCreate = v != null },
                { "td=", "Create torrent file in a custom folder", v => dirTorrents = v },
                { "x|xml", "Folder path of the XML torrent description file", v => mXmlCreate = v != null },
                { "h|help", "Show this message and exit", v => mShowHelp = v != null }
            };

            if (args.Length == 0)
            {
                mShowHelp = true;
            }

            // give cli the ability to replace environment variables
            string[] args2 = new string[args.Length];
            int      count = 0;

            foreach (string arg in args)
            {
                args2[count++] = arg.Replace("%appdata%", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
            }

            try
            {
                p.Parse(args2);

                // set root folder for images or set images dir if set one
                mScreenshotDir = Directory.Exists(dirRoot) ? dirRoot : dirImages;

                // set root folder for torrents or set torrents dir if set one
                mTorrentsDir = Directory.Exists(dirRoot) ? dirRoot : dirTorrents;
            }
            catch (Exception ex)
            {
                Console.Write("tdmakercli: ");
                Console.WriteLine(ex.Message);
                Console.WriteLine("Try 'tdmakercli --help' for more information.");
                return;
            }

            if (mShowHelp)
            {
                ShowHelp(p);
                return;
            }

            if (!File.Exists(mSettingsFile))
            {
                Program.AppConf = AppSettings.Read();
                mSettingsFile   = Program.AppConf.XMLSettingsFile;
            }

            if (File.Exists(mSettingsFile))
            {
                Program.conf = XMLSettingsCore.Read(mSettingsFile);
            }

            if (Program.conf != null)
            {
                Program.InitializeDefaultFolderPaths();
                Program.mtnProfileMgr = XMLSettingsMtnProfiles.Read();

                Console.WriteLine("Media location:");
                Console.WriteLine(mMediaLoc);
                Console.WriteLine();

                Console.WriteLine("Settings file");
                Console.WriteLine(mSettingsFile);
                Console.WriteLine();

                Console.WriteLine("MTN Path:");
                Console.WriteLine(Program.conf.MTNPath);
                Console.WriteLine();

                List <string> listFileOrDir = new List <string>()
                {
                    mMediaLoc
                };
                MediaWizardOptions mwo = Adapter.GetMediaType(listFileOrDir, true);
                if (mwo.MediaTypeChoice == MediaType.MediaIndiv && mFileCollection)
                {
                    mwo.MediaTypeChoice = MediaType.MediaCollection;
                }
                MediaInfo2 mi = new MediaInfo2(mwo.MediaTypeChoice, mMediaLoc);
                mi.ReadMedia();

                TorrentInfo ti = new TorrentInfo(mi);
                CreateScreenshot(ti);
                CreatePublish(ti);
                CreateTorrent(ti);
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to exit.");
            Console.ReadLine();
        }
Example #3
0
        private void AnalyzeMedia(List <string> files)
        {
            if (!ValidateInput())
            {
                return;
            }

            DialogResult        dlgResult        = DialogResult.OK;
            List <TaskSettings> taskSettingsList = new List <TaskSettings>();

            MediaWizardOptions mo = Adapter.GetMediaType(files);

            if (mo.ShowWizard)
            {
                ShowMediaWizard(ref mo, files);
            }

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

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

            if (dlgResult == DialogResult.OK)
            {
                if (mo.MediaTypeChoice == MediaType.MediaCollection)
                {
                    TaskSettings ts = new TaskSettings();
                    ts.MediaOptions = mo;

                    files.Sort();
                    string firstPath = files[0];
                    PrepareNewMedia(ts, File.Exists(firstPath) ? Path.GetDirectoryName(files[0]) : firstPath);
                    foreach (string p in files)
                    {
                        if (File.Exists(p))
                        {
                            ts.Media.FileCollection.Add(p);
                        }
                    }
                    taskSettingsList.Add(ts);
                }
                else
                {
                    foreach (string fd in files)
                    {
                        if (File.Exists(fd) || Directory.Exists(fd))
                        {
                            TaskSettings ts = new TaskSettings();
                            ts.MediaOptions = mo;

                            PrepareNewMedia(ts, fd);
                            ts.Media.DiscType = MediaHelper.GetSourceType(fd);

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

                            if (!string.IsNullOrEmpty(txtTitle.Text))
                            {
                                ts.Media.SetTitle(txtTitle.Text);
                            }

                            taskSettingsList.Add(ts);
                        }
                    }
                }

                foreach (TaskSettings ts in taskSettingsList)
                {
                    WorkerTask task = WorkerTask.CreateTask(ts);
                    task.UploadProgressChanged  += Task_UploadProgressChanged;
                    task.MediaLoaded            += Task_MediaLoaded;
                    task.StatusChanged          += Task_StatusChanged;
                    task.ScreenshotUploaded     += Task_ScreenshotUploaded;
                    task.TorrentInfoCreated     += Task_TorrentInfoCreated;
                    task.TorrentProgressChanged += Task_TorrentProgressChanged;
                    task.TaskCompleted          += Task_TaskCompleted;
                    TaskManager.Start(task);
                }

                UpdateGuiControls();
                pBar.Value = 0;
            }
        }
Example #4
0
        private static void Main(string[] args)
        {
            string dirImages         = string.Empty;
            string dirRoot           = string.Empty;
            string mSettingsFilePath = string.Empty;
            string dirTorrents       = string.Empty;

            bool mFileCollection = false;
            bool mShowHelp       = false;

            var p = new OptionSet()
            {
                { "c", "Treat multiple files as a collection", v => mFileCollection = v != null },
                { "m|media=", "Location of the media file/folder", v => mMediaLoc = v },
                { "o|options=", "Location of the settings file", v => mSettingsFilePath = v },
                { "rd=", "Root directory for screenshots, torrent and all other output files. Overrides all other custom folders.", v => dirRoot = v },
                { "s", "Create screenshots", v => mScreenshotsCreate = v != null },
                { "sd=", "Create screenshots in a custom folder and upload", v => dirImages = v },
                { "t", "Create torrent file in the parent folder of the media file", v => mTorrentCreate = v != null },
                { "td=", "Create torrent file in a custom folder", v => dirTorrents = v },
                { "u", "Upload screenshots", v => mScreenshotsUpload = v != null },
                { "x|xml", "Folder path of the XML torrent description file", v => mXmlCreate = v != null },
                { "h|help", "Show this message and exit", v => mShowHelp = v != null }
            };

            if (args.Length == 0)
            {
                mShowHelp = true;
            }

            // give cli the ability to replace environment variables
            string[] args2 = new string[args.Length];
            int      count = 0;

            foreach (string arg in args)
            {
                args2[count++] = arg.Replace("%appdata%", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
            }

            try
            {
                p.Parse(args2);

                // set root folder for images or set images dir if set one
                mScreenshotDir = Directory.Exists(dirRoot) ? dirRoot : dirImages;

                // set root folder for torrents or set torrents dir if set one
                mTorrentsDir = Directory.Exists(dirRoot) ? dirRoot : dirTorrents;
            }
            catch (Exception ex)
            {
                Console.Write("tdmakercli: ");
                Console.WriteLine(ex.Message);
                Console.WriteLine("Try 'tdmakercli --help' for more information.");
                return;
            }

            if (mShowHelp)
            {
                ShowHelp(p);
                return;
            }

            if (!File.Exists(mSettingsFilePath))
            {
                mSettingsFilePath = App.SettingsFilePath;
            }

            if (File.Exists(mSettingsFilePath))
            {
                App.Settings        = Settings.Load(mSettingsFilePath);
                App.UploadersConfig = UploadersConfig.Load(App.UploadersConfigPath);
            }

            if (App.Settings != null)
            {
                App.InitializeDefaultFolderPaths();

                List <string> listFileOrDir = new List <string>()
                {
                    mMediaLoc
                };
                MediaWizardOptions mwo = Adapter.GetMediaType(listFileOrDir, true);
                if (mwo.MediaTypeChoice == MediaType.MediaIndiv && mFileCollection)
                {
                    mwo.MediaTypeChoice = MediaType.MediaCollection;
                }

                TaskSettings ts = new TaskSettings();
                ts.MediaOptions.CreateScreenshots = mScreenshotsCreate;
                ts.MediaOptions.UploadScreenshots = mScreenshotsUpload;

                WorkerTask task = new WorkerTask(ts);
                MediaInfo2 mi   = new MediaInfo2(mwo, mMediaLoc);
                mi.ReadMedia();

                if (mScreenshotsUpload)
                {
                    TakeScreenshots(task);
                    task.UploadScreenshots();
                }
                else if (mScreenshotsCreate)
                {
                    TakeScreenshots(task);
                }

                //  CreatePublish(ti);
                //  CreateTorrent(ti);
            }
        }