Exemplo n.º 1
0
        private void Load_Preview(bool alwaysAsk)
        {
            // dataGridViewSearchResults.Rows.Clear();
              while (dataGridViewSearchResults.Rows.Count > 0)
              {
            dataGridViewSearchResults.Rows.RemoveAt(0);
              }
              button_GoDetailPage.Enabled = false;
              button_Preview.Enabled = false;

              GrabberUrlClass grab = new GrabberUrlClass();
              int pageNumber = -1;
              if (!string.IsNullOrEmpty(textPage.Text))
            pageNumber = Convert.ToInt16(textPage.Text);
              try
              {
            listUrl = grab.ReturnURL(TextSearch.Text, textConfig.Text + ".tmp", pageNumber, alwaysAsk, string.Empty);
              }
              catch (Exception ex)
              {
            DialogResult dlgResult = DialogResult.None;
            button_Preview.Enabled = true;
            dlgResult = MessageBox.Show("Grabber ERROR - check your definitions! \n\nException Message: " + ex.Message + "\nStacktrace: " + ex.StackTrace, "Error", MessageBoxButtons.OK);
            if (dlgResult == DialogResult.OK) { }
              }

              for (int i = 0; i < listUrl.Count; i++)
              {
            //DataGridViewRow row = new DataGridViewRow();
            //row.Cells[0].Value = i;
            //row.Cells[1].Value = image;
            //row.Cells[2].Value = wurl.Title;
            //row.Cells[3].Value = wurl.Year;
            //row.Cells[4].Value = wurl.Options;
            //row.Cells[5].Value = wurl.ID;
            //row.Cells[6].Value = wurl.URL;
            //row.Cells[7].Value = wurl.Director;
            //row.Cells[8].Value = wurl.Akas;
            //i = dataGridViewSearchResults.Rows.Add(row); // add row for config

            var wurl = (GrabberUrlClass.IMDBUrl)listUrl[i];
            Image image = GrabUtil.GetImageFromUrl(wurl.Thumb); // Image image = Image.FromFile(wurl.Thumb); // Image smallImage = image.GetThumbnailImage(20, 30, null, IntPtr.Zero);
            dataGridViewSearchResults.Rows.Add(new object[] { (i + 1).ToString(), image, wurl.Title, wurl.Year, wurl.Options, wurl.ID, wurl.URL, wurl.Director, wurl.Akas });

            //dataGridViewSearchResults.Rows[i].Cells[0].Value = i;
            //dataGridViewSearchResults.Rows[i].Cells[1].Style.NullValue = null;
            //dataGridViewSearchResults.Rows[i].Cells[1].Value = image;
            //dataGridViewSearchResults.Rows[i].Cells[2].Value = wurl.Title;
            //dataGridViewSearchResults.Rows[i].Cells[3].Value = wurl.Year;
            //dataGridViewSearchResults.Rows[i].Cells[4].Value = wurl.Options;
            //dataGridViewSearchResults.Rows[i].Cells[5].Value = wurl.ID;
            //dataGridViewSearchResults.Rows[i].Cells[6].Value = wurl.URL;
            //dataGridViewSearchResults.Rows[i].Cells[7].Value = wurl.Director;
            //dataGridViewSearchResults.Rows[i].Cells[8].Value = wurl.Akas;
              }
              if (dataGridViewSearchResults.Rows.Count > 0)
              {
            dataGridViewSearchResults.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dataGridViewSearchResults.Rows[0].Selected = true; //set first line as selected
            button_GoDetailPage.Enabled = true;
            button_Preview.Enabled = true;
              }
        }
Exemplo n.º 2
0
        private void buttonPreview_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textConfig.Text))
              {
            MessageBox.Show("No Config loaded !", "Error");
            return;
              }

              Stopwatch watch = new Stopwatch();
              string totalruntime = string.Empty;
              watch.Reset();
              watch.Start();
              textPreview.Clear();
              pictureBoxPreviewCollection.ImageLocation = "";
              pictureBoxPreviewCover.ImageLocation = "";
              labelImageSize.Text = "";

              SaveXml(textConfig.Text + ".tmp");
              GrabberUrlClass grab = new GrabberUrlClass();
              string[] result = new string[80];

              try // http://akas.imdb.com/title/tt0133093/
              {
            result = grab.GetDetail(TextURLDetail.Text, Environment.GetEnvironmentVariable("TEMP"), textConfig.Text + ".tmp", true, string.Empty, string.Empty, string.Empty, string.Empty, null);
              }
              catch (Exception ex)
              {
            DialogResult dlgResult = DialogResult.None;
            dlgResult = MessageBox.Show("An error ocurred - check your definitions!\n Exception: " + ex + ", Stacktrace: " + ex.StackTrace, "Error", MessageBoxButtons.OK);
            if (dlgResult == DialogResult.OK)
            {
            }
              }
              watch.Stop();
              totalruntime = "Total Runtime: " + watch.ElapsedMilliseconds + " ms.";

              string mapped;
              for (int i = 0; i < result.Length; i++)
              {
            textPreview.SelectionFont = new Font("Arial", (float)9.75, FontStyle.Bold | FontStyle.Underline);
            mapped = i > 39 ? " (mapped)" : "";

            switch (i)
            {
              case 0:
            textPreview.SelectedText += "(" + i + ") " + "Original Title" + mapped + Environment.NewLine;
            break;
              case 40:
            textPreview.SelectedText += Environment.NewLine;
            textPreview.SelectedText += Environment.NewLine;
            textPreview.SelectionFont = new Font("Arial", (float)9.75, FontStyle.Bold | FontStyle.Underline);
            textPreview.SelectedText += "MAPPED OUTPUT FIELDS:" + Environment.NewLine;
            textPreview.SelectedText += Environment.NewLine;
            textPreview.SelectionFont = new Font("Arial", (float)9.75, FontStyle.Bold | FontStyle.Underline);
            textPreview.SelectedText += "(" + i + ") " + "Original Title" + mapped + Environment.NewLine;
            break;
              case 1:
              case 41:
            textPreview.SelectedText += "(" + i + ") " + "Translated Title" + mapped + Environment.NewLine;
            break;
              case 2:
              case 42:
            textPreview.SelectedText += "(" + i + ") " + "Cover" + mapped + Environment.NewLine;
            if (i > 39) // only show image once !
            {
              try
              {
                pictureBoxPreviewCover.ImageLocation = result[i];

                // Create new FileInfo object and get the Length.
                FileInfo f = new FileInfo(result[i]);
                //long s1 = f.Length;
                //labelImageSize.Text = s1.ToString();
                labelImageSize.Text = ByteString(f.Length);
              }
              catch (Exception)
              {
                labelImageSize.Text = "n/a";
                //MessageBox.Show("An error ocurred in image preview - check your config.\n" + ex.Message + "\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
              }
              try
              {
                pictureBoxPreviewCollection.ImageLocation = Path.Combine(Path.GetDirectoryName(result[i]), "Collection_" + Path.GetFileName(result[i]));
                //FileInfo f = new FileInfo(Result[i]);
                //labelImageSize.Text = this.ByteString(f.Length);
              }
              catch (Exception)
              {
                // labelImageSize.Text = "n/a";
              }
            }
            break;
              case 3:
              case 43:
            textPreview.SelectedText += "(" + i + ") " + "Description" + mapped + Environment.NewLine;
            break;
              case 4:
              case 44:
            textPreview.SelectedText += "(" + i + ") " + "Rating" + mapped + Environment.NewLine;
            break;
              case 5:
              case 45:
            textPreview.SelectedText += "(" + i + ") " + "Actors" + mapped + Environment.NewLine;
            break;
              case 6:
              case 46:
            textPreview.SelectedText += "(" + i + ") " + "Director" + mapped + Environment.NewLine;
            break;
              case 7:
              case 47:
            textPreview.SelectedText += "(" + i + ") " + "Producer" + mapped + Environment.NewLine;
            break;
              case 8:
              case 48:
            textPreview.SelectedText += "(" + i + ") " + "Year" + mapped + Environment.NewLine;
            break;
              case 9:
              case 49:
            textPreview.SelectedText += "(" + i + ") " + "Country" + mapped + Environment.NewLine;
            break;
              case 10:
              case 50:
            textPreview.SelectedText += "(" + i + ") " + "Category" + mapped + Environment.NewLine;
            break;
              case 11:
              case 51:
            textPreview.SelectedText += "(" + i + ") " + "URL" + mapped + Environment.NewLine;
            break;
              case 12:
              case 52:
            textPreview.SelectedText += "(" + i + ") " + "Image" + mapped + Environment.NewLine;
            break;
              case 13:
              case 53:
            textPreview.SelectedText += "(" + i + ") " + "Writer" + mapped + Environment.NewLine;
            break;
              case 14:
              case 54:
            textPreview.SelectedText += "(" + i + ") " + "Comment" + mapped + Environment.NewLine;
            break;
              case 15:
              case 55:
            textPreview.SelectedText += "(" + i + ") " + "Language" + mapped + Environment.NewLine;
            break;
              case 16:
              case 56:
            textPreview.SelectedText += "(" + i + ") " + "Tagline" + mapped + Environment.NewLine;
            break;
              case 17:
              case 57:
            textPreview.SelectedText += "(" + i + ") " + "Certification" + mapped + Environment.NewLine;
            break;
              case 18:
              case 58:
            textPreview.SelectedText += "(" + i + ") " + "IMDB_Id" + mapped + Environment.NewLine;
            break;
              case 19:
              case 59:
            textPreview.SelectedText += "(" + i + ") " + "IMDB_Rank" + mapped + Environment.NewLine;
            break;
              case 20:
              case 60:
            textPreview.SelectedText += "(" + i + ") " + "Studio" + mapped + Environment.NewLine;
            break;
              case 21:
              case 61:
            textPreview.SelectedText += "(" + i + ") " + "Edition" + mapped + Environment.NewLine;
            break;
              case 22:
              case 62:
            textPreview.SelectedText += "(" + i + ") " + "Fanart" + mapped + Environment.NewLine;
            break;
              case 23:
              case 63:
            textPreview.SelectedText += "(" + i + ") " + "Generic 1" + mapped + Environment.NewLine;
            break;
              case 24:
              case 64:
            textPreview.SelectedText += "(" + i + ") " + "Generic 2" + mapped + Environment.NewLine;
            break;
              case 25:
              case 65:
            textPreview.SelectedText += "(" + i + ") " + "Generic 3" + mapped + Environment.NewLine;
            break;
              case 26:
              case 66:
            textPreview.SelectedText += "(" + i + ") " + "Names: Countries for 'Translated Title'" + mapped + Environment.NewLine;
            break;
              case 27:
              case 67:
            textPreview.SelectedText += "(" + i + ") " + "Values: Countries for 'Translated Title'" + mapped + Environment.NewLine;
            break;
              case 28:
              case 68:
            textPreview.SelectedText += "(" + i + ") " + "Names: Countries for 'Certification'" + mapped + Environment.NewLine;
            break;
              case 29:
              case 69:
            textPreview.SelectedText += "(" + i + ") " + "Values: Countries for 'Certification'" + mapped + Environment.NewLine;
            break;
              case 30:
              case 70:
            textPreview.SelectedText += "(" + i + ") " + "Values: MultiPosters'" + mapped + Environment.NewLine;
            break;
              case 31:
              case 71:
            textPreview.SelectedText += "(" + i + ") " + "Values: Photos'" + mapped + Environment.NewLine;
            break;
              case 32:
              case 72:
            textPreview.SelectedText += "(" + i + ") " + "Values: PersonImages'" + mapped + Environment.NewLine;
            break;
              case 33:
              case 73:
            textPreview.SelectedText += "(" + i + ") " + "Values: MultiFanart'" + mapped + Environment.NewLine;
            break;
              case 34:
              case 74:
            textPreview.SelectedText += "(" + i + ") " + "Values: Trailer'" + mapped + Environment.NewLine;
            break;
              case 35:
              case 75:
            textPreview.SelectedText += "(" + i + ") " + "TMDB_Id'" + mapped + Environment.NewLine;
            break;
              case 36:
              case 76:
            textPreview.SelectedText += "(" + i + ") " + "Runtime'" + mapped + Environment.NewLine;
            break;
              case 37:
              case 77:
            textPreview.SelectedText += "(" + i + ") " + "Collection'" + mapped + Environment.NewLine;
            break;
              case 38:
              case 78:
            textPreview.SelectedText += "(" + i + ") " + "CollectionImageURL'" + mapped + Environment.NewLine;
            break;
              case 39:
              case 79:
            textPreview.SelectedText += "(" + i + ") " + "Picture URL'" + mapped + Environment.NewLine;
            break;
              default:
            textPreview.SelectedText += "(" + i + ") " + "Mapping Output Field '" + (i - 40) + "'" + mapped + Environment.NewLine;
            break;
            }
            if (i <= 80) // Changed to support new fields...
              textPreview.AppendText(result[i] + Environment.NewLine);
              }
              // List of Grab Pages used for Grabber results:
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.SelectionFont = new Font("Arial", (float)9.75, FontStyle.Bold | FontStyle.Underline);
              textPreview.SelectedText += "*** Infos about used Grab Pages ***" + Environment.NewLine;
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("Base page:" + TimeBodyDetail + Environment.NewLine);
              textPreview.AppendText(URLBodyDetail + Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("URL Gateway:" + TimeBodyDetail2 + Environment.NewLine);
              textPreview.AppendText(URLBodyDetail2 + Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("URL Redirection Generic 1:" + TimeBodyLinkGeneric1 + Environment.NewLine);
              textPreview.AppendText(URLBodyLinkGeneric1 + Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("URL Redirection Generic 2:" + TimeBodyLinkGeneric2 + Environment.NewLine);
              textPreview.AppendText(URLBodyLinkGeneric2 + Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("URL Redirection Cover:" + TimeBodyLinkImg + Environment.NewLine);
              textPreview.AppendText(URLBodyLinkImg + Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("URL Redirection Persons:" + TimeBodyLinkPersons + Environment.NewLine);
              textPreview.AppendText(URLBodyLinkPersons + Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("URL Redirection Title:" + TimeBodyLinkTitles + Environment.NewLine);
              textPreview.AppendText(URLBodyLinkTitles + Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("URL Redirection Certification:" + TimeBodyLinkCertification + Environment.NewLine);
              textPreview.AppendText(URLBodyLinkCertification + Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("URL Redirection Comment:" + TimeBodyLinkComment + Environment.NewLine);
              textPreview.AppendText(URLBodyLinkComment + Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("URL Redirection Description:" + TimeBodyLinkSyn + Environment.NewLine);
              textPreview.AppendText(URLBodyLinkSyn + Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("URL Redirection MultiPosters:" + TimeBodyLinkMultiPosters + Environment.NewLine);
              textPreview.AppendText(URLBodyLinkMultiPosters + Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("URL Redirection Photos:" + TimeBodyLinkPhotos + Environment.NewLine);
              textPreview.AppendText(URLBodyLinkPhotos + Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("URL Redirection PersonImages:" + TimeBodyLinkPersonImages + Environment.NewLine);
              textPreview.AppendText(URLBodyLinkPersonImages + Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("URL Redirection MultiFanart:" + TimeBodyLinkMultiFanart + Environment.NewLine);
              textPreview.AppendText(URLBodyLinkMultiFanart + Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText("URL Redirection Trailer:" + TimeBodyLinkTrailer + Environment.NewLine);
              textPreview.AppendText(URLBodyLinkTrailer + Environment.NewLine);

              textPreview.AppendText(Environment.NewLine);
              textPreview.AppendText(Environment.NewLine);
              textPreview.SelectionFont = new Font("Arial", (float)9.75, FontStyle.Bold | FontStyle.Underline);
              textPreview.SelectedText += totalruntime + Environment.NewLine;

              File.Delete(textConfig.Text + ".tmp");
        }
Exemplo n.º 3
0
    //-------------------------------------------------------------------------------------------
    //  Dowload backdrops on theMovieDB.org
    //-------------------------------------------------------------------------------------------        
    public static void Download_Backdrops_Fanart(string wtitle, string wttitle, string wftitle, string director, string imdbid, string year, bool choose, int wGetId, string savetitle, string personartworkpath, bool loadFanart, bool loadPersonImages, GUIAnimation searchanimation)
    {
      new Thread(delegate()
      {
        var grab = new GrabberUrlClass();
        int wyear = 0;
        try { wyear = Convert.ToInt32(year); } catch { }
        try
        {
          SetProcessAnimationStatus(true, searchanimation);  // GUIWaitCursor.Init(); GUIWaitCursor.Show();
          List<DbMovieInfo> listemovies = grab.GetFanart(wtitle, savetitle, wyear, director, imdbid, MyFilms.conf.StrPathFanart, true, choose, MyFilms.conf.StrTitle1, personartworkpath);
          SetProcessAnimationStatus(false, searchanimation);  //GUIWaitCursor.Hide();
          //System.Collections.Generic.List<grabber.DBMovieInfo> listemovies = Grab.GetFanart(wtitle, wttitle, wyear, director, MyFilms.conf.StrPathFanart, true, choose);
          LogMyFilms.Debug("(DownloadBackdrops) - listemovies: '" + wtitle + "', '" + wttitle + "', '" + wyear + "', '" + director + "', '" + MyFilms.conf.StrPathFanart + "', 'true', '" + choose + "', '" + MyFilms.conf.StrTitle1 + "'");
          int listCount = listemovies.Count;
          LogMyFilms.Debug("(DownloadBackdrops) - listemovies: Result Listcount: '" + listCount + "'");

          if (choose) listCount = 2;
          switch (listCount)
          {
            case 0:
              break;
            case 1:
              LogMyFilms.Debug("Fanart " + listemovies[0].Name.Substring(listemovies[0].Name.LastIndexOf("\\") + 1) + " downloaded for " + wttitle);
              if (listemovies[0].Persons.Count > 0)
              {
                LogMyFilms.Debug("PersonArtwork: " + listemovies[0].Persons.Count + " Persons checked for " + wttitle);
                foreach (DbPersonInfo person in listemovies[0].Persons)
                {
                  LogMyFilms.Debug("PersonArtwork: " + person.Images.Count + " images found for " + person.Name);
                }
              }
              break;
            default:

              const int MinChars = 2;
              const bool Filter = true; // no "der die das"

              GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
              if (dlg == null) return;
              dlg.Reset();
              dlg.SetHeading(loadFanart ? GUILocalizeStrings.Get(1079862) : GUILocalizeStrings.Get(1079900));  // Load fanart (online)  // Download person images (selected film)
              dlg.Add("  *****  " + GUILocalizeStrings.Get(1079860) + "  *****  "); //manual selection
              foreach (DbMovieInfo t in listemovies)
              {
                string dialoginfoline = t.Name + "  (" + t.Year + ")";
                if (loadFanart) dialoginfoline += " - Fanarts: " + t.Backdrops.Count;
                if (loadPersonImages) dialoginfoline += " - Persons: " + t.Persons.Count.ToString();
                dlg.Add(dialoginfoline);
                LogMyFilms.Debug("TMDB listemovies: " + t.Name + "  (" + t.Year + ") - Fanarts: " + t.Backdrops.Count + " - TMDB-Id: " + t.Identifier + " - Persons: " + t.Persons.Count);
              }
              if (!(dlg.SelectedLabel > -1))
              {
                dlg.SelectedLabel = -1;
                dlg.DoModal(wGetId);
              }
              if (dlg.SelectedLabel == 0)
              {
                #region Get SubTitles and Subwords from otitle and ttitle
                //First Show Dialog to choose Otitle, Ttitle or substrings - or Keyboard to manually enter searchstring!!!
                var dlgSearchFilm = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                if (dlgSearchFilm == null) return;
                dlgSearchFilm.Reset();
                dlgSearchFilm.SetHeading(GUILocalizeStrings.Get(1079859)); // choose search expression
                dlgSearchFilm.Add("  *****  " + GUILocalizeStrings.Get(1079858) + "  *****  ");
                //manual selection with keyboard
                //dlgs.Add(wtitle); //Otitle
                dlgSearchFilm.Add(savetitle); //Otitle = savetitle
                dlgSearchFilm.Add(wttitle); //Ttitle
                foreach (string t in MyFilms.SubTitleGrabbing(wtitle).Where(t => t.Length > 1)) dlgSearchFilm.Add(t);
                foreach (string t in MyFilms.SubTitleGrabbing(wttitle).Where(t => t.Length > 1)) dlgSearchFilm.Add(t);
                foreach (string t in MyFilms.SubWordGrabbing(wtitle, MinChars, Filter).Where(t => t.Length > 1)) dlgSearchFilm.Add(t);
                foreach (string t in MyFilms.SubWordGrabbing(wttitle, MinChars, Filter).Where(t => t.Length > 1)) dlgSearchFilm.Add(t);
                //Now all titles and Substrings listed in dialog !
                //dlgs.Add("  *****  " + GUILocalizeStrings.Get(1079860) + "  *****  "); //manual selection
                if (!(dlgSearchFilm.SelectedLabel > -1))
                {
                  dlgSearchFilm.SelectedLabel = -1;
                  dlgSearchFilm.DoModal(wGetId);
                }
                if (dlgSearchFilm.SelectedLabel == 0) // enter manual searchstring via VK
                {
                  VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
                  if (null == keyboard) return;
                  keyboard.Reset();
                  keyboard.SetLabelAsInitialText(false); // set to false, otherwise our intial text is cleared
                  keyboard.Text = wtitle;
                  keyboard.DoModal(wGetId);
                  if (keyboard.IsConfirmed && (keyboard.Text.Length > 0))
                  {
                    //Remove_Backdrops_Fanart(wtitle, true);
                    //Remove_Backdrops_Fanart(wttitle, true);
                    //Remove_Backdrops_Fanart(wftitle, true);
                    Download_Backdrops_Fanart(keyboard.Text, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, true, wGetId, savetitle, personartworkpath, loadFanart, loadPersonImages, searchanimation);
                  }
                  break;
                }
                if (dlgSearchFilm.SelectedLabel > 0 && dlgSearchFilm.SelectedLabel < 3) // if one of otitle or ttitle selected, keep year and director
                {
                  Download_Backdrops_Fanart(dlgSearchFilm.SelectedLabelText, wttitle, wftitle, year, director, string.Empty, true, wGetId, savetitle, personartworkpath, loadFanart, loadPersonImages, searchanimation);
                  //Download_Backdrops_Fanart(string wtitle, string wttitle, string director, string year, bool choose,int wGetID, string savetitle)
                  break;
                }
                if (dlgSearchFilm.SelectedLabel > 2) // For subitems, search without year and director !
                {
                  Download_Backdrops_Fanart(dlgSearchFilm.SelectedLabelText, wttitle, wftitle, string.Empty, string.Empty, string.Empty, true, wGetId, savetitle, personartworkpath, loadFanart, loadPersonImages, searchanimation);
                  //Download_Backdrops_Fanart(string wtitle, string wttitle, string director, string year, bool choose,int wGetID, string savetitle)
                  break;
                }

                #endregion
              }
              if (dlg.SelectedLabel > 0)
              {
                // Load Fanart  -> show progress dialog !

                var dlgPrgrs = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS);
                if (dlgPrgrs != null)
                {
                  dlgPrgrs.Reset();
                  dlgPrgrs.DisplayProgressBar = true;
                  dlgPrgrs.ShowWaitCursor = false;
                  dlgPrgrs.DisableCancel(true);
                  dlgPrgrs.SetHeading("MyFilms Artwork Download");
                  dlgPrgrs.StartModal(GUIWindowManager.ActiveWindow);
                  dlgPrgrs.SetLine(1, "Loading Artwork ...");
                  dlgPrgrs.Percentage = 0;

                  #region load fanarts ...
                  bool first = true;
                  string filename = string.Empty;
                  string filename1 = string.Empty;
                  //if (MyFilms.conf.StrTitle1 == "OriginalTitle")
                  //  wttitle = savetitle; // Was wttitle = wtitle;
                  int i = 0;
                  if (loadFanart) // Download Fanart
                  {
                    if (dlgPrgrs != null) dlgPrgrs.SetLine(1, "Loading Fanart for '" + savetitle + "'");

                    foreach (string backdrop in listemovies[dlg.SelectedLabel - 1].Backdrops)
                    {
                      filename1 = Grabber.GrabUtil.DownloadBacdropArt(MyFilms.conf.StrPathFanart, backdrop, savetitle, true, first, out filename);
                      if (dlgPrgrs != null) dlgPrgrs.SetLine(2, "loading '" + System.IO.Path.GetFileName(filename) + "'");
                      if (dlgPrgrs != null) dlgPrgrs.Percentage = i * 100 / listemovies[dlg.SelectedLabel - 1].Backdrops.Count;
                      LogMyFilms.Debug("Fanart " + filename1.Substring(filename1.LastIndexOf("\\") + 1) + " downloaded for " + savetitle);

                      if (filename == string.Empty) filename = filename1;
                      if (!(filename == "already" && filename1 == "already")) filename = "added";
                      first = false;
                      i++;
                    }
                  }
                  #endregion

                  listemovies[0].Name = filename;

                  if (loadPersonImages) // Download PersonArtwork
                  {
                    string filenameperson = string.Empty;
                    string filename1person = string.Empty;
                    LogMyFilms.Debug("Person Artwork - " + listemovies[0].Persons.Count + " persons found - now loading artwork");
                    if (!string.IsNullOrEmpty(personartworkpath) && listemovies[0].Persons != null &&
                        listemovies[0].Persons.Count > 0)
                    {
                      if (dlgPrgrs != null) dlgPrgrs.SetLine(1, "Loading person images for '" + wttitle + "'");
                      if (dlgPrgrs != null) dlgPrgrs.SetLine(2, "");

                      foreach (DbPersonInfo person in listemovies[0].Persons)
                      {
                        bool firstpersonimage = true;
                        bool onlysinglepersonimage = true;
                        var persondetails = new DbPersonInfo();
                        var theMoviedb = new TheMoviedb();
                        persondetails = theMoviedb.GetPersonsById(person.Id, string.Empty);
                        LogMyFilms.Debug("Person Artwork: found '" + persondetails.Images.Count + "' TMDB images for '" + persondetails.Name + "' in movie '" + savetitle + "'");
                        if (dlgPrgrs != null) dlgPrgrs.SetLine(2, "loading '" + persondetails.Name + "'");
                        if (dlgPrgrs != null) dlgPrgrs.Percentage = 0;

                        if (persondetails.Images.Count > 0)
                        {
                          i = 0;
                          foreach (var image in persondetails.Images)
                          {
                            filename1person = Grabber.GrabUtil.DownloadPersonArtwork(personartworkpath, image, persondetails.Name, true, firstpersonimage, out filenameperson);
                            if (dlgPrgrs != null) dlgPrgrs.SetLine(2, "loading '" + persondetails.Name + "' (TMDB - #" + i + ")");
                            if (dlgPrgrs != null) dlgPrgrs.Percentage = i * 100 / persondetails.Images.Count;

                            LogMyFilms.Debug("Person Artwork " + filename1person.Substring(filename1person.LastIndexOf("\\") + 1) + " downloaded for '" + persondetails.Name + "' in movie '" + savetitle + "', path='" + filename1person + "'");
                            if (filenameperson == string.Empty) filenameperson = filename1person;
                            if (!(filenameperson == "already" && filename1person == "already")) filenameperson = "added";
                            firstpersonimage = false;
                            i++;
                            if (onlysinglepersonimage) break;
                          }
                        }
                      }
                    }
                    else if (string.IsNullOrEmpty(personartworkpath)) LogMyFilms.Debug("No Personartwork loaded - Personartworkpath is not set in setup!");
                  }
                  if (dlgPrgrs != null) dlgPrgrs.Percentage = 100;
                  dlgPrgrs.ShowWaitCursor = false;
                  dlgPrgrs.SetLine(1, GUILocalizeStrings.Get(1079846));
                  dlgPrgrs.SetLine(2, "");
                  Thread.Sleep(50);
                  dlgPrgrs.Close(); // Done...
                  return;
                }
              }
              break;
          }
        }
        catch (Exception ex)
        {
          LogMyFilms.Debug(ex, "Thread 'MyFilmsTMDBLoader' - exception!");
        }
        GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) =>
        {
          //dlgPrgrs.ShowWaitCursor = false;
          // enter here what to load after background thread has finished !
          if (DetailsUpdated != null) DetailsUpdated(true);
          return 0;
        }, 0, 0, null);
      }) { Name = "MyFilmsTMDBLoader", IsBackground = true }.Start();
    }
Exemplo n.º 4
0
        public ArrayList ReturnURL(string strSearch, string strConfigFile, int strPage, bool alwaysAsk, string strMediaPath)
        {
            string strFileBasedReader = string.Empty;
              string strURLFile = string.Empty;
              string strDBName = string.Empty;
              string cleanup = string.Empty;

              XmlDocument doc = new XmlDocument();
              doc.Load(strConfigFile);
              XmlNode n = doc.ChildNodes[1].FirstChild;

              try { strDBName = XmlConvert.DecodeName(n.SelectSingleNodeFast("DBName").InnerText); }
              catch { strDBName = "ERROR"; }
              try { strURLFile = XmlConvert.DecodeName(n.SelectSingleNodeFast("URLSearch/URL").InnerText); }
              catch { strURLFile = ""; }
              try { strFileBasedReader = XmlConvert.DecodeName(n.SelectSingleNodeFast("FileBasedReader").InnerText); }
              catch { strFileBasedReader = "false"; }
              try { cleanup = XmlConvert.DecodeName(n.SelectSingleNodeFast("SearchCleanup").InnerText); }
              catch (Exception) { cleanup = string.Empty; }

              if (strFileBasedReader == "true" || strSearch.Contains("\\")) // if a mediapath is given and file name is part of the search expression... assume it's nfo/xml/xbmc reader request and return the proper file to read in details
              {
            #region read from file - mediapath

            if (string.IsNullOrEmpty(strMediaPath) && strSearch.Contains("\\")) strMediaPath = strSearch;

            elements.Clear();
            if (!string.IsNullOrEmpty(strURLFile))
            {
              try
              {
            string directory = Path.GetDirectoryName(strMediaPath); // get directory name of media file
            string filename = Path.GetFileNameWithoutExtension(strMediaPath); // get filename without extension
            //strSearch = GrabUtil.EncodeSearch(strSearch);
            foreach (string file in Directory.GetFiles(directory, strURLFile.Replace("#Filename#", filename), SearchOption.TopDirectoryOnly))   // search exact match
            {
              string fileShortname = Path.GetFileName(file);
              var url = new IMDBUrl(file, fileShortname, strDBName, n, "1");
              LogMyFilms.Debug("ReturnURL() - Found and adding nfo file '" + fileShortname + "', fullpath = '" + file + "'");
              elements.Add(url);
            }
            if (elements.Count == 0) // if no results found, try searching with cleaned filename
            {
              foreach (var file in Directory.GetFiles(directory, strURLFile.Replace("#Filename#", GrabUtil.ReplaceNormalOrRegex(filename, cleanup)), SearchOption.TopDirectoryOnly))   // cleanup filename for better search results
              {
                string fileShortname = Path.GetFileName(file);
                var url = new IMDBUrl(file, fileShortname, strDBName, n, "1");
                LogMyFilms.Debug("ReturnURL() - Found and adding nfo file '" + fileShortname + "', fullpath = '" + file + "'");
                elements.Add(url);
              }
            }
              }
              catch (Exception e)
              {
            LogMyFilms.Debug(e, "ReturnURL() - Catched Exception: " + e.Message);
              }
            }
            #endregion
            return elements;
              }

              // if no local grabbing, do web grabbing:
              if (strPage == -1)
              {
            // First run, finding the key starting page number
            //Loading the configuration file
            //XmlDocument doc = new XmlDocument();
            //doc.Load(strConfigFile);
            //XmlNode n = doc.ChildNodes[1].FirstChild;
            //Gets Key to the first page if it exists (not required)
            try
            { strPage = Convert.ToInt16(XmlConvert.DecodeName(n.SelectSingleNodeFast("URLSearch/KeyStartPage").InnerText)); }
            catch
            { strPage = 1; }
              }
              var grab = new GrabberUrlClass();
              Int16 wIndex;
              do
              {
            if (strSearch.LastIndexOf(".", StringComparison.Ordinal) == strSearch.Length - 1)
              strSearch = strSearch.Substring(0, strSearch.Length - 1);
            else
              break;
              } while (true);
              grab.FindMovies(strSearch, strConfigFile, strPage, alwaysAsk, out elements, out wIndex);
              if (wIndex >= 0)
              {
            IMDBUrl wurl = (IMDBUrl)elements[wIndex];
            elements.Clear();
            elements.Add(wurl);
              }
              return elements;
        }
Exemplo n.º 5
0
    public static bool GrabActorDetails(string url, string wscript, out IMDBActor person)
    {
      LogMyFilms.Debug("launching (GrabActorDetails) with url = '" + url + "', wscript = '" + wscript + "'");

      person = new IMDBActor();
      var Grab = new GrabberUrlClass();
      var Result = new string[80];

      #region load internet data
      try
      {
        Result = Grab.GetDetail(url, "", wscript, false, null, null, null, null);
        // Result = Grab.GetDetail(url, downLoadPath, wscript, true, MyFilms.conf.GrabberOverrideLanguage, MyFilms.conf.GrabberOverridePersonLimit, MyFilms.conf.GrabberOverrideTitleLimit, MyFilms.conf.GrabberOverrideGetRoles, null);
        for (int i = 0; i < 40; i++) // copy mapped values to original values
        {
          Result[i] = Result[i + 40];
        }
      }
      catch (Exception ex)
      {
        LogMyFilms.Error(ex, "GrabActorDetails() - exception = '" + ex.Message + "'");
        return false;
      }
      #endregion

      #region load details data for person
      person.Name = Result[(int)GrabberUrlClass.Grabber_Output.OriginalTitle];
      person.DateOfBirth = Result[(int)GrabberUrlClass.Grabber_Output.Comments];
      person.PlaceOfBirth = Result[(int)GrabberUrlClass.Grabber_Output.Country];
      person.Biography = Result[(int)GrabberUrlClass.Grabber_Output.Description];
      person.ThumbnailUrl = Result[(int)GrabberUrlClass.Grabber_Output.PictureURL];
      #endregion
      LogMyFilms.Debug("GrabActorDetails() done for person : '" + person.Name + "'");
      return true;
    }
Exemplo n.º 6
0
    //-------------------------------------------------------------------------------------------
    //  Dowload TMDBinfos (Poster(s), Movieinfos) on theMovieDB.org
    //-------------------------------------------------------------------------------------------        
    public static void Download_TMDB_Posters(string wtitle, string wttitle, string director, string year, bool choose, int wGetID, string savetitle, GUIAnimation searchanimation)
    {
      string oldPicture = getGUIProperty("picture");
      string newPicture = ""; // full path to new picture
      string newPictureCatalogname = ""; // entry to be stored in catalog
      if (string.IsNullOrEmpty(oldPicture)) oldPicture = "";

      if (!Directory.Exists(MyFilms.conf.StrPathImg + "\\" + MyFilms.conf.StrPicturePrefix))
        try
        {
          Directory.CreateDirectory(MyFilms.conf.StrPathImg + "\\" + MyFilms.conf.StrPicturePrefix);
        }
        catch (Exception) { }
      var grab = new GrabberUrlClass();
      string language = CultureInfo.CurrentCulture.Name.Substring(0, 2);
      int wyear = 0;
      try { wyear = Convert.ToInt32(year); }
      catch { }
      new Thread(delegate()
        {
          try
          {
            SetProcessAnimationStatus(true, searchanimation); // GUIWaitCursor.Init(); GUIWaitCursor.Show();
            List<DbMovieInfo> listemovies = grab.GetTMDBinfos(wtitle, wttitle, wyear, director, MyFilms.conf.StrPathImg + "\\" + MyFilms.conf.StrPicturePrefix, true, choose, MyFilms.conf.StrTitle1, language);
            SetProcessAnimationStatus(false, searchanimation); // GUIWaitCursor.Hide();
            LogMyFilms.Debug("(TMDB-Infos) - listemovies: '" + wtitle + "', '" + wttitle + "', '" + wyear + "', '" + director + "', '" + MyFilms.conf.StrPathImg + "\\" + MyFilms.conf.StrPicturePrefix + "', 'true', '" + choose.ToString() + "', '" + MyFilms.conf.StrTitle1 + "', '" + language + "'");
            int listCount = listemovies.Count;
            LogMyFilms.Debug("(TMDB-Infos) - listemovies: Result Listcount: '" + listCount + "'");

            if (choose)
              listCount = 2;
            switch (listCount)
            {
              case 0:
                break;
              case 1:
                LogMyFilms.Info("Posters " + listemovies[0].Name.Substring(listemovies[0].Name.LastIndexOf("\\") + 1) + " downloaded for " + wttitle);
                break;
              default:

                const int MinChars = 2;
                const bool Filter = true;

                var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                if (dlg == null) return;
                dlg.Reset();
                dlg.SetHeading(GUILocalizeStrings.Get(1079857)); // Load TMDB data (online)
                dlg.Add("  *****  " + GUILocalizeStrings.Get(1079860) + "  *****  "); //manual selection
                foreach (DbMovieInfo t in listemovies)
                {
                  dlg.Add(t.Name + "  (" + t.Year + ") - Posters: " + t.Posters.Count + " - Id" + t.Identifier);
                  LogMyFilms.Debug("TMDB listemovies: " + t.Name + "  (" + t.Year + ") - Posters: " + t.Posters.Count + " - TMDB-Id: " + t.Identifier);
                }
                if (!(dlg.SelectedLabel > -1))
                {
                  dlg.SelectedLabel = -1;
                  dlg.DoModal(wGetID);
                }
                if (dlg.SelectedLabel == 0)
                {
                  #region Get SubTitles and Subwords from otitle and ttitle
                  GUIDialogMenu dlgs = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                  if (dlgs == null) return;
                  dlgs.Reset();
                  dlgs.SetHeading(GUILocalizeStrings.Get(1079859)); // choose search expression
                  dlgs.Add("  *****  " + GUILocalizeStrings.Get(1079858) + "  *****  "); //manual selection with keyboard
                  // First Show Dialog to choose Otitle, Ttitle or substrings - or Keyboard to manually enter searchstring!!!
                  //dlgs.Add(wtitle); //Otitle
                  dlgs.Add(savetitle); //Otitle = savetitle
                  dlgs.Add(wttitle); //Ttitle
                  foreach (object t in MyFilms.SubTitleGrabbing(wtitle))
                  {
                    if (t.ToString().Length > 1) dlgs.Add(t.ToString());
                  }
                  foreach (object t in from object t in MyFilms.SubTitleGrabbing(wttitle) where t.ToString().Length > 1 select t) dlgs.Add(t.ToString());
                  foreach (string t in MyFilms.SubWordGrabbing(wtitle, MinChars, Filter).Where(t => t.Length > 1)) dlgs.Add(t);
                  foreach (string t in MyFilms.SubWordGrabbing(wttitle, MinChars, Filter).Where(t => t.Length > 1)) dlgs.Add(t);
                  //Now all titles and Substrings listed in dialog !
                  //dlgs.Add("  *****  " + GUILocalizeStrings.Get(1079860) + "  *****  "); //manual selection
                  if (!(dlgs.SelectedLabel > -1))
                  {
                    dlgs.SelectedLabel = -1;
                    dlgs.DoModal(wGetID);
                  }
                  if (dlgs.SelectedLabel == 0)
                  {
                    var keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
                    if (null == keyboard) return;
                    keyboard.Reset();
                    keyboard.SetLabelAsInitialText(false); // set to false, otherwise our intial text is cleared
                    keyboard.Text = wtitle;
                    keyboard.DoModal(wGetID);
                    if ((keyboard.IsConfirmed) && (keyboard.Text.Length > 0))
                    {
                      Download_TMDB_Posters(keyboard.Text, wttitle, string.Empty, string.Empty, true, wGetID, savetitle, searchanimation);
                    }
                    break;
                  }
                  if (dlgs.SelectedLabel > 0 && dlgs.SelectedLabel < 3) // if one of otitle or ttitle selected, keep year and director
                  {
                    Download_TMDB_Posters(dlgs.SelectedLabelText, wttitle, year, director, true, wGetID, savetitle, searchanimation);
                    //Download_TMDB_Posters(string wtitle, string wttitle, string director, string year, bool choose,int wGetID, string savetitle)
                    break;
                  }
                  if (dlgs.SelectedLabel > 2) // For subitems, search without year and director !
                  {
                    Download_TMDB_Posters(dlgs.SelectedLabelText, wttitle, string.Empty, string.Empty, true, wGetID, savetitle, searchanimation);
                    //Download_TMDB_Posters(string wtitle, string wttitle, string director, string year, bool choose,int wGetID, string savetitle)
                    break;
                  }
                  #endregion
                }
                if (dlg.SelectedLabel > 0)
                {
                  // Load Posters  -> show progress dialog !

                  GUIDialogProgress dlgPrgrs = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS);
                  if (dlgPrgrs != null)
                  {
                    dlgPrgrs.Reset();
                    dlgPrgrs.DisplayProgressBar = true;
                    dlgPrgrs.ShowWaitCursor = false;
                    dlgPrgrs.DisableCancel(true);
                    dlgPrgrs.SetHeading("MyFilms Artwork Download");
                    dlgPrgrs.StartModal(GUIWindowManager.ActiveWindow);
                    dlgPrgrs.SetLine(1, "Loading Artwork ...");
                    dlgPrgrs.Percentage = 0;

                    bool first = true;
                    string filename = string.Empty;
                    string filename1 = string.Empty;
                    if (MyFilms.conf.StrTitle1 == "OriginalTitle")
                      wttitle = savetitle; // Was wttitle = wtitle;
                    int i = 0;
                    if (dlgPrgrs != null) dlgPrgrs.SetLine(1, "Loading Poster for '" + savetitle + "'");
                    foreach (string poster in listemovies[dlg.SelectedLabel - 1].Posters)
                    {
                      filename1 = Grabber.GrabUtil.DownloadCovers(MyFilms.conf.StrPathImg + "\\" + MyFilms.conf.StrPicturePrefix, poster, wttitle, true, first, out filename);
                      if (dlgPrgrs != null) dlgPrgrs.SetLine(2, "loading '" + System.IO.Path.GetFileName(filename) + "'");
                      if (dlgPrgrs != null) dlgPrgrs.Percentage = i * 100 / listemovies[dlg.SelectedLabel - 1].Posters.Count;
                      LogMyFilms.Info("Poster " + filename1.Substring(filename1.LastIndexOf("\\") + 1) + " downloaded for " + wttitle);
                      if (first)
                        newPicture = filename1;
                      if (filename == string.Empty)
                        filename = filename1;
                      if (!(filename == "already" && filename1 == "already"))
                        filename = "added";
                      first = false;
                      i++;
                    }
                    foreach (string person in listemovies[dlg.SelectedLabel - 1].Actors)
                    {
                      // ToDo: Load Actorinfodetails (API Call to be written in grabber) and download Person Artwork
                    }
                    listemovies[0].Name = filename;

                    newPictureCatalogname = GetPictureCatalogNameFromFilename(newPicture);

                    if (wGetID != MyFilms.ID_MyFilmsCoverManager)
                    {
                      if (!choose)
                      {
                        MyFilms.r[MyFilms.conf.StrIndex]["Picture"] = newPictureCatalogname;
                        Update_XML_database();
                        LogMyFilms.Info("(Update_XML_database()) - Database Updated for created Coverthumb: " + newPicture);
                      }
                      else
                      {
                        //TMDB_Details_Select();
                        setGUIProperty("picture", newPicture);
                        GUIWindowManager.Process(); // To Update GUI display ...

                        var dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                        dlgYesNo.SetHeading(GUILocalizeStrings.Get(1079870)); // choice
                        dlgYesNo.SetLine(1, "");
                        dlgYesNo.SetLine(2, GUILocalizeStrings.Get(10798733)); // Replace cover with new one
                        dlgYesNo.SetLine(3, "");
                        dlgYesNo.DoModal(wGetID);
                        if (!(dlgYesNo.IsConfirmed))
                        {
                          setGUIProperty("picture", oldPicture);
                          GUIWindowManager.Process();
                          return;
                        }
                        MyFilms.r[MyFilms.conf.StrIndex]["Picture"] = newPictureCatalogname;
                        Update_XML_database();
                        LogMyFilms.Info("(Update_XML_database()) - Database Updated with '" + newPictureCatalogname + "' for created Coverthumb '" + newPicture + "'");
                      }
                    }
                  }
                  if (dlgPrgrs != null) dlgPrgrs.Percentage = 100; dlgPrgrs.ShowWaitCursor = false; dlgPrgrs.SetLine(1, GUILocalizeStrings.Get(1079846)); dlgPrgrs.SetLine(2, ""); Thread.Sleep(50); dlgPrgrs.Close(); // Done...
                  // return;
                }
                break;
            }
          }
          catch (Exception ex)
          {
            LogMyFilms.Debug(ex, "Thread 'MyFilmsTMDBLoader' - exception!");
          }
          GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) =>
            {
              if (DetailsUpdated != null) DetailsUpdated(true);
              return 0;
            }, 0, 0, null);
        }) { Name = "MyFilmsTMDBLoader", IsBackground = true }.Start();
    }
Exemplo n.º 7
0
 public static ArrayList FindActor(string personname, string wscript)
 {
   var listUrl = new ArrayList();
   if (string.IsNullOrEmpty(wscript)) return listUrl;
   LogMyFilms.Debug("FindActor() with name = '" + personname + "', grabberfile = '" + wscript + "'");
   var grab = new GrabberUrlClass();
   try
   {
     listUrl = grab.ReturnURL(personname, wscript, 1, false, "");
   }
   catch (Exception ex)
   {
     LogMyFilms.Error(ex, "FindActor() - exception = '" + ex.Message + "'");
   }
   return listUrl;
 }
Exemplo n.º 8
0
    private static void GrabArtwork(string title, string ttitle, int year, string director, string imdbid, string StrTitle1, GUIDialogProgress dlgPrgrs)
    {
      try
      {
        if (dlgPrgrs != null)
          dlgPrgrs.SetLine(1, "Now loading Fanart ...");

        if (dlgPrgrs != null && !dlgPrgrs.ShouldRenderLayer())
          return;

        if (dlgPrgrs != null)
          dlgPrgrs.Percentage = 10;

        var grab = new GrabberUrlClass();
        List<DbMovieInfo> listemovies = grab.GetFanart(title, ttitle, year, director, imdbid, MyFilms.conf.StrPathFanart, true, false, StrTitle1, string.Empty);
      }
      catch (Exception ex)
      {
        LogMyFilms.Debug("GrabArtwork() - Error getting fanart: " + ex.Message);
      }
      finally
      {
        if (dlgPrgrs != null)
        {
          dlgPrgrs.Percentage = 100;
          dlgPrgrs.SetLine(1, "Finished loading Fanart !");
          dlgPrgrs.ShowWaitCursor = false;
          Thread.Sleep(500);
          dlgPrgrs.Close();
        }
      }
    }
Exemplo n.º 9
0
    //-------------------------------------------------------------------------------------------
    //  Grab Internet Movie Details Informations and update the XML database and refresh screen
    //-------------------------------------------------------------------------------------------        
    public static void grabb_Internet_Details_Informations(string url, string moviehead, string wscript, int GetID, bool interactive, GrabType grabtype, Searchtitles sTitles, GUIAnimation searchanimation)
    {
      LogMyFilms.Debug("launching (grabb_Internet_Details_Informations) with url = '" + url + "', moviehead = '" + moviehead + "', wscript = '" + wscript + "', GetID = '" + GetID + "', interactive = '" + interactive + "'");

      #region set environment
      var Grab = new GrabberUrlClass();
      var Result = new string[80];
      string title = string.Empty;
      string ttitle = string.Empty;
      string wtitle = string.Empty;
      int year = 0;
      string director = string.Empty;
      // Those settings were used in the past from AMCupdater settings - now they exist in MF config as primary source!
      // XmlConfig XmlConfig = new XmlConfig();
      // string Img_Path = XmlConfig.ReadAMCUXmlConfig(MyFilms.conf.StrAMCUpd_cnf, "Image_Download_Filename_Prefix", "");
      // string Img_Path_Type = XmlConfig.ReadAMCUXmlConfig(MyFilms.conf.StrAMCUpd_cnf, "Store_Image_With_Relative_Path", "false");

      string downLoadPath; //downLoadPath = MyFilmsSettings.GetPath(MyFilmsSettings.Path.MyFilmsPath);
      if (interactive)
        downLoadPath = Path.GetTempPath();
      else
      {
        downLoadPath = grabtype == GrabType.Person
                         ? MyFilms.conf.StrPathArtist
                         : MyFilms.conf.StrPathImg + "\\" + MyFilms.conf.StrPicturePrefix;
      }
      LogMyFilms.Debug("Grabber - GetDetail: OverrideLanguage = '" + MyFilms.conf.GrabberOverrideLanguage + "', OverridePersonLimit = '" + MyFilms.conf.GrabberOverridePersonLimit + "', OverrideTitleLimit = '" + MyFilms.conf.GrabberOverrideTitleLimit + "', Get Roles = '" + MyFilms.conf.GrabberOverrideGetRoles + "'");
      LogMyFilms.Debug("Grabber - GetDetail: script = '" + wscript + "', url = '" + url + "', download path = '" + downLoadPath + "'");
      #endregion

      new Thread(delegate()
          {
            #region load internet data
            var dlgPrgrs = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS);
            if (interactive)
            {
              if (dlgPrgrs != null)
              {
                dlgPrgrs.Reset();
                dlgPrgrs.DisplayProgressBar = false;
                dlgPrgrs.ShowWaitCursor = true;
                dlgPrgrs.DisableCancel(true);
                dlgPrgrs.SetHeading(string.Format("{0} - {1}", "MyFilms", "Internet Updates"));
                dlgPrgrs.SetLine(1, "Loading Details ...");
                dlgPrgrs.Percentage = 0;
                dlgPrgrs.NeedRefresh();
                dlgPrgrs.ShouldRenderLayer();
                dlgPrgrs.StartModal(GUIWindowManager.ActiveWindow);
              }

            }
            try
            {
              Result = Grab.GetDetail(url, downLoadPath, wscript, true, MyFilms.conf.GrabberOverrideLanguage, MyFilms.conf.GrabberOverridePersonLimit, MyFilms.conf.GrabberOverrideTitleLimit, MyFilms.conf.GrabberOverrideGetRoles, null);
            }
            catch (Exception ex) { LogMyFilms.Error(ex, "grabb_Internet_Details_Information() - exception = '" + ex.Message + "'"); }

            if (interactive)
            {
              // SetProcessAnimationStatus(false, searchanimation);
              if (dlgPrgrs != null)
              {
                dlgPrgrs.ShowWaitCursor = false;
                dlgPrgrs.Close();
              }
            }

            // copy mapped values to original values
            for (int i = 0; i < 40; i++)
            {
              LogMyFilms.Debug("Grabber Details: original: '" + i + "' - '" + Result[i] + "'");
              Result[i] = Result[i + 40];
              LogMyFilms.Debug("Grabber Details: mapped  : '" + i + "' - '" + Result[i] + "'");
            }
            LogMyFilms.Debug("Grab Internet Information done for title/ttitle: " + MyFilms.r[MyFilms.conf.StrIndex]["OriginalTitle"] + "/" + MyFilms.r[MyFilms.conf.StrIndex]["TranslatedTitle"]);

            // string Title_Group = XmlConfig.ReadAMCUXmlConfig(MyFilms.conf.StrAMCUpd_cnf, "Folder_Name_Is_Group_Name", "false");
            // string Title_Group_Apply = XmlConfig.ReadAMCUXmlConfig(MyFilms.conf.StrAMCUpd_cnf, "Group_Name_Applies_To", "");
            #endregion

            if (grabtype == GrabType.Details || grabtype == GrabType.All) // grabtype "all" includes cover
            {
              #region Movie Details

              string strChoice = "all"; // defaults to "all", if no other choice
              bool onlyselected = false;
              bool onlymissing = false;
              bool onlynonempty = false;
              var choiceViewMenu = new List<string>();
              var updateItems = new List<string>(); // store properties to update for later use ...
              const int iPropertyLengthLimit = 33;
              var PropertyList = new string[] {
                        "OriginalTitle", "TranslatedTitle", "Picture", "Description", "Rating", "Actors", "Director",
                        "Producer", "Year", "Country", "Category", "URL", "ImageURL", "Writer", "Comments", "Languages",
                        "TagLine", "Certification", "IMDB_Id", "IMDB_Rank", "Studio", "Edition", "Fanart", "Generic1",
                        "Generic2", "Generic3", "TranslatedTitleAllNames", "TranslatedTitleAllValues",
                        "CertificationAllNames", "CertificationAllValues", "MultiPosters", "Photos", "PersonImages",
                        "MultiFanart", "Trailer", "TMDB_Id", "Runtime", "Collection", "CollectionImageURL", "PictureURL"
                      };

              if (interactive) // Dialog only in interactive mode
              {
                #region interactive selection dialog
                var dlgmenu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                bool returnToMainDialog = false; // by default do NOT repeat the dialog - only if returning from sub dialogs
                do
                {
                  #region set main selection dialog for options
                  returnToMainDialog = false;
                  choiceViewMenu.Clear();
                  dlgmenu.Reset();
                  dlgmenu.SetHeading(GUILocalizeStrings.Get(10798797)); // Choose update option ...
                  dlgmenu.Add(" *** " + GUILocalizeStrings.Get(10798734) + " *** ");
                  choiceViewMenu.Add("all");
                  dlgmenu.Add(" *** " + GUILocalizeStrings.Get(10798735) + " *** ");
                  choiceViewMenu.Add("missing");
                  dlgmenu.Add(" *** " + GUILocalizeStrings.Get(10798730) + " *** ");
                  choiceViewMenu.Add("all-onlynewdata");
                  // disabled, as we now have the multiselect dialog
                  //dlgmenu.Add(" *** " + GUILocalizeStrings.Get(10798798) + " *** "); // Select single field for update ...
                  //choiceViewMenu.Add("singlefield");
                  if (File.Exists(GUIGraphicsContext.Skin + @"\MyFilmsDialogMultiSelect.xml"))
                  {
                    dlgmenu.Add(" *** " + GUILocalizeStrings.Get(10798799) + " *** "); // Select multiple fields for update ...
                    choiceViewMenu.Add("multiplefields");
                  }
                  dlgmenu.DoModal(GetID);
                  if (dlgmenu.SelectedLabel == -1) return;
                  strChoice = choiceViewMenu[dlgmenu.SelectedLabel];

                  #endregion

                  if (strChoice == "singlefield")
                  {
                    #region populate select menu, if user has chosen to ...

                    string strOldValue = "";
                    string strNewValue = "";

                    var dlgSelect = (GUIDialogSelect)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_SELECT); // GUIDialogSelect2 dlgmenu = (GUIDialogSelect2)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_SELECT2);  
                    if (dlgSelect == null) return;
                    choiceViewMenu.Clear();
                    dlgSelect.Reset();
                    dlgSelect.SetHeading(GUILocalizeStrings.Get(10798732)); // choose property to update
                    dlgSelect.SetButtonLabel("");

                    int i = 0;
                    foreach (string wProperty in PropertyList)
                    {
                      try
                      {
                        strOldValue = MyFilms.r[MyFilms.conf.StrIndex][wProperty].ToString() ?? "";
                        strNewValue = Result[i];
                        if (i == 2) strNewValue = Result[12];
                        if (strNewValue == null) strNewValue = "";

                        if ( // make sure, only supported fields are offered to user for update
                          wProperty != "ImageURL" && !wProperty.Contains("Sub") && !wProperty.Contains("All") &&
                          !wProperty.Contains("Generic") && !wProperty.Contains("Empty") &&
                          ((wProperty != "TagLine" && wProperty != "Certification" && wProperty != "Writer" &&
                            wProperty != "Studio" && wProperty != "Edition" && wProperty != "IMDB_Id" &&
                            wProperty != "IMDB_Rank" && wProperty != "TMDB_Id") ||
                           MyFilms.conf.StrFileType == MyFilmsPlugin.MyFilmsGUI.Configuration.CatalogType.AntMovieCatalog4Xtended) &&
                          wProperty != "Fanart" && wProperty != "Aspectratio" && wProperty != "MultiPosters"
                          // set to enabled to get proper selection - WIP
                          && wProperty != "Photos" && wProperty != "PersonImages" && wProperty != "MultiFanart" &&
                          wProperty != "Trailer") //  && wProperty != "Runtime" && wProperty != "Collection"
                        {
                          dlgSelect.Add(BaseMesFilms.TranslateColumn(wProperty) + ": '" + Helper.LimitString(strOldValue.Replace(Environment.NewLine, " # "), iPropertyLengthLimit) + "' -> '" + Helper.LimitString(strNewValue.Replace(Environment.NewLine, " # "), iPropertyLengthLimit) + "'");
                          choiceViewMenu.Add(wProperty);
                          LogMyFilms.Debug("GrabberUpdate - Add (" + wProperty + "): '" + strOldValue + "' -> '" + strNewValue + "'");
                        }
                        else
                        {
                          LogMyFilms.Debug("GrabberUpdate - not added (unsupported) - (" + wProperty + "): '" + strOldValue + "' -> '" + strNewValue + "'");
                        }
                      }
                      catch (Exception ex)
                      {
                        LogMyFilms.Debug("GrabberUpdate - cannot add Property '" + wProperty + "' to Selectionmenu - reason: " + ex.Message);
                      }
                      i = i + 1;
                    }

                    dlgSelect.DoModal(GetID);
                    if (dlgSelect.SelectedLabel == -1) returnToMainDialog = true; // Nothing was selected - return to main selection menu
                    strChoice = choiceViewMenu[dlgmenu.SelectedLabel];

                    #endregion
                  }

                  if (choiceViewMenu[dlgmenu.SelectedLabel] == "multiplefields")
                  {
                    #region populate multi selection menu, if user has chosen to ...

                    string strOldValue = "";
                    string strNewValue = "";

                    var dlgMultiSelectOld = (GUIWindow)GUIWindowManager.GetWindow(2100);
                    var dlgMultiSelect = new GUIDialogMultiSelect();
                    if (dlgMultiSelect == null) return;
                    dlgMultiSelect.Init();
                    GUIWindowManager.Replace(2100, dlgMultiSelect);
                    try
                    {
                      dlgMultiSelect.Reset();
                      dlgMultiSelect.SetHeading(GUILocalizeStrings.Get(10798732)); // choose property to update

                      int i = 0;
                      foreach (string wProperty in PropertyList)
                      {
                        try
                        {
                          strOldValue = MyFilms.r[MyFilms.conf.StrIndex][wProperty].ToString() ?? "";
                          strNewValue = Result[i];
                          if (i == (int)GrabberUrlClass.Grabber_Output.PicturePathLong) strNewValue = Result[(int)GrabberUrlClass.Grabber_Output.PicturePathShort];
                          if (strNewValue == null) strNewValue = "";

                          if ( // make sure, only supported fields are offered to user for update
                            wProperty != "ImageURL" && !wProperty.Contains("Sub") && !wProperty.Contains("All") &&
                            !wProperty.Contains("Generic") && !wProperty.Contains("Empty") &&
                            ((wProperty != "TagLine" && wProperty != "Certification" && wProperty != "Writer" &&
                              wProperty != "Studio" && wProperty != "Edition" && wProperty != "IMDB_Id" &&
                              wProperty != "IMDB_Rank" && wProperty != "TMDB_Id") ||
                             MyFilms.conf.StrFileType == MyFilmsPlugin.MyFilmsGUI.Configuration.CatalogType.AntMovieCatalog4Xtended) &&
                            wProperty != "Fanart" && wProperty != "Aspectratio" && wProperty != "MultiPosters"
                            // set to enabled to get proper selection - WIP
                            && wProperty != "Photos" && wProperty != "PersonImages" && wProperty != "MultiFanart" &&
                            wProperty != "Trailer") //  && wProperty != "Collection" && wProperty != "CollectionImageURL"
                          {
                            var pItem = new GUIListItem(wProperty);
                            pItem.TVTag = wProperty;
                            if (i == (int)GrabberUrlClass.Grabber_Output.PicturePathLong) pItem.IconImage = Result[(int)GrabberUrlClass.Grabber_Output.PicturePathLong];
                            pItem.Selected = false;
                            pItem.Label = BaseMesFilms.TranslateColumn(wProperty) + ": '" + Helper.LimitString(strOldValue.Replace(Environment.NewLine, " # "), iPropertyLengthLimit) + "' -> '" + Helper.LimitString(strNewValue.Replace(Environment.NewLine, " # "), iPropertyLengthLimit) + "'";
                            dlgMultiSelect.Add(pItem);
                            LogMyFilms.Debug("GrabberUpdate - Add (" + wProperty + "): '" + strOldValue + "' -> '" + strNewValue + "'");
                          }
                          else
                          {
                            LogMyFilms.Debug("GrabberUpdate - not added (unsupported) - (" + wProperty + "): '" + strOldValue + "' -> '" + strNewValue + "'");
                          }
                        }
                        catch (Exception ex)
                        {
                          LogMyFilms.Debug("GrabberUpdate - cannot add Property '" + wProperty + "' to Selectionmenu - reason: " + ex.Message);
                        }
                        i = i + 1;
                      }

                      dlgMultiSelect.DoModal(GetID);
                      updateItems.AddRange(from t in dlgMultiSelect.ListItems where t.Selected select t.TVTag.ToString());
                      LogMyFilms.Debug("GrabberUpdate - '" + updateItems.Count + "' updateItems selected !");
                      if (dlgMultiSelect.DialogModalResult == ModalResult.Cancel) return; // user cancelled
                      if (dlgMultiSelect.DialogModalResult == ModalResult.OK && updateItems.Count == 0) return; // Nothing was selected
                      if (dlgMultiSelect.DialogModalResult != ModalResult.OK) returnToMainDialog = true; // user wants to return to options menu
                    }
                    finally
                    {
                      GUIWindowManager.Replace(2100, dlgMultiSelectOld);
                    }

                    #endregion
                  }

                  switch (strChoice) // either an update type - or a single property to update
                  {
                    #region switch update options

                    case "all":
                      onlyselected = false;
                      onlymissing = false;
                      onlynonempty = false;
                      break;
                    case "missing":
                      onlyselected = false;
                      onlymissing = true;
                      onlynonempty = false;
                      break;
                    case "all-onlynewdata":
                      onlyselected = false;
                      onlymissing = false;
                      onlynonempty = true;
                      break;
                    default:
                      onlyselected = true;
                      onlymissing = false;
                      onlynonempty = false;
                      break;

                    #endregion
                  }
                }
                while (returnToMainDialog);
                LogMyFilms.Debug("GrabInternetDetails - interactive choice: '" + strChoice + "', onlyselected = '" + onlyselected + "', onlymissing = '" + onlymissing + "', onlynonempty = '" + onlynonempty + "'");
                #endregion
              }

              #region load details data

              // ********************************** now load data, if requested ! ******************************
              if (IsUpdateRequired("OriginalTitle", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["OriginalTitle"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.OriginalTitle], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
              {
                title = Result[(int)GrabberUrlClass.Grabber_Output.OriginalTitle];
                wtitle = MyFilms.r[MyFilms.conf.StrIndex]["OriginalTitle"].ToString();
                if (wtitle.Contains(MyFilms.conf.TitleDelim)) wtitle = wtitle.Substring(wtitle.LastIndexOf(MyFilms.conf.TitleDelim) + 1);
                if (wtitle != title) Remove_Backdrops_Fanart(wtitle, true);

                // Add Collection from internet grabber
                if (!string.IsNullOrEmpty(Result[(int)GrabberUrlClass.Grabber_Output.Collection]) && string.IsNullOrEmpty(moviehead))
                {
                  moviehead = Result[(int)GrabberUrlClass.Grabber_Output.Collection] + @"\";
                }
                if (MyFilms.conf.StrTitle1 == "OriginalTitle") MyFilms.r[MyFilms.conf.StrIndex]["OriginalTitle"] = moviehead + title;
                else MyFilms.r[MyFilms.conf.StrIndex]["OriginalTitle"] = title;
              }

              if (IsUpdateRequired("TranslatedTitle", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["TranslatedTitle"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.TranslatedTitle], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
              {
                ttitle = Result[(int)GrabberUrlClass.Grabber_Output.TranslatedTitle];
                if ("TranslatedTitle" == strChoice)
                {
                  if (string.IsNullOrEmpty(ttitle) && MyFilms.conf.StrTitle1 == "TranslatedTitle" && !string.IsNullOrEmpty(MyFilms.r[MyFilms.conf.StrIndex]["TranslatedTitle"].ToString())) // Added to fill ttitle with otitle in case ttitle is empty and mastertitle = ttitle and mastertitle is empty
                    ttitle = Result[(int)GrabberUrlClass.Grabber_Output.OriginalTitle];
                }
                wtitle = MyFilms.r[MyFilms.conf.StrIndex]["TranslatedTitle"].ToString();
                if (wtitle.Contains(MyFilms.conf.TitleDelim)) wtitle = wtitle.Substring(wtitle.LastIndexOf(MyFilms.conf.TitleDelim) + 1);
                if (wtitle != ttitle) Remove_Backdrops_Fanart(wtitle, true);
                if (MyFilms.conf.StrTitle1 == "TranslatedTitle")
                {
                  // Add Collection from internet grabber
                  if (!string.IsNullOrEmpty(Result[(int)GrabberUrlClass.Grabber_Output.Collection]) && string.IsNullOrEmpty(moviehead))
                  {
                    moviehead = Result[(int)GrabberUrlClass.Grabber_Output.Collection] + @"\";
                  }
                  MyFilms.r[MyFilms.conf.StrIndex]["TranslatedTitle"] = moviehead + ttitle;
                }
                else MyFilms.r[MyFilms.conf.StrIndex]["TranslatedTitle"] = ttitle;
              }

              //if (IsUpdateRequired("Collection", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Collection"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Collection], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
              //  MyFilms.r[MyFilms.conf.StrIndex]["Collection"] = Result[(int)GrabberUrlClass.Grabber_Output.Collection];

              if (IsUpdateRequired("Description", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Description"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Description], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                MyFilms.r[MyFilms.conf.StrIndex]["Description"] = Result[(int)GrabberUrlClass.Grabber_Output.Description];

              if (IsUpdateRequired("Rating", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Rating"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Rating], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
              {
                if (Result[(int)GrabberUrlClass.Grabber_Output.Rating].Length > 0)
                {
                  var provider = new NumberFormatInfo();
                  provider.NumberDecimalSeparator = ".";
                  provider.NumberDecimalDigits = 1;
                  decimal wnote = Convert.ToDecimal(Result[(int)GrabberUrlClass.Grabber_Output.Rating], provider);
                  if (string.IsNullOrEmpty(MyFilms.r[MyFilms.conf.StrIndex]["Rating"].ToString()) || !onlymissing)
                    MyFilms.r[MyFilms.conf.StrIndex]["Rating"] = string.Format("{0:F1}", wnote);
                }
              }
              if (IsUpdateRequired("Actors", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Actors"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Actors], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                if (string.IsNullOrEmpty(MyFilms.r[MyFilms.conf.StrIndex]["Actors"].ToString()) || !onlymissing)
                  MyFilms.r[MyFilms.conf.StrIndex]["Actors"] = Result[(int)GrabberUrlClass.Grabber_Output.Actors];
              if (IsUpdateRequired("Director", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Director"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Director], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
              {
                director = Result[(int)GrabberUrlClass.Grabber_Output.Director];
                MyFilms.r[MyFilms.conf.StrIndex]["Director"] = Result[(int)GrabberUrlClass.Grabber_Output.Director];
              }
              if (IsUpdateRequired("Producer", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Producer"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Producer], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                MyFilms.r[MyFilms.conf.StrIndex]["Producer"] = Result[(int)GrabberUrlClass.Grabber_Output.Producer];
              if (IsUpdateRequired("Year", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Year"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Year], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
              {
                try { year = Convert.ToInt16(Result[(int)GrabberUrlClass.Grabber_Output.Year]); }
                catch { year = 1900; }
                MyFilms.r[MyFilms.conf.StrIndex]["Year"] = year.ToString();
              }

              if (IsUpdateRequired("Country", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Country"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Country], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                MyFilms.r[MyFilms.conf.StrIndex]["Country"] = Result[(int)GrabberUrlClass.Grabber_Output.Country];
              if (IsUpdateRequired("Category", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Category"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Category], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                MyFilms.r[MyFilms.conf.StrIndex]["Category"] = Result[(int)GrabberUrlClass.Grabber_Output.Category];
              if (IsUpdateRequired("URL", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["URL"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.URL], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                if (MyFilms.conf.StrStorage != "URL")
                  MyFilms.r[MyFilms.conf.StrIndex]["URL"] = Result[(int)GrabberUrlClass.Grabber_Output.URL];
              if (IsUpdateRequired("Comments", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Comments"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Comments], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                MyFilms.r[MyFilms.conf.StrIndex]["Comments"] = Result[(int)GrabberUrlClass.Grabber_Output.Comments];
              if (IsUpdateRequired("Languages", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Languages"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Language], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                MyFilms.r[MyFilms.conf.StrIndex]["Languages"] =
                  Result[(int)GrabberUrlClass.Grabber_Output.Language];

              #region AMC4 extended fields
              if (MyFilms.conf.StrFileType == MyFilmsPlugin.MyFilmsGUI.Configuration.CatalogType.AntMovieCatalog4Xtended)
              {
                if (IsUpdateRequired("Writer", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Writer"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Writer], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                  MyFilms.r[MyFilms.conf.StrIndex]["Writer"] = Result[(int)GrabberUrlClass.Grabber_Output.Writer];
                if (IsUpdateRequired("TagLine", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["TagLine"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Tagline], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                  MyFilms.r[MyFilms.conf.StrIndex]["TagLine"] = Result[(int)GrabberUrlClass.Grabber_Output.Tagline];
                if (IsUpdateRequired("Certification", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Certification"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Certification], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                  MyFilms.r[MyFilms.conf.StrIndex]["Certification"] = Result[(int)GrabberUrlClass.Grabber_Output.Certification];
                if (IsUpdateRequired("IMDB_Id", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["IMDB_Id"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.IMDB_Id], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                  MyFilms.r[MyFilms.conf.StrIndex]["IMDB_Id"] = Result[(int)GrabberUrlClass.Grabber_Output.IMDB_Id];
                if (IsUpdateRequired("IMDB_Rank", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["IMDB_Rank"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.IMDB_Rank], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                  MyFilms.r[MyFilms.conf.StrIndex]["IMDB_Rank"] = Result[(int)GrabberUrlClass.Grabber_Output.IMDB_Rank];
                if (IsUpdateRequired("TMDB_Id", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["TMDB_Id"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.TMDB_Id], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                  MyFilms.r[MyFilms.conf.StrIndex]["TMDB_Id"] = Result[(int)GrabberUrlClass.Grabber_Output.TMDB_Id];
                if (IsUpdateRequired("Studio", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Studio"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Studio], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                  MyFilms.r[MyFilms.conf.StrIndex]["Studio"] = Result[(int)GrabberUrlClass.Grabber_Output.Studio];
                if (IsUpdateRequired("Edition", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Edition"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Edition], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                  MyFilms.r[MyFilms.conf.StrIndex]["Edition"] = Result[(int)GrabberUrlClass.Grabber_Output.Edition];
                //if (IsUpdateRequired("Fanart", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Fanart"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Fanart], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) 
                //  MyFilms.r[MyFilms.conf.StrIndex]["Fanart"] = Result[(int)GrabberUrlClass.Grabber_Output.Fanart];
                //if (IsUpdateRequired("Trailer", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Trailer"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.Trailer], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) 
                //  MyFilms.r[MyFilms.conf.StrIndex]["Trailer"] = Result[(int)GrabberUrlClass.Grabber_Output.Trailer];
              }
              #endregion

              if (grabtype == GrabType.All && IsUpdateRequired("Picture", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Picture"].ToString(), Result[(int)GrabberUrlClass.Grabber_Output.PicturePathLong], grabtype, onlyselected, onlymissing, onlynonempty, updateItems))
                grabb_Internet_Details_Informations_Cover(Result, interactive, GetID, wscript, grabtype, sTitles);

              #endregion

              #endregion
            }

            if (grabtype == GrabType.Person)
            {
              #region Person

              #region Load existing person info
              IMDBActor person = null;
              var actorList = new ArrayList();
              VideoDatabase.GetActorByName(MyFilms.conf.StrTIndex, actorList);
              LogMyFilms.Debug("GrabberUpdate - found '" + actorList.Count + "' results for '" + MyFilms.conf.StrTIndex + "'");
              if (actorList.Count > 0 && actorList.Count < 5)
              {
                LogMyFilms.Debug("IMDB first search result: '" + actorList[0] + "'");
                string[] strActor = actorList[0].ToString().Split(new char[] { '|' });
                // int actorID = (strActor[0].Length > 0 && strActor.Count() > 1) ? Convert.ToInt32(strActor[0]) : 0; // string actorname = strActor[1];
                int actorId;
                int.TryParse(strActor[0], out actorId);
                person = actorId > 0 ? VideoDatabase.GetActorInfo(actorId) : new IMDBActor();
              }
              #endregion

              string strChoice = "all"; // defaults to "all", if no other choice
              var imageUrls = new Dictionary<string, string>();

              if (interactive) // Dialog only in interactive mode
              #region interactive selection dialog
              {
                var choiceViewMenu = new List<string>();
                var dlgmenu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                dlgmenu.Reset();
                dlgmenu.SetHeading(GUILocalizeStrings.Get(10798797)); // Choose update option ...
                dlgmenu.Add(" *** " + GUILocalizeStrings.Get(10798734) + " *** ");
                choiceViewMenu.Add("all");
                dlgmenu.Add(" *** " + GUILocalizeStrings.Get(10798735) + " *** ");
                choiceViewMenu.Add("missing");
                dlgmenu.Add(" *** " + GUILocalizeStrings.Get(10798730) + " *** ");
                choiceViewMenu.Add("all-onlynewdata");

                //if (File.Exists(GUIGraphicsContext.Skin + @"\MyFilmsDialogMultiSelect.xml"))
                //{
                //  dlgmenu.Add(" *** " + GUILocalizeStrings.Get(10798799) + " *** "); // Select multiple fields for update ...
                //  choiceViewMenu.Add("multiplefields");
                //}
                #region populate selection menu

                string[] PropertyList = new string[]
                      {
                        // "TMDB_Id", "IMDB_Id",
                        "OriginalTitle", // Name
                        "TranslatedTitle", // also known as (currently not supported)
                        "Picture", 
                        "Description", // biographie
                        "Comments", 
                        "Rating", // rating (if available)
                        "Actors", // filmographie
                        "Year", 
                        "Country", // birthplace
                        "URL", // URL to webpage
                        "Generic1", "Generic2", "Generic3", 
                        // "Photos", 
                        "PersonImages", // all images, if available
                        "PictureURL" // webUrl to main picture
                      };
                string personProperty;
                string strOldValue = "";
                string strNewValue = "";

                try
                {
                  personProperty = "name";
                  strOldValue = person != null && person.Name.Length > 0 ? person.Name : "";
                  strNewValue = Result[(int)GrabberUrlClass.Grabber_Output.OriginalTitle];
                  dlgmenu.Add(GUILocalizeStrings.Get(10799301) + ": '" + strOldValue.Replace(Environment.NewLine, " # ") + "' -> '" + strNewValue.Replace(Environment.NewLine, " # ") + "'");
                  choiceViewMenu.Add(personProperty);
                  LogMyFilms.Debug("GrabberUpdate - Add to menu (" + personProperty + "): '" + strOldValue + "' -> '" + strNewValue + "'");

                  personProperty = "dateofbirth";
                  strOldValue = person != null && person.DateOfBirth.Length > 0 ? person.DateOfBirth : "";
                  strNewValue = Result[(int)GrabberUrlClass.Grabber_Output.Comments];
                  dlgmenu.Add(GUILocalizeStrings.Get(10799302) + ": '" + strOldValue.Replace(Environment.NewLine, " # ") + "' -> '" + strNewValue.Replace(Environment.NewLine, " # ") + "'");
                  choiceViewMenu.Add(personProperty);
                  LogMyFilms.Debug("GrabberUpdate - Add to menu (" + personProperty + "): '" + strOldValue + "' -> '" + strNewValue + "'");

                  personProperty = "placeofbirth";
                  strOldValue = person != null && person.PlaceOfBirth.Length > 0 ? person.PlaceOfBirth : "";
                  strNewValue = Result[(int)GrabberUrlClass.Grabber_Output.Country];
                  dlgmenu.Add(GUILocalizeStrings.Get(10799303) + ": '" + strOldValue.Replace(Environment.NewLine, " # ") + "' -> '" + strNewValue.Replace(Environment.NewLine, " # ") + "'");
                  choiceViewMenu.Add(personProperty);
                  LogMyFilms.Debug("GrabberUpdate - Add to menu (" + personProperty + "): '" + strOldValue + "' -> '" + strNewValue + "'");

                  personProperty = "biography";
                  strOldValue = person != null && person.Biography.Length > 0 ? person.Biography : "";
                  strNewValue = Result[(int)GrabberUrlClass.Grabber_Output.Description];
                  dlgmenu.Add(GUILocalizeStrings.Get(10799304) + ": '" + strOldValue.Replace(Environment.NewLine, " # ") + "' -> '" + strNewValue.Replace(Environment.NewLine, " # ") + "'");
                  choiceViewMenu.Add(personProperty);
                  LogMyFilms.Debug("GrabberUpdate - Add to menu (" + personProperty + "): '" + strOldValue + "' -> '" + strNewValue + "'");
#if MP13
                  strOldValue = (person != null && person.DateOfDeath.Length > 0) ? person.DateOfDeath : "";
                  strOldValue = (person != null && person.PlaceOfDeath.Length > 0) ? person.PlaceOfDeath : "";
                  strOldValue = (person != null && person.LastUpdate.Length > 0) ? person.LastUpdate : "";
#endif
                  // main image
                  personProperty = "coverimage";
                  strOldValue = person != null && person.ThumbnailUrl.Length > 0 ? person.ThumbnailUrl : "";
                  strNewValue = Result[(int)GrabberUrlClass.Grabber_Output.PictureURL];
                  dlgmenu.Add(GUILocalizeStrings.Get(10798682) + ": '" + strOldValue.Replace(Environment.NewLine, " # ") + "' -> '" + strNewValue.Replace(Environment.NewLine, " # ") + "'");
                  choiceViewMenu.Add(personProperty);
                  imageUrls.Add(personProperty, strNewValue);
                  LogMyFilms.Debug("GrabberUpdate - Add to menu (" + personProperty + "): '" + strOldValue + "' -> '" + strNewValue + "'");

                  // add additional images, if returned by grabber
                  string multipersonimages = Result[(int)GrabberUrlClass.Grabber_Output.PersonImages];
                  LogMyFilms.Debug("GrabberUpdate - multipersonimages = '" + multipersonimages + "'");
                  int i = 1;
                  string[] personimagesUrls = multipersonimages.Split(new char[] { ',', '|' });
                  Regex reg = new Regex(@"\(((?!\)).)*\)");
                  foreach (string personimagesUrl in personimagesUrls)
                  {
                    personProperty = "coverimage" + i.ToString();
                    strNewValue = reg.Replace(personimagesUrl, "").Trim();
                    if (strNewValue != Result[(int)GrabberUrlClass.Grabber_Output.PictureURL]) // do not add main image twice!
                    {
                      dlgmenu.Add(GUILocalizeStrings.Get(10798682) + " " + i.ToString() + ": '" + strOldValue.Replace(Environment.NewLine, " # ") + "' -> '" + strNewValue.Replace(Environment.NewLine, " # ") + "'");
                      choiceViewMenu.Add(personProperty);
                      imageUrls.Add(personProperty, strNewValue);
                      LogMyFilms.Debug("GrabberUpdate - Add to menu (" + personProperty + "): '" + strOldValue + "' -> '" + strNewValue + "'");
                      i++;
                    }
                  }
                }
                catch (Exception ex)
                {
                  LogMyFilms.Debug("GrabberUpdate - Error adding Person property to Selectionmenu: " + ex.Message);
                }
                #endregion

                dlgmenu.DoModal(GetID);
                if (dlgmenu.SelectedLabel == -1) return;
                strChoice = choiceViewMenu[dlgmenu.SelectedLabel];
                LogMyFilms.Debug("GrabInternetDetails - interactive choice: '" + strChoice + "'");
              }
              #endregion

              #region load details data for person
              switch (strChoice)
              {
                case "name":
                  person.Name = Result[(int)GrabberUrlClass.Grabber_Output.OriginalTitle];
                  break;
                case "dateofbirth":
                  person.DateOfBirth = Result[(int)GrabberUrlClass.Grabber_Output.Comments];
                  break;
                case "placeofbirth":
                  person.PlaceOfBirth = Result[(int)GrabberUrlClass.Grabber_Output.Country];
                  break;
                case "biography":
                  person.Biography = Result[(int)GrabberUrlClass.Grabber_Output.Description];
                  break;
                case "coverimage":
                  person.ThumbnailUrl = Result[(int)GrabberUrlClass.Grabber_Output.PictureURL];
                  // ToDo: Download Image
                  break;

                case "all":
                  person.Name = Result[(int)GrabberUrlClass.Grabber_Output.OriginalTitle];
                  person.DateOfBirth = Result[(int)GrabberUrlClass.Grabber_Output.Comments];
                  person.PlaceOfBirth = Result[(int)GrabberUrlClass.Grabber_Output.Country];
                  person.Biography = Result[(int)GrabberUrlClass.Grabber_Output.Description];
                  person.ThumbnailUrl = Result[(int)GrabberUrlClass.Grabber_Output.PictureURL];
                  // ToDo: Download Image
                  break;

                case "missing":
                  if (string.IsNullOrEmpty(person.Name)) person.Name = Result[(int)GrabberUrlClass.Grabber_Output.OriginalTitle];
                  if (string.IsNullOrEmpty(person.DateOfBirth)) person.DateOfBirth = Result[(int)GrabberUrlClass.Grabber_Output.Comments];
                  if (string.IsNullOrEmpty(person.PlaceOfBirth)) person.PlaceOfBirth = Result[(int)GrabberUrlClass.Grabber_Output.Country];
                  if (string.IsNullOrEmpty(person.Biography)) person.Biography = Result[(int)GrabberUrlClass.Grabber_Output.Description];
                  if (string.IsNullOrEmpty(person.ThumbnailUrl)) person.ThumbnailUrl = Result[(int)GrabberUrlClass.Grabber_Output.PictureURL];
                  // ToDo: Download Image
                  break;

                case "all-onlynewdata":
                  if (string.IsNullOrEmpty(Result[(int)GrabberUrlClass.Grabber_Output.OriginalTitle])) person.Name = Result[(int)GrabberUrlClass.Grabber_Output.OriginalTitle];
                  if (string.IsNullOrEmpty(Result[(int)GrabberUrlClass.Grabber_Output.Comments])) person.DateOfBirth = Result[(int)GrabberUrlClass.Grabber_Output.Comments];
                  if (string.IsNullOrEmpty(Result[(int)GrabberUrlClass.Grabber_Output.Country])) person.PlaceOfBirth = Result[(int)GrabberUrlClass.Grabber_Output.Country];
                  if (string.IsNullOrEmpty(Result[(int)GrabberUrlClass.Grabber_Output.Description])) person.Biography = Result[(int)GrabberUrlClass.Grabber_Output.Description];
                  if (string.IsNullOrEmpty(Result[(int)GrabberUrlClass.Grabber_Output.PictureURL]) && Result[(int)GrabberUrlClass.Grabber_Output.PictureURL].ToLower().StartsWith("http")) person.ThumbnailUrl = Result[(int)GrabberUrlClass.Grabber_Output.PictureURL];
                  // ToDo: Download Image
                  break;

                default:
                  if (strChoice.StartsWith("coverimage"))
                  {
                    person.ThumbnailUrl = imageUrls[strChoice];
                    LogMyFilms.Debug("GrabInternetDetails - set person URL to: " + person.ThumbnailUrl);
                  }
                  break;
              }

              LogMyFilms.Debug("GrabInternetDetails - downloadimage: '" + Result[(int)GrabberUrlClass.Grabber_Output.PicturePathLong]);

              #region Add or update actor to video database
              try
              {
                //#if MP1X
                //                  int actorId = VideoDatabase.AddActor(person.Name);
                //#else
                //                  int actorId = VideoDatabase.AddActor(null, person.Name);
                //#endif
                int actorId = GUIUtils.AddActor(null, person.Name);
                if (actorId > 0)
                {
                  if (!string.IsNullOrEmpty(person.Biography)) // clean up before saving ...
                  {
                    if (person.Biography.StartsWith("From Wikipedia, the free encyclopedia")) person.Biography = person.Biography.Replace("From Wikipedia, the free encyclopedia", "").TrimStart(new char[] { '.' }).Trim(new char[] { ' ', '\r', '\n' });
                  }
                  VideoDatabase.SetActorInfo(actorId, person);
                  //VideoDatabase.AddActorToMovie(_movieDetails.ID, actorId);
                }
              }
              catch (Exception ex) { LogMyFilms.Debug("Error adding person to VDB: " + ex.Message, ex.StackTrace); }
              #endregion

              #region load missing images ...
              if (!string.IsNullOrEmpty(MyFilms.conf.StrPathArtist) && !string.IsNullOrEmpty(person.ThumbnailUrl))
              {
                string filename = MyFilms.conf.StrPathArtist + "\\" + person.Name + ".jpg";  // string filename = Path.Combine(MyFilms.conf.StrPathArtist, personname); //File.Exists(MyFilms.conf.StrPathArtist + "\\" + personsname + ".jpg")))
                if (person.ThumbnailUrl.Contains("http:") && (strChoice == "all" || strChoice == "all-onlynewdata" || (!File.Exists(filename) && strChoice == "missing") || strChoice.StartsWith("coverimage")))
                {
                  #region MP Thumb download deactivated, as downloading not yet working !!!
                  //if (person.ThumbnailUrl != string.Empty) // to update MP person thumb dir
                  //{
                  //  string largeCoverArt = Utils.GetLargeCoverArtName(Thumbs.MovieActors, person.Name);
                  //  string coverArt = Utils.GetCoverArtName(Thumbs.MovieActors, person.Name);
                  //  Utils.FileDelete(largeCoverArt);
                  //  Utils.FileDelete(coverArt);
                  //  IMDBFetcher.DownloadCoverArt(Thumbs.MovieActors, person.ThumbnailUrl, person.Name);
                  //  //DownloadCoverArt(Thumbs.MovieActors, imdbActor.ThumbnailUrl, imdbActor.Name);
                  //}
                  #endregion
                  string filename1person = GrabUtil.DownloadPersonArtwork(MyFilms.conf.StrPathArtist, person.ThumbnailUrl, person.Name, false, true, out filename);
                }
              }
              #endregion
              // grabb_Internet_Details_Informations_Cover(Result, interactive, GetID, wscript, grabtype, sTitles);

              #endregion

              #endregion
            }

            if (grabtype == GrabType.Cover)
            {
              #region Cover

              if (string.IsNullOrEmpty(Result[(int)GrabberUrlClass.Grabber_Output.PicturePathLong]))
              {
                if (interactive)
                {
                  GUIUtils.ShowOKDialog(GUILocalizeStrings.Get(10798625));  // no results found
                  // grabb_Internet_Informations(FullMovieName, GetID, true, wscript, FullMoviePath, grabtype, showAll);
                }
                return;
              }
              grabb_Internet_Details_Informations_Cover(Result, interactive, GetID, wscript, grabtype, sTitles);

              #endregion
            }

            if (grabtype == GrabType.MultiCovers)
            {
              #region MultiCovers

              if (string.IsNullOrEmpty(Result[(int)GrabberUrlClass.Grabber_Output.MultiPosters]))
              {
                // no data found
                if (interactive)
                {
                  GUIUtils.ShowOKDialog(GUILocalizeStrings.Get(10798625));  // no results found
                  // grabb_Internet_Informations(FullMovieName, GetID, true, wscript, FullMoviePath, grabtype, showAll);
                }
                return;
              }
              grabb_Internet_Details_Informations_Cover(Result, interactive, GetID, wscript, grabtype, sTitles);

              #endregion
            }

            Update_XML_database();
            LogMyFilms.Info("Database Updated for title/ttitle: " + title + "/" + ttitle);

            if (GetID != MyFilms.ID_MyFilmsCoverManager)
              if (title.Length > 0 && MyFilms.conf.StrFanart && grabtype != GrabType.Person) // Get Fanart
              {
                #region fanart

                // GUIDialogProgress dlgPrgrs = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); // already defined above !
                if (dlgPrgrs != null)
                {
                  dlgPrgrs.Reset();
                  dlgPrgrs.DisplayProgressBar = false;
                  dlgPrgrs.ShowWaitCursor = true;
                  dlgPrgrs.DisableCancel(true);
                  dlgPrgrs.SetHeading(string.Format("{0} - {1}", "MyFilms", "Artwork Updater"));
                  dlgPrgrs.SetLine(1, "Loading Artwork ...");
                  dlgPrgrs.Percentage = 0;
                  dlgPrgrs.NeedRefresh();
                  dlgPrgrs.ShouldRenderLayer();
                  dlgPrgrs.StartModal(GUIWindowManager.ActiveWindow);

                  new Thread(delegate()
                      {
                        string imdbid = GetIMDB_Id(MyFilms.r[MyFilms.conf.StrIndex]);
                        GrabArtwork(title, ttitle, year, director, imdbid, MyFilms.conf.StrTitle1, dlgPrgrs);
                        //  dlgPrgrs.Percentage = 100;
                        //  dlgPrgrs.SetLine(1, "Finished loading Movie Details ...");
                        //  dlgPrgrs.NeedRefresh();
                        //  dlgPrgrs.ShouldRenderLayer();
                        //  Thread.Sleep(500);
                        //  dlgPrgrs.ShowWaitCursor = false;
                        //  dlgPrgrs.Close();

                        //GrabArtwork(title, ttitle, (int)year, director, MyFilms.conf.StrTitle1.ToString(), r => 
                        //{
                        //  dlgPrgrs.Percentage = r;
                        //  return dlgPrgrs.ShouldRenderLayer();
                        //});
                        GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) =>
                            { return 0; }, 0, 0, null);
                      }) { Name = "MyFilmsArtworkLoader", IsBackground = true }.Start();
                  return;
                }
                // System.Collections.Generic.List<grabber.DBMovieInfo> listemovies = Grab.GetFanart(title, ttitle, (int)year, director, MyFilms.conf.StrPathFanart, true, false, MyFilms.conf.StrTitle1.ToString());

                #endregion
              }
            GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) =>
                {
                  if (GetID != MyFilms.ID_MyFilmsCoverManager)
                    if (DetailsUpdated != null) DetailsUpdated(true); // will launch screen update with new data, if handler registered
                  return 0;
                }, 0, 0, null);
          }) { Name = "MyFilmsDetailsLoader", IsBackground = true }.Start();
    }
Exemplo n.º 10
0
    //-------------------------------------------------------------------------------------------
    //  Grab URL Internet Movie Informations and update the XML database and refresh screen
    //  -> Search and select matching movie
    //-------------------------------------------------------------------------------------------        
    public static void grabb_Internet_Informations_Search(string fullMovieName, int GetID, string wscript, string fullMoviePath, GrabType grabtype, Searchtitles sTitles, GUIAnimation searchanimation)
    {
      if (string.IsNullOrEmpty(wscript)) return;
      LogMyFilms.Debug("grabb_Internet_Informations_Search() with title = '" + fullMovieName + "', grabberfile = '" + wscript + "'");
      string movieName = fullMovieName;
      string movieHierarchy = string.Empty;
      string moviePath = fullMoviePath;
      if (MyFilms.conf.TitleDelim.Length > 0)
      {
        movieName = fullMovieName.Substring(fullMovieName.LastIndexOf(MyFilms.conf.TitleDelim, StringComparison.Ordinal) + 1).Trim();
        movieHierarchy = fullMovieName.Substring(0, fullMovieName.LastIndexOf(MyFilms.conf.TitleDelim, StringComparison.Ordinal) + 1).Trim();
      }
      var grab = new Grabber.GrabberUrlClass();
      GrabberUrlClass.IMDBUrl wurl;
      var listUrl = new ArrayList();

      new Thread(delegate()
        {
          SetProcessAnimationStatus(true, searchanimation); // GUIWaitCursor.Init(); GUIWaitCursor.Show();
          try
          {
            // listUrl = Grab.ReturnURL(MovieName, wscript, 1, !MyFilms.conf.StrGrabber_Always, MoviePath); // MoviePath only when nfo reader used !!!
            listUrl = grab.ReturnURL(movieName, wscript, 1, !MyFilms.conf.StrGrabber_Always, "");
          }
          catch (Exception ex)
          {
            LogMyFilms.Error(ex, "grabb_Internet_Details_Search() - exception = '" + ex.Message + "'");
          }
          SetProcessAnimationStatus(false, searchanimation); // GUIWaitCursor.Hide();

          int listCount = listUrl.Count;
          if (!MyFilms.conf.StrGrabber_Always)
            listCount = 2;
          switch (listCount)
          {
            case 1: // only one match -> grab details without user interaction
              wurl = (Grabber.GrabberUrlClass.IMDBUrl)listUrl[0];
              grabb_Internet_Details_Informations(wurl.URL, movieHierarchy, wscript, GetID, false, grabtype, sTitles, searchanimation);
              break;
            case 0:
              break;
            default:
              #region manual choice
              var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
              var choiceViewMenu = new List<string>();
              choiceViewMenu.Clear();

              if (dlg == null) return;
              dlg.Reset();
              dlg.SetHeading(GUILocalizeStrings.Get(924)); // menu
              dlg.Add("  *****  " + GUILocalizeStrings.Get(1079860) + "  *****  "); //manual selection
              choiceViewMenu.Add("manual selection");

              for (int i = 0; i < listUrl.Count; i++)
              {
                wurl = (Grabber.GrabberUrlClass.IMDBUrl)listUrl[i];
                if (wurl.Director.Contains(MyFilms.r[MyFilms.conf.StrIndex]["Director"].ToString()) && wurl.Year.Contains(MyFilms.r[MyFilms.conf.StrIndex]["Year"].ToString()) && !MyFilms.conf.StrGrabber_Always)
                {
                  if (dlg.SelectedLabel == -1)
                    dlg.SelectedLabel = i + 1;
                  else
                    dlg.SelectedLabel = -2;
                }
                string viewTitle = wurl.Title;
                if (!string.IsNullOrEmpty(wurl.Year)) viewTitle += " (" + wurl.Year + ")";
                if (!string.IsNullOrEmpty(wurl.Options)) viewTitle += " - " + wurl.Options + "";
                dlg.Add(viewTitle);
                choiceViewMenu.Add(wurl.Title);
              }
              string[] split = movieName.Trim().Split(new Char[] { ' ', '-' }, StringSplitOptions.RemoveEmptyEntries);
              foreach (string s in split.Where(s => s.Length > 2))
              {
                dlg.Add(GUILocalizeStrings.Get(137) + " '" + s + "'"); // add words from title as search items
                choiceViewMenu.Add(s);
              }
              if (grabtype != GrabType.Person)
              {
                #region add all titles as alternative search expressions
                if (!string.IsNullOrEmpty(sTitles.OriginalTitle) && !choiceViewMenu.Contains(sTitles.OriginalTitle))
                {
                  dlg.Add(GUILocalizeStrings.Get(137) + " '" + sTitles.OriginalTitle + "'"); //search
                  choiceViewMenu.Add(sTitles.OriginalTitle);
                }
                if (!string.IsNullOrEmpty(sTitles.TranslatedTitle) && !choiceViewMenu.Contains(sTitles.TranslatedTitle))
                {
                  dlg.Add(GUILocalizeStrings.Get(137) + " '" + sTitles.TranslatedTitle + "'");
                  choiceViewMenu.Add(sTitles.TranslatedTitle);
                }
                if (!string.IsNullOrEmpty(sTitles.FormattedTitle) && !choiceViewMenu.Contains(sTitles.FormattedTitle))
                {
                  dlg.Add(GUILocalizeStrings.Get(137) + " '" + sTitles.FormattedTitle + "'");
                  choiceViewMenu.Add(sTitles.FormattedTitle);
                }
                if (!string.IsNullOrEmpty(sTitles.MovieDirectoryTitle) && !choiceViewMenu.Contains(sTitles.MovieDirectoryTitle))
                {
                  dlg.Add(GUILocalizeStrings.Get(137) + " '" + sTitles.MovieDirectoryTitle + "'");
                  choiceViewMenu.Add(sTitles.MovieDirectoryTitle);
                }
                if (!string.IsNullOrEmpty(sTitles.MovieFileTitle) && !choiceViewMenu.Contains(sTitles.MovieFileTitle))
                {
                  dlg.Add(GUILocalizeStrings.Get(137) + " '" + sTitles.MovieFileTitle + "'");
                  choiceViewMenu.Add(sTitles.MovieFileTitle);
                }
                #endregion
              }

              if (!(dlg.SelectedLabel > -1))
              {
                dlg.SelectedLabel = -1;
                dlg.DoModal(GetID);
              }
              if (dlg.SelectedLabel == 0)
              {
                VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
                if (null == keyboard) return;
                keyboard.Reset();
                keyboard.SetLabelAsInitialText(false); // set to false, otherwise our intial text is cleared
                keyboard.Text = movieName;
                keyboard.DoModal(GetID);
                if (keyboard.IsConfirmed && keyboard.Text.Length > 0)
                  grabb_Internet_Informations_Search(keyboard.Text, GetID, wscript, moviePath, grabtype, sTitles, searchanimation);
                break;
              }
              if (dlg.SelectedLabel > 0 && dlg.SelectedLabel <= listUrl.Count)
              {
                wurl = (GrabberUrlClass.IMDBUrl)listUrl[dlg.SelectedLabel - 1];
                grabb_Internet_Details_Informations(wurl.URL, movieHierarchy, wscript, GetID, true, grabtype, sTitles, searchanimation);
                break;
              }
              if (dlg.SelectedLabel > listUrl.Count)
              {
                //VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
                //if (null == keyboard) return;
                //keyboard.Reset();
                //keyboard.Text = dlg.SelectedLabelText;
                //// keyboard.Text = choiceViewMenu[dlg.SelectedLabel];
                //keyboard.DoModal(GetID);
                //if ((keyboard.IsConfirmed) && (keyboard.Text.Length > 0))
                //  grabb_Internet_Informations_Search(keyboard.Text, GetID, wscript, MoviePath, grabtype, sTitles);
                string strChoice = choiceViewMenu[dlg.SelectedLabel];
                LogMyFilms.Debug("grabb_Internet_Informations_Search(): (re)search with new search expression: '" + strChoice + "'");
                grabb_Internet_Informations_Search(strChoice, GetID, wscript, moviePath, grabtype, sTitles, searchanimation);
              }
              break;
              #endregion
          }
          GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) => { return 0; }, 0, 0, null);
        }) { Name = "MyFilmsDetailsLoader", IsBackground = true }.Start();
    }
Exemplo n.º 11
0
 private void Menu_LoadFanart(bool loadPersonImages)
 {
   Grabber.GrabberUrlClass Grab = new Grabber.GrabberUrlClass();
   string personartworkpath = string.Empty;
   Searchtitles sTitles = GetSearchTitles(MyFilms.r[MyFilms.conf.StrIndex], "");
   string imdbid = GetIMDB_Id(MyFilms.r[MyFilms.conf.StrIndex]);
   if (!string.IsNullOrEmpty(sTitles.FanartTitle) && MyFilms.conf.StrFanart)
   {
     LogMyFilms.Debug("MyFilmsDetails (fanart-menuselect) Download Fanart: originaltitle: '" + sTitles.OriginalTitle + "' - translatedtitle: '" + sTitles.TranslatedTitle + "' - director: '" + sTitles.Director + "' - year: '" + sTitles.Year.ToString() + "'");
     if (MyFilms.conf.UseThumbsForPersons && !string.IsNullOrEmpty(MyFilms.conf.StrPathArtist))
     {
       personartworkpath = MyFilms.conf.StrPathArtist;
       LogMyFilms.Debug("MyFilmsDetails (fanart-menuselect) Download PersonArtwork 'enabled' - destination: '" + personartworkpath + "'");
     }
     doUpdateDetailsViewByFinishEvent = true;
     Download_Backdrops_Fanart(sTitles.OriginalTitle, sTitles.TranslatedTitle, sTitles.FormattedTitle, sTitles.Director, imdbid, sTitles.Year.ToString(), true, GetID, sTitles.FanartTitle, personartworkpath, true, loadPersonImages, m_SearchAnimation);
   }
 }