Ejemplo n.º 1
0
        public static string CreatePublish(TorrentInfo ti, PublishOptionsPacket pop)
        {
            string pt = "";

            switch (pop.PublishInfoTypeChoice)
            {
                case PublishInfoType.ExternalTemplate:
                    if (Directory.Exists(pop.TemplateLocation))
                    {
                        pt = ti.CreatePublishExternal(pop, new TemplateReader(pop.TemplateLocation, ti));
                    }
                    else if (Directory.Exists(ti.Media.TemplateLocation))
                    {
                        pt = ti.CreatePublishExternal(pop, new TemplateReader(ti.Media.TemplateLocation, ti));
                    }
                    else
                    {
                        pt = ti.CreatePublishInternal(pop);
                    }
                    break;

                case PublishInfoType.InternalTemplate:
                    pt = ti.CreatePublishInternal(pop);
                    break;

                case PublishInfoType.MediaInfo:
                    pt = ti.CreatePublishMediaInfo(pop);
                    break;
            }

            ti.Media.ReleaseDescription = Adapter.StripImg(pt).Trim();
            ;

            return pt;
        }
Ejemplo n.º 2
0
        public static string ToPublishString(TaskSettings ts, PublishOptions pop)
        {
            string pt = "";

            switch (pop.PublishInfoTypeChoice)
            {
            case PublishInfoType.ExternalTemplate:
                if (Directory.Exists(pop.TemplateLocation))
                {
                    pt = TorrentInfo.ToStringPublishExternal(pop, new TemplateReader(pop.TemplateLocation, ts));
                }
                else if (Directory.Exists(ts.Media.TemplateLocation))
                {
                    pt = TorrentInfo.ToStringPublishExternal(pop, new TemplateReader(ts.Media.TemplateLocation, ts));
                }
                else
                {
                    pt = TorrentInfo.ToStringPublishInternal(ts);
                }
                break;

            case PublishInfoType.InternalTemplate:
                pt = TorrentInfo.ToStringPublishInternal(ts);
                break;

            case PublishInfoType.MediaInfo:
                pt = TorrentInfo.ToStringPublishMediaInfo(ts);
                break;
            }

            ts.Media.ReleaseDescription = Adapter.StripImg(pt).Trim();
            ;

            return(pt);
        }
Ejemplo n.º 3
0
        public static string CreatePublish(TorrentInfo ti, PublishOptionsPacket pop)
        {
            string pt = "";

            switch (pop.PublishInfoTypeChoice)
            {
            case PublishInfoType.ExternalTemplate:
                if (Directory.Exists(pop.TemplateLocation))
                {
                    pt = ti.CreatePublish(pop, new TemplateReader2(pop.TemplateLocation, ti));
                }
                else if (Directory.Exists(ti.Media.TemplateLocation))
                {
                    pt = ti.CreatePublish(pop, new TemplateReader2(ti.Media.TemplateLocation, ti));
                }
                else
                {
                    pt = ti.CreatePublishInternal(pop);
                }
                break;

            case PublishInfoType.InternalTemplate:
                pt = ti.CreatePublishInternal(pop);
                break;

            case PublishInfoType.MediaInfo:
                pt = ti.CreatePublishMediaInfo(pop);
                break;
            }

            ti.Media.ReleaseDescription = Adapter.StripImg(pt).Trim();;

            return(pt);
        }
Ejemplo n.º 4
0
 private static void CreateScreenshots(TorrentInfo ti)
 {
     if (Directory.Exists(mScreenshotDir))
     {
         ti.CreateScreenshots(mScreenshotDir);
     }
     else
     {
         ti.CreateScreenshots();
     }
 }
Ejemplo n.º 5
0
        private static void CreatePublish(TorrentInfo ti)
        {
            PublishOptionsPacket pop = new PublishOptionsPacket()
            {
                AlignCenter = App.Settings.ProfileActive.AlignCenter,
                FullPicture = App.Settings.ProfileActive.UseFullPictureURL,
                PreformattedText = App.Settings.ProfileActive.PreText,
                PublishInfoTypeChoice = App.Settings.ProfileActive.Publisher,
                TemplateLocation = Path.Combine(App.TemplatesDir, "BTN")
            };
            ti.PublishString = Adapter.CreatePublish(ti, pop);

            Console.WriteLine(ti.PublishString);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Constructor of TemplateReader
        /// </summary>
        /// <param name="loc">Directory Path of the Template</param>
        /// <param name="ti">TorrentInfo object that has MediaInfo</param>
        public TemplateReader2(string loc, TorrentInfo ti)
        {
            this.Location        = loc;
            this.TorrentInfo     = ti;
            this.MappingHelperMy = new MappingHelper(ti.Media.Overall.Summary);
            // this.MappingHelperMy.ListFieldsAll();

            // Read the files in Location
            string[] files = Directory.GetFiles(loc, "*.txt", SearchOption.AllDirectories);
            foreach (string f in files)
            {
                using (StreamReader sw = new StreamReader(f))
                {
                    switch (Path.GetFileNameWithoutExtension(f))
                    {
                    case "Disc":
                        mDiscInfo = sw.ReadToEnd().Trim();
                        break;

                    case "DiscAudioInfo":
                        mDiscAudioInfo = sw.ReadToEnd().Trim();
                        break;

                    case "File":
                        mFileInfo = sw.ReadToEnd().Trim();
                        break;

                    case "FileAudioInfo":
                        mFileAudioInfo = sw.ReadToEnd().Trim();
                        break;

                    case "GeneralInfo":
                        mGeneralInfo = sw.ReadToEnd().Trim();
                        break;

                    case "FileVideoInfo":
                        mFileVideoInfo = sw.ReadToEnd().Trim();
                        break;

                    case "DiscVideoInfo":
                        mDiscVideoInfo = sw.ReadToEnd().Trim();
                        break;
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private static void CreateTorrent(TorrentInfo ti)
        {
            if (mTorrentCreate)
            {
                Helpers.CreateDirectoryIfNotExist(mTorrentsDir);
                ti.Media.TorrentCreateInfo = new TorrentCreateInfo(App.Settings.ProfileActive, mMediaLoc);
                if (Directory.Exists(mTorrentsDir))
                {
                    ti.Media.TorrentCreateInfo.TorrentFolder = mTorrentsDir;
                }
                ti.Media.TorrentCreateInfo.CreateTorrent();

                // create xml file
                if (mXmlCreate)
                {
                    string fp = Path.Combine(ti.Media.TorrentCreateInfo.TorrentFolder, MediaHelper.GetMediaName(ti.Media.TorrentCreateInfo.MediaLocation)) + ".xml";
                    FileSystem.GetXMLTorrentUpload(ti.Media).Write2(fp);
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Constructor of TemplateReader
        /// </summary>
        /// <param name="loc">Directory Path of the Template</param>
        /// <param name="ti">TorrentInfo object that has MediaInfo</param>
        public TemplateReader(string loc, TorrentInfo ti)
        {
            this.Location = loc;
            this.TorrentInfo = ti;
            TorrentInfo.Media.Info = new MappingHelper(ti.Media.Overall.Summary);
            // this.MappingHelperMy.ListFieldsAll();

            // Read the files in Location
            string[] files = Directory.GetFiles(loc, "*.txt", SearchOption.AllDirectories);
            foreach (string f in files)
            {
                using (StreamReader sw = new StreamReader(f))
                {
                    switch (Path.GetFileNameWithoutExtension(f))
                    {
                        case "Disc":
                            mDiscInfo = sw.ReadToEnd().Trim();
                            break;
                        case "DiscAudioInfo":
                            mDiscAudioInfo = sw.ReadToEnd().Trim();
                            break;
                        case "File":
                            mFileInfo = sw.ReadToEnd().Trim();
                            break;
                        case "FileAudioInfo":
                            mFileAudioInfo = sw.ReadToEnd().Trim();
                            break;
                        case "GeneralInfo":
                            mGeneralInfo = sw.ReadToEnd().Trim();
                            break;
                        case "FileVideoInfo":
                            mFileVideoInfo = sw.ReadToEnd().Trim();
                            break;
                        case "DiscVideoInfo":
                            mDiscVideoInfo = sw.ReadToEnd().Trim();
                            break;
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private string CreatePublishInitial(TorrentInfo ti)
        {
            PublishOptionsPacket pop = new PublishOptionsPacket();
            pop.AlignCenter = App.Settings.ProfileActive.AlignCenter;
            pop.FullPicture = ti.Media.Options.UploadScreenshots && App.Settings.ProfileActive.UseFullPictureURL;
            pop.PreformattedText = App.Settings.ProfileActive.PreText;
            pop.PublishInfoTypeChoice = App.Settings.ProfileActive.Publisher;
            ti.PublishOptions = pop;

            return Adapter.CreatePublish(ti, pop);
        }
Ejemplo n.º 10
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;
                }
                MediaInfo2 mi = new MediaInfo2(mwo, mMediaLoc);
                mi.ReadMedia();

                TorrentInfo ti = new TorrentInfo(mi);

                mi.Options.UploadScreenshots = mScreenshotsUpload;

                if (mScreenshotsUpload)
                {
                    CreateScreenshots(ti);
                    ti.UploadScreenshots();
                }
                else if (mScreenshotsCreate)
                {
                    CreateScreenshots(ti);
                }

                CreatePublish(ti);
                CreateTorrent(ti);
            }
        }
Ejemplo n.º 11
0
        private string CreatePublishInitial(TorrentInfo ti)
        {
            PublishOptionsPacket pop = new PublishOptionsPacket();
            pop.AlignCenter = Program.Settings.AlignCenter;
            pop.FullPicture = ti.Media.UploadScreenshots && Program.Settings.UseFullPicture;
            pop.PreformattedText = Program.Settings.PreText;
            pop.PublishInfoTypeChoice = Program.Settings.PublishInfoTypeChoice;
            ti.PublishOptions = pop;

            return Adapter.CreatePublish(ti, pop);
        }
Ejemplo n.º 12
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();
            }
        }