Ejemplo n.º 1
0
        /// <summary>
        /// Create torrent with progress
        /// </summary>
        /// <param name="workerMy"></param>
        public void CreateTorrent(BackgroundWorker workerMy)
        {
            string p = this.MediaLocation;

            if (this.TrackerGroupActive != null)
            {
                if (File.Exists(p) || Directory.Exists(p))
                {
                    foreach (Tracker myTracker in this.TrackerGroupActive.Trackers)
                    {
                        MonoTorrent.Common.TorrentCreator tc = new MonoTorrent.Common.TorrentCreator();
                        tc.CreatedBy    = Application.ProductName;
                        tc.Private      = true;
                        tc.Comment      = MediaHelper.GetMediaName(p);
                        tc.Path         = p;
                        tc.PublisherUrl = "https://github.com/McoreD/TDMaker";
                        tc.Publisher    = Application.ProductName;
                        tc.StoreMD5     = false; // delays torrent creation
                        List <string> temp = new List <string>();
                        temp.Add(myTracker.AnnounceURL);
                        tc.Announces.Add(temp);

                        string torrentFileName = string.Format("{0} - {1}.torrent", (File.Exists(p) ? Path.GetFileName(p) : MediaHelper.GetMediaName(p)), myTracker.Name);
                        this.SetTorrentFilePath(torrentFileName);

                        ReportProgress(workerMy, ProgressType.UPDATE_STATUSBAR_DEBUG, string.Format("Creating {0}", this.TorrentFilePath));

                        tc.Hashed += delegate(object o, TorrentCreatorEventArgs e)
                        {
                            ReportProgress(workerMy, ProgressType.UPDATE_PROGRESSBAR_CUMULATIVE, e.OverallCompletion);
                        };

                        HelpersLib.Helpers.CreateDirectoryIfNotExist(this.TorrentFilePath);
                        tc.Create(this.TorrentFilePath);
                        ReportProgress(workerMy, ProgressType.UPDATE_STATUSBAR_DEBUG, string.Format("Created {0}", this.TorrentFilePath));
                    }
                }
            }
            else
            {
                Console.WriteLine("There were no active trackers configured to create a torrent.");
            }
        }
Ejemplo n.º 2
0
        public void CreateTorrent()
        {
            string p = Info.TaskSettings.Media.Location;

            if (Info.TaskSettings.Profile != null && Info.TaskSettings.Profile.Trackers != null && (File.Exists(p) || Directory.Exists(p)))
            {
                foreach (string tracker in Info.TaskSettings.Profile.Trackers)
                {
                    TorrentCreator tc = new TorrentCreator();
                    tc.CreatedBy    = Application.ProductName;
                    tc.Private      = true;
                    tc.Comment      = MediaHelper.GetMediaName(p);
                    tc.Path         = p;
                    tc.PublisherUrl = "https://github.com/McoreD/TDMaker";
                    tc.Publisher    = Application.ProductName;
                    tc.StoreMD5     = false; // delays torrent creation
                    List <string> temp = new List <string>();
                    temp.Add(tracker);
                    tc.Announces.Add(temp);

                    var    uri             = new Uri(tracker);
                    string torrentFileName = string.Format("{0}.torrent", (File.Exists(p) ? Path.GetFileNameWithoutExtension(p) : MediaHelper.GetMediaName(p)));
                    Info.TaskSettings.TorrentFilePath = Path.Combine(Path.Combine(Info.TaskSettings.TorrentFolder, uri.Host), torrentFileName);

                    ReportProgress(string.Format("Creating {0}", Info.TaskSettings.TorrentFilePath));

                    tc.Hashed += delegate(object o, TorrentCreatorEventArgs e)
                    {
                        Info.TorrentProgress = e.OverallCompletion;
                        OnTorrentProgressChanged();
                    };

                    Helpers.CreateDirectoryFromFilePath(Info.TaskSettings.TorrentFilePath);
                    tc.Create(Info.TaskSettings.TorrentFilePath);
                    ReportProgress(string.Format("Created {0}", Info.TaskSettings.TorrentFilePath));
                    Success = true;
                }
            }
            else
            {
                DebugHelper.WriteLine("There were no active trackers configured to create a torrent.");
            }
        }
Ejemplo n.º 3
0
        private void PrepareUserActionMsg(List <string> list_fd)
        {
            if (list_fd.Count == 1 && File.Exists(list_fd[0]))
            {
                lblUserActionMsg.Text        = "You are about to analyze a single file...";
                this.Options.MediaTypeChoice = MediaType.MediaIndiv;
                rbFilesAsIndiv.Checked       = true;
                gbQuestion.Enabled           = false;
            }
            else if (list_fd.Count == 1 && Directory.Exists(list_fd[0]))
            {
                SourceType src = MediaHelper.GetSourceType(list_fd[0]);
                switch (src)
                {
                case SourceType.Bluray:
                    lblUserActionMsg.Text        = "You are about to analyze a Blu-ray Disc...";
                    this.Options.MediaTypeChoice = MediaType.MediaDisc;
                    break;

                case SourceType.DVD:
                    lblUserActionMsg.Text        = "You are about to analyze a DVD...";
                    this.Options.MediaTypeChoice = MediaType.MediaDisc;
                    break;

                default:
                    lblUserActionMsg.Text        = "You are about to analyze a directory...";
                    this.Options.MediaTypeChoice = MediaType.MediaCollection;
                    break;
                }
            }
            else
            {
                this.Options.MediaTypeChoice = MediaType.MediaCollection;

                bool bDirFound  = false;
                bool bFileFound = false;
                int  dirCount   = 0;
                int  filesCount = 0;

                foreach (string fd in list_fd)
                {
                    if (Directory.Exists(fd))
                    {
                        dirCount++;
                        bDirFound = true;
                    }
                    else if (File.Exists(fd))
                    {
                        filesCount++;
                        bFileFound = true;
                    }
                    if (dirCount > 1)
                    {
                        break;
                    }
                }
                if (bDirFound && !bFileFound)
                {
                    if (dirCount > 1)
                    {
                        lblUserActionMsg.Text = "You are about to analyze a collection of directories...";
                    }
                }
                else // no dir found
                {
                    lblUserActionMsg.Text = "You are about to analyze a collection of files...";
                }
            }

            chkCreateTorrent.Checked     = Program.Settings.TorrentCreateAuto;
            chkScreenshotsCreate.Checked = Program.Settings.ScreenshotsUpload;
            gbQuestion.Enabled           = this.Options.MediaTypeChoice != MediaType.MediaDisc;
        }