コード例 #1
0
        public void StartSearch()
        {
            MyTorrents.Instance().torrentList.Visible = false;
            TorrentEngine.Instance().SearchCompleted += new SearchCompleted(_torrentEngine_SearchCompleted);
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);

            keyboard.Reset();

            keyboard.Text = SearchString == null ? "" : SearchString;
            keyboard.DoModal(GUIWindowManager.ActiveWindow);

            if (!keyboard.IsConfirmed)
            {
                MyTorrents.Instance().torrentList.Visible = true;
                MyTorrents.ListType = "Torrents";
                return;
            }

            SearchString = keyboard.Text;

            GUIDialogMenu dlgMenu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlgMenu == null)
            {
                return;
            }

            dlgMenu.Reset();

            dlgMenu.SetHeading("Which engine to use?");
            TorrentSearchEngine tse = null;

            try
            {
                tse = new TorrentSearchEngine(Configuration.Instance().Settings["TorrentSearch.Config"] as string);
            }
            catch
            {
                Log.Instance().Print("MyTorrents.xml config file loading failed!");
            }
            foreach (ITorrentSearch engine in tse.Engines)
            {
                GUIListItem listItem = new GUIListItem();
                listItem.Label = engine.Name;
                dlgMenu.Add(listItem);
            }
            dlgMenu.DoModal(GUIWindowManager.ActiveWindow);
            if (dlgMenu.SelectedLabel == -1)
            {
                MyTorrents.Instance().torrentList.Visible = true;
                MyTorrents.ListType = "Torrents";
                return;
            }
            _searchEngine = tse.Engines[dlgMenu.SelectedLabel];
            MyTorrents.Instance().torrentList.Clear();
            MyTorrents.Instance().torrentList.Visible = true;
            MyTorrents.Instance().torrentList.ListItems = SearchResults;

            UpdateSearchResults("Default");//
        }
コード例 #2
0
        public List <GUIListItem> UpdateWatches()
        {
            if (MyTorrents.Instance()._torrentWatchlist.MPTVSeriesWorker.IsBusy == true)
            {
                GUIWaitCursor.Init();
                GUIWaitCursor.Show();
            }
            //GUIPropertyManager.SetProperty("#MyTorrents.Count", String.Format("{0}", _torrentWatchlist.WatchList.Count));
            torrentList.Clear();

            foreach (WatchItem watch in MyTorrents.Instance()._torrentWatchlist._watchItemList)
            {
                GUIListItem item = new GUIListItem();
                item.Label        = watch.GetLabel1();
                item.Label2       = watch.GetLabel2();
                item.AlbumInfoTag = watch;
                torrentList.Add(item);
            }

            if (torrentList.Count == 0)
            {
                GUIListItem item = new GUIListItem();
                item.Label = "No watchlist items.";
                torrentList.Add(item);
            }
            return(torrentList);
        }
コード例 #3
0
        public void AddSeries()
        {
            GUIDialogMenu dialog = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dialog == null)
            {
                return;
            }

            dialog.Reset();
            dialog.SetHeading("Choose TV Series to add");
            foreach (Series s in MyTorrents.Instance()._torrentWatchlist.allseries)
            {
                dialog.Add(s.Name);
            }
            dialog.DoModal(GUIWindowManager.ActiveWindow);

            if (dialog.SelectedId != -1)
            {
                SeriesItem item         = new SeriesItem();
                Series     chosenseries = MyTorrents.Instance()._torrentWatchlist.allseries[dialog.SelectedId - 1];
                item.quality           = "720p";
                item.source            = "HDTV";
                item.type              = "New episodes";
                item.show              = new Series();
                item.show.Name         = chosenseries.Name;
                item.show.OriginalName = chosenseries.OriginalName;
                item.show.ID           = chosenseries.ID;
                item.tracker           = "PublicHD";
                MyTorrents.Instance()._torrentWatchlist._watchItemList.Add(item);
            }
        }
コード例 #4
0
        public void SelectQuality(SeriesItem item)
        {
            GUIDialogMenu dialog = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dialog == null)
            {
                return;
            }

            dialog.Reset();
            dialog.SetHeading("Choose Resolution");
            dialog.Add("SD");
            dialog.Add("720p");
            dialog.Add("1080i");
            dialog.Add("1080p");
            dialog.Add("480p");

            dialog.DoModal(GUIWindowManager.ActiveWindow);

            if (dialog.SelectedId != -1)
            {
                MyTorrents.Instance()._torrentWatchlist.GetSeriesList().Where(e => e.show.ID == item.show.ID).First().quality = dialog.SelectedLabelText;

                GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.Quality", dialog.SelectedLabelText);
            }
        }
コード例 #5
0
        public void SelectSource(SeriesItem item)
        {
            GUIDialogMenu dialog = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dialog == null)
            {
                return;
            }

            dialog.Reset();
            dialog.SetHeading("Choose Source");
            dialog.Add("HDTV");
            dialog.Add("VHSRip");
            dialog.Add("TVRip");
            dialog.Add("DVDRip");
            dialog.Add("BDRip");
            dialog.Add("BluRay");
            dialog.Add("WEB");
            dialog.Add("DVD");

            dialog.DoModal(GUIWindowManager.ActiveWindow);

            if (dialog.SelectedId != -1)
            {
                MyTorrents.Instance()._torrentWatchlist.GetSeriesList().Where(e => e.show.ID == item.show.ID).First().source = dialog.SelectedLabelText;

                GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.Source", dialog.SelectedLabelText);
            }
        }
コード例 #6
0
        public void SelectTracker(SeriesItem item)
        {
            GUIDialogMenu dialog = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dialog == null)
            {
                return;
            }

            dialog.Reset();
            dialog.SetHeading("Choose TV Series to add");
            TorrentSearchEngine tse = null;

            try
            {
                tse = new TorrentSearchEngine(Configuration.Instance().Settings["TorrentSearch.Config"] as string);
            }
            catch
            {
                Log.Instance().Print("MyTorrents.xml config file loading failed!");
            }
            foreach (ITorrentSearch engine in tse.Engines)
            {
                dialog.Add(engine.Name);
            }
            dialog.DoModal(GUIWindowManager.ActiveWindow);

            if (dialog.SelectedId != -1)
            {
                MyTorrents.Instance()._torrentWatchlist.GetSeriesList().Where(e => (e as SeriesItem).show.ID == item.show.ID).First().tracker = dialog.SelectedLabelText;

                GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.Tracker", dialog.SelectedLabelText);
            }
        }
コード例 #7
0
        public override bool Init()
        {
            _config   = Configuration.Instance().LoadConfiguration();
            _instance = this;
            LoadTorrentWatch();
            _icons.LoadIconMappings(_config);
            ViewRSS.LoadRssChannels(_config);
            StartRss();
            //RSSChannelManager.Instance().RSSChannelUpdated += new RSSChannelUpdated(_RSSUpdated);
            InitWindowSpy();

            if (EstablishConnection(_config))
            {
                Log.Instance().Print("connection established");
            }
            else
            {
                Log.Instance().Print("connection is not established");
            }
            if (_config.Notify)
            {
                Notifier.Initialize();
            }
            base.Init();

            return(Load(System.IO.Path.Combine(GUIGraphicsContext.Skin, @"MP-MyTorrents.xml")));
        }
コード例 #8
0
        public void FolderClickMenu(GUIListItem fldr, GUIListItem _selectedtorrent, TorrentLabel label)
        {
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading("Folder Options");
            dlg.Add("Set as download location");
            //dlg.Add("Add to favourite places");
            dlg.DoModal(GUIWindowManager.ActiveWindow);

            switch (dlg.SelectedLabelText)
            {
            case "Set as download location":
            {
                MyTorrents.Instance().HideFolderBrowser();

                if (MyTorrents.ListType == "SeriesInfo")
                {
                    SeriesItem item = _selectedtorrent.AlbumInfoTag as SeriesItem;

                    MyTorrents.Instance()._torrentWatchlist.GetSeriesList().Where(e => e.show.ID == item.show.ID).First().folder = fldr.Path + @"\" + fldr.Label;
                    GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.Folder", fldr.Path + @"\" + fldr.Label);
                }
                else
                {
                    DefaultDir = TorrentEngine.Instance().TorrentSession.GetSettings("dir_active_download");
                    string response  = TorrentEngine.Instance().TorrentSession.GetResponse(string.Format("?action=setsetting&s=dir_active_download&v={0}", fldr.Path + @"\" + fldr.Label));
                    string response2 = TorrentEngine.Instance().TorrentSession.GetResponse("?action=setsetting&s=dir_active_download_flag&v=1");
                    TorrentSearch.TorrentMatch match = _selectedtorrent.AlbumInfoTag as TorrentSearch.TorrentMatch;


                    bool ok = TorrentEngine.Instance().StartDownloading(match.Url, label.Name, true, match.cookie, match.Id, _downloadoption, "");
                    if (!ok)
                    {
                        GUIDialogNotify notify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                        notify.Reset();
                        notify.SetHeading("Failed!");
                        notify.SetText("Unable to start download.");
                        notify.DoModal(GUIWindowManager.ActiveWindow);
                    }
                    string revert = TorrentEngine.Instance().TorrentSession.GetResponse(string.Format("?action=setsetting&s=dir_active_download&v={0}", DefaultDir));
                }
                break;
            }
            }
        }
コード例 #9
0
        public void SearchSeries()
        {
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);

            keyboard.Reset();
            keyboard.Text = "";
            keyboard.DoModal(GUIWindowManager.ActiveWindow);

            if (!keyboard.IsConfirmed)
            {
                return;
            }

            IList <TraktShow> searchshow = TraktAPI.SearchShows(keyboard.Text).ToList();
            GUIDialogMenu     dialog     = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dialog == null)
            {
                return;
            }

            dialog.Reset();
            dialog.SetHeading("Choose TV Series to add");
            foreach (TraktShow ts in searchshow)
            {
                dialog.Add(string.Format("{0} - ({1})", ts.Title, ts.Year));
            }
            dialog.DoModal(GUIWindowManager.ActiveWindow);

            if (dialog.SelectedId != -1)
            {
                TraktShow  t    = searchshow[dialog.SelectedId - 1];
                SeriesItem item = new SeriesItem();
                item.quality           = "720p";
                item.show              = new Series();
                item.show.Name         = t.Title;
                item.show.OriginalName = t.Title;
                item.show.Description  = t.Overview;
                foreach (string genre in t.Genres)
                {
                    item.show.Genres += "|" + genre;
                }
                item.show.Rating = ((double)t.Ratings.Percentage / 10.0).ToString();
                item.show.Poster = t.Images.Banner;
                item.show.ID     = t.Tvdb;
                item.tracker     = "BTN";
                MyTorrents.Instance()._torrentWatchlist._watchItemList.Add(item);
            }
        }
コード例 #10
0
        public void StartParametricSearch(string param)
        {
            _searchString = param;
            TorrentSearchEngine tse = new TorrentSearchEngine(Configuration.Instance().Settings["TorrentSearch.Config"] as string);

            try
            {
                _searchEngine = tse.Engines.Where(e => e.Name == "mptvseries").First();

                MyTorrents.Instance().torrentList.Clear();
                MyTorrents.Instance().torrentList.Visible = true;
                MyTorrents.Instance().torrentList.ListItems = SearchResults;
                UpdateSearchResults("Default");
            }
            catch (Exception ex)
            {
                Log.Instance().Print(ex);
            }
        }
コード例 #11
0
        public void ChooseType(SeriesItem item)
        {
            GUIDialogMenu dialog = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dialog == null)
            {
                return;
            }

            dialog.Reset();
            dialog.SetHeading("Choose Watching Type");
            dialog.Add("New episodes");
            dialog.Add("Missing episodes");

            dialog.DoModal(GUIWindowManager.ActiveWindow);

            if (dialog.SelectedId != -1)
            {
                MyTorrents.Instance()._torrentWatchlist.GetSeriesList().Where(e => e.show.ID == item.show.ID).First().type = dialog.SelectedLabelText;

                GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.Type", dialog.SelectedLabelText);
            }
        }
コード例 #12
0
        public void ShowSeries(object info)
        {
            SelectedWatch = info as SeriesItem;
            Series selected = MyTorrents.Instance()._torrentWatchlist.allseries.Where(e => e.ID == (SelectedWatch).show.ID).FirstOrDefault();

            if (selected != null)
            {
                //get updated info from mp-tvseries
                SelectedWatch.show = selected;
            }
            GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo", "yes");
            GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.SeriesName", SelectedWatch.show.Name);
            GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.SeriesPoster", SelectedWatch.show.Poster);
            GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.SeriesInfo", SelectedWatch.show.Description);
            GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.SeriesGenres", SelectedWatch.show.Genres);
            GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.SeriesRating", SelectedWatch.show.Rating);
            GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.Quality", SelectedWatch.quality);
            GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.Tracker", SelectedWatch.tracker);
            GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.Type", SelectedWatch.type);
            GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.Source", SelectedWatch.source);
            GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.Folder", SelectedWatch.folder);
            GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.Specials", SelectedWatch.includespecials.ToString());
            //MyTorrents.Instance()._torrentWatchlist._watchItemList.Where(e => (e as SeriesItem).show.ID == SelectedWatch.show.ID).FirstOrDefault() = SelectedWatch;
        }
コード例 #13
0
        public void SearchItemClicked(TorrentMatch match)
        {
            GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

            dlg.SetHeading("Download this torrent?");
            dlg.SetLine(1, match.Title);
            dlg.SetLine(2, UnitConvert.SizeToString(match.Size));
            //dlg.SetLine(3, item.Label3);

            dlg.DoModal(GUIWindowManager.ActiveWindow);

            if (!dlg.IsConfirmed)
            {
                return;
            }

            label = DialogAskLabel.Ask();
            if (label == null)
            {
                return;
            }
            Log.Instance().Print("label is " + label.Name);
            List <DownloadDir> predefined = TorrentEngine.Instance().TorrentSession.ListDirs();

            if (predefined == null)
            {
                //MyTorrents.Instance().DisplayError("Unable to connect", "Connection error. Please open your Torrent client before retrying.");
                //return;
            }
            GUIDialogMenu chooser = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (chooser == null)
            {
                return;
            }

            chooser.Reset();
            chooser.SetHeading("Download options");
            chooser.Add("No change");
            //foreach (DownloadDir dir in predefined)
            //{
            //    GUIListItem element = new GUIListItem();
            //    element.Label = dir.path;
            //    element.Label2 = String.Format("{0} MB Free", Convert.ToString(dir.available));
            //    chooser.Add(element);
            //}

            chooser.Add("Browse Folders");

            chooser.DoModal(GUIWindowManager.ActiveWindow);
            if (chooser.SelectedId == -1)
            {
                return;
            }

            int    selecteddirId = chooser.SelectedId;
            string selectedText  = chooser.SelectedLabelText;

            Log.Instance().Print("download option is " + selectedText);
            bool ok = false;
            // KAT hack
            string dowOption = "";

            if (_searchEngine.GetType() == typeof(TorrentSearch_Combiner))
            {
                Log.Instance().Print("Selected engine is Combiner");
                TorrentSearch_Combiner _eng = (TorrentSearch_Combiner)_searchEngine;
                if (_searchEngine.Parameters.ContainsKey("Options"))
                {
                    dowOption = _eng.Engines.Where(e => e.Name == match.tracker).First().Parameters["Options"].ToString().Replace("%id%", match.Id);
                }
            }
            else
            {
                if (_searchEngine.Parameters.ContainsKey("Options"))
                {
                    dowOption = _searchEngine.Parameters["Options"].ToString().Replace("%id%", match.Id);
                }
            }

            switch (selectedText)
            {
            case "Browse Folders":

                //FolderBrowser ViewFolders = new FolderBrowser(TorrentEngine.Instance().TorrentSession, label, match, dowOption);
                Log.Instance().Print("Loading file browser");
                MyTorrents.ListType = "FolderBrowser";
                MyTorrents.Instance().ShowFolderBrowser();
                break;

            case "No change":

                if (label != null)
                {
                    Log.Instance().Print("Starting torrent file downloading");

                    ok = TorrentEngine.Instance().StartDownloading(match.Url, label.Name, true, match.cookie, match.Id, dowOption, "");
                }
                break;

            default:

                if (label != null)
                {
                    Log.Instance().Print("Starting torrent file downloading");
                    ok = TorrentEngine.Instance().StartDownloading(match.Url, label.Name, true, match.cookie, match.Id, dowOption, String.Format("&download_dir={0}", selecteddirId - 2));
                }
                break;
            }

            /*
             * if (!ok)
             * {
             *  GUIDialogNotify notify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
             *  notify.Reset();
             *  notify.SetHeading("Failed!");
             *  notify.SetText("Unable to start download.");
             *  notify.DoModal(GUIWindowManager.ActiveWindow);
             *
             *  Log.Instance().Print("Downloading failed");
             * }
             * */
        }
コード例 #14
0
        public void ContextMenu(object info)
        {
            WatchItem     watch = info as WatchItem;
            GUIDialogMenu dlg   = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }


            dlg.Reset();
            dlg.SetHeading("Torrent watchlist");
            dlg.Add("Add Series");
            dlg.Add("Search Series");
            dlg.Add("Add Movie");
            dlg.Add("Add custom");
            dlg.Add("Manual Search");
            dlg.Add("Remove selected");
            dlg.Add("Clear list");
            dlg.Add("Force RSS update");
            dlg.DoModal(GUIWindowManager.ActiveWindow);

            switch (dlg.SelectedLabelText)
            {
            case "Add Series":
            {
                AddSeries();
                MyTorrents.Instance().ShowTorrentWatch();
                break;
            }

            case "Search Series":
            {
                SearchSeries();
            }
            break;

            case "Add Movie":
                break;

            case "Manual Search":
                MyTorrents.Instance()._torrentWatchlist.SearchTorrent();
                break;

            case "Add custom":
            {
                VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
                keyboard.Reset();
                keyboard.Text = "";
                keyboard.DoModal(GUIWindowManager.ActiveWindow);

                if (!keyboard.IsConfirmed)
                {
                    return;
                }

                watch            = new WatchItem();
                watch.SearchTerm = keyboard.Text;

                TorrentLabel label = DialogAskLabel.Ask();
                if (label != null)
                {
                    watch.Label = label.Name;
                    MyTorrents.Instance()._torrentWatchlist.AddWatch(watch);
                    Log.Instance().Print(String.Format("Watch [{0}] added.", watch.SearchTerm));
                }
                break;
            }

            case "Clear list":
            {
                MyTorrents.Instance()._torrentWatchlist.Clear();
                break;
            }

            case "Remove selected":
            {
                MyTorrents.Instance()._torrentWatchlist.RemoveWatch(watch);
                // torrentList.RemoveItem(torrentList.SelectedListItemIndex);
                break;
            }

            case "Force RSS update":
            {
                RSSChannelManager.Instance().UpdateChannels(true);
                break;
            }
            }

            MyTorrents.Instance().ShowTorrentWatch();
        }
コード例 #15
0
        public void OnToggleSpecials(SeriesItem item, bool includespecials)
        {
            MyTorrents.Instance()._torrentWatchlist.GetSeriesList().Where(e => e.show.ID == item.show.ID).First().includespecials = includespecials;

            GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo.Specials", includespecials.ToString());
        }
コード例 #16
0
 public void ChooseFolder(SeriesItem item)
 {
     MyTorrents.ListType = "SeriesFolderBrowser";
     GUIPropertyManager.SetProperty("#MyTorrents.SeriesInfo", "no");
     MyTorrents.Instance().ShowFolderBrowser();
 }
コード例 #17
0
        public bool StartDownloading(string url, string label, bool force, string cookies, string id, string Downoption, string option, string folder)
        {
            string    data = "";
            CacheItem item = _contentCache.Item(url);

            if (item == null)
            {
                try
                {
                    WebClient client = new WebClient();
                    client.Headers.Add("User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.186 Safari/535.1");
                    if (cookies != null)
                    {
                        client.Headers.Add("Cookie", cookies);
                    }
                    if (Downoption != "")
                    {
                        client.Headers.Add(Downoption);
                    }
                    Log.Instance().Print(client.Headers.ToString());
                    Log.Instance().Print("downloading torrent file");
                    byte[] content = client.DownloadData(url);
                    data = Encoding.UTF8.GetString(content);
                    item = new CacheItem(url, content);
                    _contentCache.Add(item);
                }
                catch (Exception e)
                {
                    MyTorrents.Instance().DisplayError("Error", "An unknown error has occurred.");

                    Log.Instance().Print(string.Format("Could not download torrent [{0}].", url));
                    Log.Instance().Print(e);
                    Log.Instance().Print(data);
                    return(false);
                }
            }
            else
            {
                //MyTorrents.Instance().DisplayError("Error", "This torrent has been found in download cache. Action cancelled.");

                Log.Instance().Print(string.Format("Torrent [{0}] found from cache, not downloading again.", url));
                long size = 0;

                foreach (CacheItem i in _contentCache.Cache)
                {
                    size += i.Data.Length;
                }
                Log.Instance().Print(string.Format("Cache size is around {0:F2}Kb.", size / 1024.0));
                if (!force)
                {
                    return(false);
                }
            }
            TorrentFile tfile = null;

            try
            {
                MemoryStream ms = new MemoryStream(item.Data);
                if (ms == null)
                {
                    throw new Exception();
                }
                tfile = new TorrentFile(ms);
                if (tfile == null)
                {
                    throw new Exception();
                }
            }
            catch
            {
                MyTorrents.Instance().DisplayError("Error", "An error has occurred. Invalid torrent file.");
                return(false);
            }
            string hash = tfile.Hash;
            //if (TorrentByHash(hash) != null)
            //{
            //    MyTorrents.Instance().DisplayError("Error", "Torrent already exists.");
            //    return false;
            //}
            string filename = tfile.Name;

            tfile.Close();

            if (!force)
            {
                if (IsAlreadyDownloaded(hash))
                {
                    Log.Instance().Print("Already downloaded!");
                    return(false);
                }
            }

            Log.Instance().Print(String.Format("Download [{0}] started.", url));
            bool ret = false;

            if (folder == "")
            {
                ret = _torrentSession.StartDownload(item.Data, filename, label, hash, option);
            }
            else
            {
                ret = _torrentSession.StartDownloadToFolder(item.Data, filename, label, hash, option, folder);
            }
            if (!ret)
            {
                MyTorrents.Instance().DisplayError("Error", "An unknown error has occurred.");
                Log.Instance().Print(data);
            }
            if (ret && !force)
            {
                _hashQueue.Add("");
            }
            return(ret);
        }