public void AddMovieTorrent(Movie m) { dataset.MoviesTableRow row = data.MoviesTable.NewMoviesTableRow(); string[] information = m.GetMovieInformation(); row.BeginEdit(); row.File = information[11]; row.Movie_Title = information[0]; row.Year = information[1]; row.Save_Structure = information[13]; row.Sent = false; row.Source_Media = information[2]; row.Codec_Format = information[3]; row.File_Format = information[4]; row.File_Path = information[10]; row.Site_Origin = information[12]; row.EndEdit(); DataRow dr = data.TorrentsTable.Rows.Find(row.ID); while (dr != null) { row.ID++; dr = data.TorrentsTable.Rows.Find(row.ID); } data.MoviesTable.AddMoviesTableRow(row); }
public void Build(object files) { TorrentDataHandler data = new TorrentDataHandler(); List<Torrent> torrents = new List<Torrent>(); List<FileInfo> items = null; Torrent torrent; try { items = (List<FileInfo>)files; } catch { DirectoryHandler.LogError("Fatal Error converting object files to items in TorrentBuilder.Build");} information[14] = null; int filescount = items.Count; double progress = 0; double count = 0; foreach(FileInfo item in items) { string birth = GetTorrentBirth(item); if (birth == null) { string savefolder = null; string announce = null; try { object torrentdata = BEncoding.Decode(item); savefolder = (string)(((ListDictionary)((ListDictionary)torrentdata)["info"])["name"]); //Torrentdata is a LD containing LD, which contains name announce = (string)(((ListDictionary)torrentdata)["announce"]); announce = announce.Replace("http://", ""); announce = announce.Substring(0, announce.IndexOf(":")); } catch { savefolder = item.Name; } information[12] = (announce == null) ? "???" : announce; information[11] = item.Name; information[10] = item.FullName; information[13] = SettingsHandler.GetOtherDownloadDirectory() + savefolder; torrent = new Torrent(information); torrent.SetPath(DirectoryHandler.MoveTorrentFile(torrent)); data.AddOtherTorrent(torrent); } else if (birth == "ptp") { ProcessMovieTorrent(item, birth); Movie tm = new Movie(information); tm.SetPath(DirectoryHandler.MoveTorrentFile(tm)); data.AddMovieTorrent(tm); } else if (birth.Equals("waffles") || birth.Equals("what")) { ProcessMusicTorrent(item, birth); if (information[14] != "true") { if (SettingsHandler.GetDownloadFormatExists(information[2])) { torrent = VerifyMusicTorrent(); torrents.Add(torrent); torrent.SetPath(DirectoryHandler.MoveTorrentFile(torrent)); data.AddTorrent(torrent); } } } //Clear out information for this run to avoid misinformation on the next run for (int b = 0; b < information.Length; b++) information[b] = null; progress = (++count / filescount) * 100; if (progress <= 100 && progress >= 0) this.ReportProgress((int)progress); } ew.ClearApplyToAll(); }