Ejemplo n.º 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");//
        }
Ejemplo n.º 2
0
        static public void RawSearchTest(string engine, string search, string sort)
        {
            TorrentSearchEngine tse           = new TorrentSearchEngine("MyTorrents.xml");
            ITorrentSearch      torrentSearch = tse.Create(engine);

            string      raw    = torrentSearch.RawSearch(search, sort, null);
            CultureInfo mylang = CultureInfo.CurrentCulture;

            Console.OutputEncoding = Encoding.GetEncoding(mylang.TextInfo.ANSICodePage);
            Console.WriteLine(raw);
        }
Ejemplo n.º 3
0
        static public void LoginTest(string engine)
        {
            Console.WriteLine("LoginTest: {0}", engine);
            TorrentSearchEngine tse           = new TorrentSearchEngine("MyTorrents.xml");
            ITorrentSearch      torrentSearch = tse.Create(engine);
            HttpWebResponse     r             = torrentSearch.Login();

            Console.WriteLine("Response: {0} - {1}", r.StatusCode, r.StatusDescription);
            for (int i = 0; i < r.Headers.Count; ++i)
            {
                Console.WriteLine("Header Name:{0}, Value :{1}", r.Headers.Keys[i], r.Headers[i]);
            }
        }
Ejemplo n.º 4
0
        static public void SearchTest(string engine, string search, string sort)
        {
            Console.WriteLine("SearchTest: {0}:\"{1}\":{2}", engine, search, sort);
            TorrentSearchEngine tse           = new TorrentSearchEngine("MyTorrents.xml");
            ITorrentSearch      torrentSearch = tse.Create(engine);

            TorrentMatchList matchList = torrentSearch.Search(search, sort, null);
            CultureInfo      mylang    = CultureInfo.CurrentCulture;

            Console.OutputEncoding = Encoding.GetEncoding(mylang.TextInfo.ANSICodePage);
            foreach (TorrentMatch match in matchList)
            {
                Console.WriteLine("Found: {0} (Size:{1:F2} MB))", match.Title, match.Size / (1024 * 1024));
            }
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
0
        void _bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            TorrentSearchParameters p   = e.Argument as TorrentSearchParameters;
            TorrentSearchEngine     tse = null;

            try

            {
                tse = new TorrentSearchEngine(Configuration.Instance().Settings["TorrentSearch.Config"] as string);
            }
            catch
            {
                Log.Instance().Print("Mytorrents.xml cofig file loading failed!");
            }
            ITorrentSearch   t         = tse.Create(p.SearchEngine);
            TorrentMatchList matchList = t.Search(p.SearchString, p.SortOrder, null);

            e.Result = matchList;
        }
Ejemplo n.º 7
0
        protected void OnPageLoad()
        {
            string loadParam = null;

            // check if running version of mediaportal supports loading with parameter
            System.Reflection.FieldInfo fi = typeof(GUIWindow).GetField("_loadParameter", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
            if (fi != null)
            {
                loadParam = (string)fi.GetValue(this);
                //site:<sitename>|category:<categoryname>|search:<searchstring>|return:<locked|root>|view:<list|smallthumbs|largethumbs>
                //add bool option on search to popup VK if nothing found or not
            }
            if (!string.IsNullOrEmpty(loadParam))
            {
                _searchString = loadParam;
                TorrentSearchEngine tse = new TorrentSearchEngine(Configuration.Instance().Settings["TorrentSearch.Config"] as string);
                _searchEngine = tse.Engines.Where(e => e.Name == "mptvseries").First();
                UpdateSearchResults("Default");
            }
            else
            {
                StartSearch();
            }
        }
Ejemplo n.º 8
0
        public virtual void DoSearch()
        {
            Thread AutoSearch = new Thread(delegate()
            {
                try
                {
                    Log.Instance().Print(string.Format("Automatic search started [{0}]", this.show.Name));
                    Log.Instance().Print(string.Format("Unlocal Episodes [{0}]", this.show.AllUnlocal));
                    Log.Instance().Print(string.Format("Next unlocal Episode [{0}]", this.show.FirstUnlocal));

                    TorrentSearchEngine tse = new TorrentSearchEngine(Configuration.Instance().Settings["TorrentSearch.Config"] as string);
                    var watch = this;
                    ITorrentSearch _searchEngine = tse.Engines.Where(e => e.Name == watch.tracker).First();
                    string CleanTitle            = Regex.Replace(watch.show.OriginalName, "[^0-9a-zA-Z ]+", "");
                    TorrentMatchList matchlist   = _searchEngine.Search(CleanTitle, "Default", null);
                    Log.Instance().Print(string.Format("Search {0} on {1} Sort {2} Count {3}", CleanTitle, _searchEngine.Name, "Default", matchlist.Count));
                    switch (watch.type)
                    {
                    case "New episodes":
                        int t = 0;
                        Log.Instance().Print(string.Format("Searching for episode [{0}]", this.show.FirstUnlocal));
                        foreach (TorrentMatch m in matchlist)
                        {
                            if (m.Title.IndexOf(watch.show.FirstUnlocal) != -1 && m.Title.IndexOf(watch.quality) != -1 && m.Title.IndexOf(watch.source) != -1)
                            {
                                t++;
                                Log.Instance().Print(string.Format("Match {0}", m.Title));
                                bool ok = TorrentEngine.Instance().StartDownloading(m.Url, "", true, m.cookie, m.Id, "", "", watch.folder);
                            }
                        }
                        Log.Instance().Print(string.Format("[{0}] matches found", t));
                        break;

                    case "Missing episodes":
                        IEnumerable <string> eps = watch.show.AllUnlocal.Split('|').ToList();
                        eps     = (watch.includespecials ? eps : eps.Where(e => e.StartsWith("S00") == false).ToList());
                        var ccc = (from m in matchlist from ep in eps where m.Title.Contains(ep) select m).ToList();
                        foreach (TorrentMatch m in matchlist)
                        {
                            foreach (string ep in eps)
                            {
                                int y = 0;
                                Log.Instance().Print(string.Format("Searching for episode [{0}]", ep));
                                if (m.Title.Contains(ep) && m.Title.IndexOf(watch.quality) != -1 && m.Title.IndexOf(watch.source) != -1)
                                {
                                    y++;
                                    Log.Instance().Print(string.Format("Match {0}", m.Title));
                                    bool ok = TorrentEngine.Instance().StartDownloading(m.Url, "", true, m.cookie, m.Id, "", "", watch.folder);
                                }
                                Log.Instance().Print(string.Format("[{0}] matches found for episodes [{1}]", y, m.Title));
                            }
                        }
                        break;
                    }
                }
                catch { }
            })
            {
                IsBackground = true,
                Name         = "MyTorrents Autograbber"
            };

            AutoSearch.Start();
        }