void Grab_Paint(GrabType t, object sender, PaintEventArgs e) { if (this.grabbing == t) { return; } Cursors.NoMove2D.Draw(e.Graphics, e.ClipRectangle); }
void GrabEnd() { endFramePos = oldInterpolatePos; endFrameRot = oldInterpolateRot; skeleton.transform.localPosition = Vector3.zero; skeleton.transform.localEulerAngles = Vector3.zero; ///save coord skeleton.BlendToSkeleton(blend); RenderModelVisible(!HideController); blendToPose = 0; grabPoser = null; GrabInteractible = null; grabType = GrabType.None; }
void GrabEnd() { endFramePos = transform.parent.InverseTransformPoint(oldInterpolatePos); endFrameRot = oldInterpolateRot; skeleton.transform.localPosition = Vector3.zero; skeleton.transform.localEulerAngles = Vector3.zero; ///save coord skeleton.BlendToSkeleton(blend); renderModelVisible(!hideController); blendToPose = 0; blendToPoseMoveObject = 0; grabPoser = null; grabInteractible = null; grabType = GrabType.None; }
void SelectObject(Vector3 selectPoint, GrabType grabType, Collider[] colliders, ref CustomInteractible interactible) { if (!grabPoser) { colliders = Physics.OverlapSphere(selectPoint, gripRadius, layerColliderChecker); interactible = null; float tempCloseDistance = float.MaxValue; for (int i = 0; i < colliders.Length; i++) { CustomInteractible tempCustomInteractible = colliders[i].GetComponentInParent <CustomInteractible>(); if (tempCustomInteractible != null && tempCustomInteractible.isInteractible && tempCustomInteractible.grabType == grabType) { if (Vector3.Distance(tempCustomInteractible.transform.position, selectPoint) < tempCloseDistance) { tempCloseDistance = Vector3.Distance(tempCustomInteractible.transform.position, selectPoint); interactible = tempCustomInteractible; } } } } else if (grabType == GrabType.Select) // HANDLE SELECT TYPE { if (interactible) { colliders = Physics.OverlapSphere(selectPoint, indexRadius * 2f, layerColliderChecker); if (colliders == null || colliders.Length == 0) { interactible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver); GrabEnd(); interactible = null; return; } for (int i = 0; i < colliders.Length; i++) { CustomInteractible tempCustomInteractible = colliders[i].GetComponentInParent <CustomInteractible>(); if (tempCustomInteractible && tempCustomInteractible == interactible) { return; } } interactible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver); GrabEnd(); interactible = null; } } }
void Grab_MouseDown(GrabType t, object sender, MouseEventArgs e) { HookManager.MouseUp += HookManager_MouseUp; HookManager.MouseMove += HookManager_MouseMove; this.grabbing = t; Cursor.Current = Cursors.NoMove2D; GrabMinion1.Refresh(); GrabMinion2.Refresh(); GrabMinion3.Refresh(); GrabMinion4.Refresh(); GrabMinion5.Refresh(); GrabMinion6.Refresh(); GrabMinion7.Refresh(); GrabMinion8.Refresh(); GrabSend.Refresh(); GrabAdventure.Refresh(); GrabClaim.Refresh(); }
private void InteractionProcessor(CustomInteractible oldgrabInteractible, CustomInteractible grabInteractible, GrabType procGrabType) { if (grabInteractible != oldgrabInteractible) { if (oldgrabInteractible) { oldgrabInteractible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver); } if (grabInteractible) { grabInteractible.SendMessage("GrabStart", this, SendMessageOptions.DontRequireReceiver); setHandTransform = false; grabType = procGrabType; renderModelVisible(!grabInteractible.hideController); SkeletonUpdate(); blendToPose = 1; blendToPoseMoveObject = 1; endFramePos = transform.parent.InverseTransformPoint(skeleton.transform.position); endFrameRot = skeleton.transform.rotation; } } }
void HookManager_MouseUp(object sender, MouseEventArgs e) { HookManager.MouseUp -= HookManager_MouseUp; HookManager.MouseMove -= HookManager_MouseMove; Cursor.Current = Cursors.Default; if (grabLocations.ContainsKey(grabbing) == false) { grabLocations.Add(grabbing, new Point()); } grabLocations[grabbing] = new Point(e.X, e.Y); this.grabbing = GrabType.none; GrabMinion1.Refresh(); GrabMinion2.Refresh(); GrabMinion3.Refresh(); GrabMinion4.Refresh(); GrabMinion5.Refresh(); GrabMinion6.Refresh(); GrabMinion7.Refresh(); GrabMinion8.Refresh(); GrabSend.Refresh(); GrabAdventure.Refresh(); GrabClaim.Refresh(); }
public void GrabCheck() { if (grabType != GrabType.None && GrabInteractible) { if (grabType == GrabType.Pinch && pinchButton.GetStateUp(handType)) { GrabInteractible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver); GrabEnd(); } if (grabType == GrabType.Grip && grabButton.GetStateUp(handType)) { GrabInteractible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver); GrabEnd(); } } if (!grabPoser) { if (blend > 0) { blendToAnimation += 1f / blend * Time.deltaTime; blendToAnimation = Mathf.Clamp01(blendToAnimation); blendToPose += 1f / blendPosition * Time.deltaTime; blendToPose = Mathf.Clamp01(blendToPose); blendToPoseMoveObject += 1f / blendPosition * Time.deltaTime; blendToPoseMoveObject = Mathf.Clamp01(blendToPoseMoveObject); } else { blendToAnimation = 1; } CustomInteractible OldGrabInteractible = GrabInteractible; if (SelectedIndexInteractible) { GrabInteractible = SelectedIndexInteractible; if (GrabInteractible != OldGrabInteractible) { if (OldGrabInteractible) { OldGrabInteractible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver); } if (GrabInteractible) { GrabInteractible.SendMessage("GrabStart", this, SendMessageOptions.DontRequireReceiver); setHandTransform = false; grabType = GrabType.Select; RenderModelVisible(!GrabInteractible.HideController); SkeletonUpdate(); blendToPose = 1; blendToPoseMoveObject = 1; endFramePos = transform.parent.InverseTransformPoint(skeleton.transform.position); endFrameRot = skeleton.transform.rotation; } } } else { if (SelectedPinchInteractible && pinchButton.GetStateDown(handType)) { GrabInteractible = SelectedPinchInteractible; if (GrabInteractible != OldGrabInteractible) { if (OldGrabInteractible) { OldGrabInteractible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver); } if (GrabInteractible) { GrabInteractible.SendMessage("GrabStart", this, SendMessageOptions.DontRequireReceiver); setHandTransform = false; grabType = GrabType.Pinch; RenderModelVisible(!GrabInteractible.HideController); SkeletonUpdate(); blendToPose = 1; blendToPoseMoveObject = 1; endFramePos = transform.parent.InverseTransformPoint(skeleton.transform.position); endFrameRot = skeleton.transform.rotation; } } } else { if (SelectedGpibInteractible && grabButton.GetStateDown(handType)) { GrabInteractible = SelectedGpibInteractible; if (GrabInteractible != OldGrabInteractible) { if (OldGrabInteractible) { OldGrabInteractible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver); } if (GrabInteractible) { GrabInteractible.SendMessage("GrabStart", this, SendMessageOptions.DontRequireReceiver); setHandTransform = false; grabType = GrabType.Grip; RenderModelVisible(!GrabInteractible.HideController); SkeletonUpdate(); blendToPose = 1; blendToPoseMoveObject = 1; endFramePos = transform.parent.InverseTransformPoint(skeleton.transform.position); endFrameRot = skeleton.transform.rotation; } } } } } } }
private static bool IsUpdateRequired(string currentField, string selectedField, string oldvalue, string newvalue, GrabType grabtype, bool onlyselected, bool onlymissing, bool onlynonempty, List<string> updateitems) { bool updaterequired = false; if (currentField == selectedField || !onlyselected || updateitems.Contains(currentField)) { if (onlymissing && string.IsNullOrEmpty(oldvalue) || !onlymissing) { if (onlynonempty && !string.IsNullOrEmpty(newvalue) || !onlynonempty) { if (!string.IsNullOrEmpty(newvalue)) updaterequired = true; } } } LogMyFilms.Debug("IsUpdateRequired(): return '" + updaterequired + "' for: currentField = '" + currentField + "', selectedField = '" + selectedField + "', onlyselected = '" + onlyselected + "', onlymissing = '" + onlymissing + "', onlynonempty = '" + onlynonempty + "'"); return updaterequired; }
private static void grabb_Internet_Details_Informations_Cover(string[] Result, bool interactive, int GetID, string wscript, GrabType grabtype, Searchtitles sTitles) { string tmpPicture = ""; string tmpPicturename = ""; // picturename only string newPicture = ""; // full path to new picture string newPictureCatalogname = ""; // entry to be stored in catalog string oldPicture = MyFilmsDetail.getGUIProperty("picture"); // "save" current picture for later restore... string oldPictureCatalogname = MyFilms.r[MyFilms.conf.StrIndex]["Picture"].ToString(); // set defaults... switch (grabtype) { case GrabType.Cover: case GrabType.All: tmpPicture = Result[(int)Grabber_URLClass.Grabber_Output.PicturePathLong]; tmpPicturename = Result[(int)Grabber_URLClass.Grabber_Output.PicturePathLong].Substring(Result[(int)Grabber_URLClass.Grabber_Output.PicturePathLong].LastIndexOf("\\") + 1); break; case GrabType.MultiCovers: // make difference between existing cover and new one //if (!string.IsNullOrEmpty(MyFilms.r[MyFilms.conf.StrIndex]["Picture"].ToString())) //{ // string tmp = MyFilms.r[MyFilms.conf.StrIndex]["Picture"].ToString(); // if (tmp.Contains("\\")) // { // tmp = tmp.Substring(tmp.LastIndexOf("\\") + 1); // if (tmp.Contains("[")) // tmpPicturename = tmp.Substring(0, tmp.LastIndexOf("[") - 1); // else tmpPicturename = tmp; // } // else tmpPicturename = tmp; //} //if (title.EndsWith(".jpg")) // title = title.Substring(0, title.Length - 4); //string safeName = CreateFilename(title); //string dirname = artFolder; //// string directory = ""; ////if (dirname.Length > dirname.LastIndexOf("\\")) //// directory = dirname.Substring(dirname.LastIndexOf("\\")); ////if (!System.IO.Directory.Exists(directory)) //// System.IO.Directory.CreateDirectory(directory); //if (first && !System.IO.File.Exists(dirname + safeName + ".jpg")) // filename = dirname + safeName + ".jpg"; //else // filename = dirname + safeName + " [" + imageUrl.GetHashCode() + "].jpg"; //FileInfo newFile = new FileInfo(filename); //bool alreadyInFolder = newFile.Exists; if (string.IsNullOrEmpty(tmpPicturename)) { tmpPicturename = sTitles.FanartTitle + ".jpg"; } break; } if (MyFilms.conf.StrPicturePrefix.Length > 0) newPicture = MyFilms.conf.StrPathImg + "\\" + MyFilms.conf.StrPicturePrefix + tmpPicturename; else newPicture = Path.Combine(MyFilms.conf.StrPathImg, tmpPicturename); newPictureCatalogname = GetPictureCatalogNameFromFilename(newPicture); LogMyFilms.Debug("Cover Image path : '" + MyFilms.conf.StrPathImg + "'"); LogMyFilms.Debug("Picturehandling : '" + MyFilms.conf.PictureHandling + "'"); LogMyFilms.Debug("PicturePrefix : '" + MyFilms.conf.StrPicturePrefix + "'"); LogMyFilms.Debug("Temp Cover Image : '" + tmpPicture + "'"); LogMyFilms.Debug("New Cover Image : '" + newPicture + "'"); LogMyFilms.Debug("New Catalog Entry: '" + newPictureCatalogname + "'"); switch (grabtype) { case GrabType.MultiCovers: #region multiple cover images var script = new GrabberScript(wscript); var ArtworkImages = new ArtworkInfo(Result[(int)Grabber_URLClass.Grabber_Output.MultiPosters], script.URLPrefix); var testlist = new List<ArtworkInfoItem>(); testlist = Grabber.GrabUtil.GetMultiImageList(script.URLPrefix, Result[(int)Grabber_URLClass.Grabber_Output.MultiPosters], ""); var choiceViewMenu = new List<string>(); var dlgmenu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); dlgmenu.Reset(); dlgmenu.SetHeading(GUILocalizeStrings.Get(10798764)); // Load Covers ... dlgmenu.Add(GUILocalizeStrings.Get(10798622) + " (" + testlist.Count.ToString() + ")"); //all choiceViewMenu.Add("all"); int i = 0; foreach (Grabber.ArtworkInfoItem artworkImage in testlist) { try { dlgmenu.Add(artworkImage.Name); choiceViewMenu.Add(artworkImage.URL); LogMyFilms.Debug("Coverdownload - Add to menu (" + i + ": " + artworkImage.Name + "): '" + artworkImage.URL + "'"); } catch { } i = i + 1; } dlgmenu.DoModal(GetID); if (dlgmenu.SelectedLabel == -1) return; string strChoice = choiceViewMenu[dlgmenu.SelectedLabel]; LogMyFilms.Debug("GrabInternetDetails - interactive choice: '" + strChoice + "'"); //GrabberScript script = new GrabberScript(wscript); 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(string.Format("{0} - {1}", "MyFilms", "Internet Details Grabber")); dlgPrgrs.SetLine(1, "Loading Cover(s) [" + script.DBName + "] ..."); dlgPrgrs.Percentage = 0; dlgPrgrs.StartModal(GUIWindowManager.ActiveWindow); new System.Threading.Thread(delegate() { try { string filename = string.Empty; string filename1 = string.Empty; string filename2 = string.Empty; //if (MasterTitle == "OriginalTitle") // wtitle2 = wtitle1; bool first = true; int a = 0; if (strChoice != "all") { filename1 = Grabber.GrabUtil.DownloadCovers(MyFilms.conf.StrPathImg + "\\" + MyFilms.conf.StrPicturePrefix, strChoice, tmpPicturename, true, first, out filename); } else { foreach (Grabber.ArtworkInfoItem artworkImage in testlist) { filename1 = GrabUtil.DownloadCovers(MyFilms.conf.StrPathImg + "\\" + MyFilms.conf.StrPicturePrefix, artworkImage.URL, tmpPicturename, true, first, out filename); if (dlgPrgrs != null) dlgPrgrs.SetLine(2, "loading '" + System.IO.Path.GetFileName(filename) + "'"); if (dlgPrgrs != null) dlgPrgrs.Percentage = a * 100 / testlist.Count; LogMyFilms.Info("Poster " + filename1.Substring(filename1.LastIndexOf("\\") + 1) + " downloaded for " + newPictureCatalogname); artworkImage.LocalPath = filename; if (first) newPicture = filename1; if (filename == string.Empty) filename = filename1; if (!(filename == "already" && filename1 == "already")) filename = "added"; first = false; a++; } } } catch (Exception ex) { LogMyFilms.DebugException("Thread 'MyFilmsCoverLoader' - exception! - ", ex); } if (dlgPrgrs != null) dlgPrgrs.Percentage = 100; dlgPrgrs.ShowWaitCursor = false; dlgPrgrs.SetLine(1, GUILocalizeStrings.Get(1079846)); dlgPrgrs.SetLine(2, ""); Thread.Sleep(50); dlgPrgrs.Close(); // Done... GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) => { dlgPrgrs.ShowWaitCursor = false; // enter here what to load after background thread has finished ! if (GetID == MyFilms.ID_MyFilmsCoverManager) { if (DetailsUpdated != null) DetailsUpdated(true); } return 0; }, 0, 0, null); }) { Name = "MyFilmsCoverLoader", IsBackground = true }.Start(); return; } #endregion break; case GrabType.Cover: #region single cover without confirmation dialog if (File.Exists(newPicture)) // if 'base file' already exists, create sub file name Result[(int)Grabber_URLClass.Grabber_Output.Country] { newPicture = Path.Combine(Path.GetDirectoryName(newPicture), Path.GetFileNameWithoutExtension(newPicture) + " [" + Result[(int)Grabber.Grabber_URLClass.Grabber_Output.PictureURL].GetHashCode() + "]" + System.IO.Path.GetExtension(newPicture)); LogMyFilms.Debug("New Cover File Name = '" + newPicture + "'"); } if (newPicture != tmpPicture) { if (!Directory.Exists(newPicture.Substring(0, newPicture.LastIndexOf("\\")))) { try { Directory.CreateDirectory(newPicture.Substring(0, newPicture.LastIndexOf("\\"))); } catch (Exception ex) { LogMyFilms.Debug("Could not create directory '" + newPicture.Substring(0, newPicture.LastIndexOf("\\")) + "' - Exception: " + ex); } } try { LogMyFilms.Debug("Copy '" + tmpPicture + "' to '" + newPicture + "'"); File.Copy(tmpPicture, newPicture, true); } catch (Exception ex) { LogMyFilms.Debug("Error copy file: '" + tmpPicture + "' - Exception: " + ex); } } if (newPicture != tmpPicture) { try { File.Delete(tmpPicture); } catch (Exception ex) { LogMyFilms.Debug("Error deleting tmp file: '" + tmpPicture + "' - Exception: " + ex); } } #endregion break; case GrabType.All: #region single cover if (interactive) { setGUIProperty("picture", tmpPicture); 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(GetID); if (!(dlgYesNo.IsConfirmed)) { setGUIProperty("picture", oldPicture); GUIWindowManager.Process(); return; } else { setGUIProperty("picture", ""); GUIWindowManager.Process(); } } if (newPicture != tmpPicture) { if (!Directory.Exists(newPicture.Substring(0, newPicture.LastIndexOf("\\")))) { try { Directory.CreateDirectory(newPicture.Substring(0, newPicture.LastIndexOf("\\"))); } catch (Exception ex) { LogMyFilms.Debug("Could not create directory '" + newPicture.Substring(0, newPicture.LastIndexOf("\\")) + "' - Exception: " + ex); } } try { File.Copy(tmpPicture, newPicture, true); } catch (Exception ex) { LogMyFilms.Debug("Error copy file: '" + tmpPicture + "' - Exception: " + ex); } } if (newPicture != tmpPicture) { try { File.Delete(tmpPicture); } catch (Exception ex) { LogMyFilms.Debug("Error deleting tmp file: '" + tmpPicture + "' - Exception: " + ex); } } #endregion #region collection image string tmpPictureCollection = Path.GetDirectoryName(tmpPicture) + @"\Collection_" + Path.GetFileName(tmpPicture); string newPictureCollection = MyFilms.conf.StrPathImg + "\\" + MyFilms.conf.StrTitleSelect.Replace(MyFilms.conf.TitleDelim, ".") + "." + sTitles.MasterTitle + ".jpg"; if (System.IO.File.Exists(tmpPictureCollection)) { try { File.Copy(tmpPictureCollection, newPictureCollection, true); LogMyFilms.Debug("Created Collection image '" + newPictureCollection + "'"); } catch (Exception ex) { LogMyFilms.Debug("Error copy file: '" + tmpPictureCollection + "' - Exception: " + ex); } } else { LogMyFilms.Debug("Collection Cover '" + tmpPictureCollection + "' does not exists - do nothing."); } if (newPictureCollection != tmpPictureCollection) { try { File.Delete(tmpPictureCollection); } catch (Exception ex) { LogMyFilms.Debug("Error deleting tmp file: '" + tmpPictureCollection + "' - Exception: " + ex); } } #endregion break; } // update catalog entry in memory if (string.IsNullOrEmpty(MyFilms.r[MyFilms.conf.StrIndex]["Picture"].ToString())) MyFilms.r[MyFilms.conf.StrIndex]["Picture"] = newPictureCatalogname; else if (interactive) MyFilms.r[MyFilms.conf.StrIndex]["Picture"] = newPictureCatalogname; else if (!oldPicture.Contains(oldPictureCatalogname)) MyFilms.r[MyFilms.conf.StrIndex]["Picture"] = newPictureCatalogname; // set picture to new one (full path) setGUIProperty("picture", newPicture); GUIWindowManager.Process(); if (GetID == MyFilms.ID_MyFilmsCoverManager) { if (DetailsUpdated != null) DetailsUpdated(true); } }
//------------------------------------------------------------------------------------------- // 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 Grabber_URLClass(); 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.ErrorException("grabb_Internet_Details_Information() - exception = '" + ex.Message + "'", ex); } 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 == 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)Grabber_URLClass.Grabber_Output.PicturePathLong) strNewValue = Result[(int)Grabber_URLClass.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 == 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)Grabber_URLClass.Grabber_Output.PicturePathLong) pItem.IconImage = Result[(int)Grabber_URLClass.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)Grabber_URLClass.Grabber_Output.OriginalTitle], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) { title = Result[(int)Grabber_URLClass.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)Grabber_URLClass.Grabber_Output.Collection]) && string.IsNullOrEmpty(moviehead)) { moviehead = Result[(int)Grabber_URLClass.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)Grabber_URLClass.Grabber_Output.TranslatedTitle], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) { ttitle = Result[(int)Grabber_URLClass.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)Grabber_URLClass.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)Grabber_URLClass.Grabber_Output.Collection]) && string.IsNullOrEmpty(moviehead)) { moviehead = Result[(int)Grabber_URLClass.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)Grabber_URLClass.Grabber_Output.Collection], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) // MyFilms.r[MyFilms.conf.StrIndex]["Collection"] = Result[(int)Grabber_URLClass.Grabber_Output.Collection]; if (IsUpdateRequired("Description", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Description"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Description], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) MyFilms.r[MyFilms.conf.StrIndex]["Description"] = Result[(int)Grabber_URLClass.Grabber_Output.Description]; if (IsUpdateRequired("Rating", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Rating"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Rating], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) { if (Result[(int)Grabber_URLClass.Grabber_Output.Rating].Length > 0) { var provider = new NumberFormatInfo(); provider.NumberDecimalSeparator = "."; provider.NumberDecimalDigits = 1; decimal wnote = Convert.ToDecimal(Result[(int)Grabber_URLClass.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)Grabber_URLClass.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)Grabber_URLClass.Grabber_Output.Actors]; if (IsUpdateRequired("Director", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Director"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Director], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) { director = Result[(int)Grabber_URLClass.Grabber_Output.Director]; MyFilms.r[MyFilms.conf.StrIndex]["Director"] = Result[(int)Grabber_URLClass.Grabber_Output.Director]; } if (IsUpdateRequired("Producer", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Producer"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Producer], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) MyFilms.r[MyFilms.conf.StrIndex]["Producer"] = Result[(int)Grabber_URLClass.Grabber_Output.Producer]; if (IsUpdateRequired("Year", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Year"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Year], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) { try { year = Convert.ToInt16(Result[(int)Grabber_URLClass.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)Grabber_URLClass.Grabber_Output.Country], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) MyFilms.r[MyFilms.conf.StrIndex]["Country"] = Result[(int)Grabber_URLClass.Grabber_Output.Country]; if (IsUpdateRequired("Category", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Category"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Category], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) MyFilms.r[MyFilms.conf.StrIndex]["Category"] = Result[(int)Grabber_URLClass.Grabber_Output.Category]; if (IsUpdateRequired("URL", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["URL"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.URL], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) if (MyFilms.conf.StrStorage != "URL") MyFilms.r[MyFilms.conf.StrIndex]["URL"] = Result[(int)Grabber_URLClass.Grabber_Output.URL]; if (IsUpdateRequired("Comments", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Comments"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Comments], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) MyFilms.r[MyFilms.conf.StrIndex]["Comments"] = Result[(int)Grabber_URLClass.Grabber_Output.Comments]; if (IsUpdateRequired("Languages", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Languages"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Language], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) MyFilms.r[MyFilms.conf.StrIndex]["Languages"] = Result[(int)Grabber_URLClass.Grabber_Output.Language]; #region AMC4 extended fields if (MyFilms.conf.StrFileType == Configuration.CatalogType.AntMovieCatalog4Xtended) { if (IsUpdateRequired("Writer", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Writer"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Writer], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) MyFilms.r[MyFilms.conf.StrIndex]["Writer"] = Result[(int)Grabber_URLClass.Grabber_Output.Writer]; if (IsUpdateRequired("TagLine", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["TagLine"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Tagline], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) MyFilms.r[MyFilms.conf.StrIndex]["TagLine"] = Result[(int)Grabber_URLClass.Grabber_Output.Tagline]; if (IsUpdateRequired("Certification", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Certification"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Certification], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) MyFilms.r[MyFilms.conf.StrIndex]["Certification"] = Result[(int)Grabber_URLClass.Grabber_Output.Certification]; if (IsUpdateRequired("IMDB_Id", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["IMDB_Id"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.IMDB_Id], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) MyFilms.r[MyFilms.conf.StrIndex]["IMDB_Id"] = Result[(int)Grabber_URLClass.Grabber_Output.IMDB_Id]; if (IsUpdateRequired("IMDB_Rank", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["IMDB_Rank"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.IMDB_Rank], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) MyFilms.r[MyFilms.conf.StrIndex]["IMDB_Rank"] = Result[(int)Grabber_URLClass.Grabber_Output.IMDB_Rank]; if (IsUpdateRequired("TMDB_Id", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["TMDB_Id"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.TMDB_Id], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) MyFilms.r[MyFilms.conf.StrIndex]["TMDB_Id"] = Result[(int)Grabber_URLClass.Grabber_Output.TMDB_Id]; if (IsUpdateRequired("Studio", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Studio"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Studio], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) MyFilms.r[MyFilms.conf.StrIndex]["Studio"] = Result[(int)Grabber_URLClass.Grabber_Output.Studio]; if (IsUpdateRequired("Edition", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Edition"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Edition], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) MyFilms.r[MyFilms.conf.StrIndex]["Edition"] = Result[(int)Grabber_URLClass.Grabber_Output.Edition]; //if (IsUpdateRequired("Fanart", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Fanart"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Fanart], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) // MyFilms.r[MyFilms.conf.StrIndex]["Fanart"] = Result[(int)Grabber_URLClass.Grabber_Output.Fanart]; //if (IsUpdateRequired("Trailer", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Trailer"].ToString(), Result[(int)Grabber_URLClass.Grabber_Output.Trailer], grabtype, onlyselected, onlymissing, onlynonempty, updateItems)) // MyFilms.r[MyFilms.conf.StrIndex]["Trailer"] = Result[(int)Grabber_URLClass.Grabber_Output.Trailer]; } #endregion if (grabtype == GrabType.All && IsUpdateRequired("Picture", strChoice, MyFilms.r[MyFilms.conf.StrIndex]["Picture"].ToString(), Result[(int)Grabber_URLClass.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)Grabber_URLClass.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)Grabber_URLClass.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)Grabber_URLClass.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)Grabber_URLClass.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)Grabber_URLClass.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)Grabber_URLClass.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)Grabber_URLClass.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)Grabber_URLClass.Grabber_Output.OriginalTitle]; break; case "dateofbirth": person.DateOfBirth = Result[(int)Grabber_URLClass.Grabber_Output.Comments]; break; case "placeofbirth": person.PlaceOfBirth = Result[(int)Grabber_URLClass.Grabber_Output.Country]; break; case "biography": person.Biography = Result[(int)Grabber_URLClass.Grabber_Output.Description]; break; case "coverimage": person.ThumbnailUrl = Result[(int)Grabber_URLClass.Grabber_Output.PictureURL]; // ToDo: Download Image break; case "all": person.Name = Result[(int)Grabber_URLClass.Grabber_Output.OriginalTitle]; person.DateOfBirth = Result[(int)Grabber_URLClass.Grabber_Output.Comments]; person.PlaceOfBirth = Result[(int)Grabber_URLClass.Grabber_Output.Country]; person.Biography = Result[(int)Grabber_URLClass.Grabber_Output.Description]; person.ThumbnailUrl = Result[(int)Grabber_URLClass.Grabber_Output.PictureURL]; // ToDo: Download Image break; case "missing": if (string.IsNullOrEmpty(person.Name)) person.Name = Result[(int)Grabber_URLClass.Grabber_Output.OriginalTitle]; if (string.IsNullOrEmpty(person.DateOfBirth)) person.DateOfBirth = Result[(int)Grabber_URLClass.Grabber_Output.Comments]; if (string.IsNullOrEmpty(person.PlaceOfBirth)) person.PlaceOfBirth = Result[(int)Grabber_URLClass.Grabber_Output.Country]; if (string.IsNullOrEmpty(person.Biography)) person.Biography = Result[(int)Grabber_URLClass.Grabber_Output.Description]; if (string.IsNullOrEmpty(person.ThumbnailUrl)) person.ThumbnailUrl = Result[(int)Grabber_URLClass.Grabber_Output.PictureURL]; // ToDo: Download Image break; case "all-onlynewdata": if (string.IsNullOrEmpty(Result[(int)Grabber_URLClass.Grabber_Output.OriginalTitle])) person.Name = Result[(int)Grabber_URLClass.Grabber_Output.OriginalTitle]; if (string.IsNullOrEmpty(Result[(int)Grabber_URLClass.Grabber_Output.Comments])) person.DateOfBirth = Result[(int)Grabber_URLClass.Grabber_Output.Comments]; if (string.IsNullOrEmpty(Result[(int)Grabber_URLClass.Grabber_Output.Country])) person.PlaceOfBirth = Result[(int)Grabber_URLClass.Grabber_Output.Country]; if (string.IsNullOrEmpty(Result[(int)Grabber_URLClass.Grabber_Output.Description])) person.Biography = Result[(int)Grabber_URLClass.Grabber_Output.Description]; if (string.IsNullOrEmpty(Result[(int)Grabber_URLClass.Grabber_Output.PictureURL]) && Result[(int)Grabber_URLClass.Grabber_Output.PictureURL].ToLower().StartsWith("http")) person.ThumbnailUrl = Result[(int)Grabber_URLClass.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)Grabber_URLClass.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)Grabber_URLClass.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)Grabber_URLClass.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 System.Threading.Thread(delegate() { string imdbid = GetIMDB_Id(MyFilms.r[MyFilms.conf.StrIndex]); GrabArtwork(title, ttitle, (int)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(); }
//------------------------------------------------------------------------------------------- // 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.Grabber_URLClass(); Grabber_URLClass.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.ErrorException("grabb_Internet_Details_Search() - exception = '" + ex.Message + "'", ex); } 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.Grabber_URLClass.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.Grabber_URLClass.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 = (Grabber_URLClass.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(); }
//------------------------------------------------------------------------------------------- // Grab URL Internet Movie Informations and update the XML database and refresh screen // -> Selection of grabber script //------------------------------------------------------------------------------------------- public static void grabb_Internet_Informations(string fullMovieName, int GetID, bool choosescript, string wscript, string fullMoviePath, GrabType grabtype, bool showAll, Searchtitles sTitles, GUIAnimation searchanimation) { LogMyFilms.Debug("(grabb_Internet_Informations) with grabtype = '" + grabtype + "', title = '" + fullMovieName + "', choosescript = '" + choosescript + "', grabberfile = '" + wscript + "'"); if (choosescript) { if (!Directory.Exists(MyFilmsSettings.GetPath(MyFilmsSettings.Path.GrabberScripts))) { GUIUtils.ShowOKDialog(string.Format(GUILocalizeStrings.Get(1079876), MyFilmsSettings.GetPath(MyFilmsSettings.Path.GrabberScripts)), GUILocalizeStrings.Get(1079877), "", ""); LogMyFilms.Info("My Films : The Directory grabber config files doesn't exists. Verify your Configuration !"); return; } if (!Directory.Exists(MyFilmsSettings.GetPath(MyFilmsSettings.Path.GrabberScripts) + @"\user")) { try { Directory.CreateDirectory(MyFilmsSettings.GetPath(MyFilmsSettings.Path.GrabberScripts) + @"\user"); } catch (Exception ex) { LogMyFilms.Debug("Error creating user script directory: '" + ex.Message + "'"); } } // Grabber Directory filled, search for XML scripts files var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); dlg.Reset(); dlg.SetHeading(GUILocalizeStrings.Get(10798706)); // "Choose internet grabber script" if (dlg == null) return; var scriptfile = new ArrayList(); if (MyFilms.conf.StrGrabber_cnf.Length > 0 && (grabtype == GrabType.Details || grabtype == GrabType.All)) { try { var defaultScript = new GrabberScript(MyFilms.conf.StrGrabber_cnf); defaultScript.Load(MyFilms.conf.StrGrabber_cnf); scriptfile.Add(MyFilms.conf.StrGrabber_cnf); dlg.Add(MyFilms.conf.StrGrabber_cnf.Substring(MyFilms.conf.StrGrabber_cnf.LastIndexOf("\\", System.StringComparison.Ordinal) + 1) + " (default)"); dlg.SelectedLabel = 0; } catch (Exception) { LogMyFilms.Error("The default script is not compatible with current MyFilms version - please change your settings !"); } } var dirsInf = new DirectoryInfo(MyFilmsSettings.GetPath(MyFilmsSettings.Path.GrabberScripts)); FileSystemInfo[] sfiles = dirsInf.GetFileSystemInfos(); foreach (FileSystemInfo sfi in sfiles) { if ((sfi.Extension.ToLower() == ".xml") && (sfi.FullName != MyFilms.conf.StrGrabber_cnf)) { var script = new GrabberScript(sfi.FullName); script.Load(sfi.FullName); string displayName = ""; string displayNamePost = ""; switch (grabtype) { case GrabType.MultiCovers: displayNamePost = script.Type.ToLower().Contains("multicovers") ? " - (Multi Cover)" : " - (Single Cover)"; break; } if (ShouldGrabberBeAdded(script, grabtype, showAll)) { if (!string.IsNullOrEmpty(script.DBName)) { displayName += script.DBName; if (!string.IsNullOrEmpty(script.Language)) displayName += " (" + script.Language + ")"; displayName += displayNamePost; } else displayName += sfi.Name; dlg.Add(displayName); scriptfile.Add(sfi.FullName); } } } // add choice to show all languages if (!showAll && !string.IsNullOrEmpty(MyFilms.conf.ItemSearchGrabberScriptsFilter)) dlg.Add(GUILocalizeStrings.Get(10798765)); // Show all if (scriptfile.Count > 0) { dlg.DoModal(GetID); if (dlg.SelectedLabel == -1) return; if (dlg.SelectedLabelText == GUILocalizeStrings.Get(10798765)) { grabb_Internet_Informations(fullMovieName, GetID, true, wscript, fullMoviePath, grabtype, true, sTitles, searchanimation); return; } if (dlg.SelectedLabel > -1) wscript = scriptfile[dlg.SelectedLabel].ToString(); } } grabb_Internet_Informations_Search(fullMovieName, GetID, wscript, fullMoviePath, grabtype, sTitles, searchanimation); }
private static bool ShouldGrabberBeAdded(GrabberScript script, GrabType grabtype, bool showallLanguages) { bool add = false; string currentlanguagefilter = ""; if (!string.IsNullOrEmpty(MyFilms.conf.ItemSearchGrabberScriptsFilter)) currentlanguagefilter = MyFilms.conf.ItemSearchGrabberScriptsFilter; string[] sep = new string[] { ",", ";", "|", "/", ".", @"\", ":" }; switch (grabtype) { case GrabType.All: case GrabType.Details: case GrabType.Cover: case GrabType.MultiCovers: case GrabType.Fanart: case GrabType.Person: case GrabType.Photos: case GrabType.Trailers: break; } // check, if it meets filter criteria string[] allowedlanguages = currentlanguagefilter.Split(sep, StringSplitOptions.RemoveEmptyEntries); string[] supportedlanguages = script.Language.Split(sep, StringSplitOptions.RemoveEmptyEntries); string[] supportedfunctions = script.Type.Split(sep, StringSplitOptions.RemoveEmptyEntries); if (string.IsNullOrEmpty(currentlanguagefilter) || currentlanguagefilter.Contains("*")) // if there is no filter set in config or override add script anyway... { showallLanguages = true; } if (supportedfunctions.Length == 0 && (grabtype == GrabType.Details || grabtype == GrabType.All)) // if there is no functions set and trying legacy menu ... add = true; else { foreach (string supportedfunction in supportedfunctions.Where(supportedfunction => supportedfunction.Trim().ToLower() == grabtype.ToString().ToLower() || (supportedfunction.Trim().ToLower() == "details" && grabtype.ToString().ToLower() == "all"))) { if (showallLanguages) add = true; else { foreach (string allowedlanguage in from allowedlanguage in allowedlanguages from supportedlanguage in supportedlanguages where supportedlanguage.Trim().ToLower() == allowedlanguage.Trim().ToLower() select allowedlanguage) { add = true; } } } } return add; }
public IActionResult shopInfoImport(IFormFile excelfile) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { DateTime beginTime = DateTime.Now; string sWebRootFolder = _hostingEnvironment.WebRootPath + "\\UploadFiles\\ImportUserInfoExcel"; //var schoolinfo = _dbContext.SchoolInforManagement.AsQueryable(); string uploadtitle = "垃圾分类导入" + DateTime.Now.ToString("yyyyMMddHHmmss"); string sFileName = $"{uploadtitle}.xlsx"; FileInfo file = new FileInfo(Path.Combine(sWebRootFolder, sFileName)); //string conStr = ConnectionStrings.DefaultConnection; string responsemsgsuccess = ""; string responsemsgrepeat = ""; string responsemsgdefault = ""; int successcount = 0; int repeatcount = 0; int defaultcount = 0; string today = DateTime.Now.ToString("yyyy-MM-dd"); try { //把excelfile中的数据复制到file中 using (FileStream fs = new FileStream(file.ToString(), FileMode.Create)) //初始化一个指定路径和创建模式的FileStream { excelfile.CopyTo(fs); fs.Flush(); //清空stream的缓存,并且把缓存中的数据输出到file } System.Data.DataTable dt = Haikan3.Utils.ExcelTools.ExcelToDataTable(file.ToString(), "Sheet1", true); if (dt == null || dt.Rows.Count == 0) { response.SetFailed("表格无数据"); return(Ok(response)); } else { if (!dt.Columns.Contains("垃圾名称")) { response.SetFailed("无‘垃圾名称’列"); return(Ok(response)); } for (int i = 0; i < dt.Rows.Count; i++) { var entity = new GrabType(); entity.GrabTypeUuid = Guid.NewGuid(); if (!string.IsNullOrEmpty(dt.Rows[i]["垃圾名称"].ToString())) { entity.GrabName = dt.Rows[i]["垃圾名称"].ToString(); } else { responsemsgdefault += "<p style='color:red'>" + "第" + (i + 2) + "行垃圾名称为空" + "</p></br>"; defaultcount++; continue; } if (!string.IsNullOrEmpty(dt.Rows[i]["垃圾类型"].ToString())) { string type = dt.Rows[i]["垃圾类型"].ToString(); if (type != "易腐垃圾" && type != "其他垃圾" && type != "可回收物" && type != "有害垃圾") { responsemsgdefault += "<p style='color:red'>" + "第" + (i + 2) + "行垃圾类型不正确" + "</p></br>"; defaultcount++; continue; } else { entity.Type = dt.Rows[i]["垃圾类型"].ToString(); } } else { responsemsgdefault += "<p style='color:red'>" + "第" + (i + 2) + "行垃圾类型为空" + "</p></br>"; defaultcount++; continue; } entity.AddPeopel = "超级管理员"; entity.IsDelete = "0"; entity.AddTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); _dbContext.GrabType.Add(entity); _dbContext.SaveChanges(); successcount++; } } responsemsgsuccess = "<p style='color:green'>导入成功:" + successcount + "条</p></br>" + responsemsgsuccess; responsemsgrepeat = "<p style='color:orange'>重复需手动修改数据:" + repeatcount + "条</p></br>" + responsemsgrepeat; responsemsgdefault = "<p style='color:red'>导入失败:" + defaultcount + "条</p></br>" + responsemsgdefault; DateTime endTime = DateTime.Now; TimeSpan useTime = endTime - beginTime; string taketime = "导入时间" + useTime.TotalSeconds.ToString() + "秒 "; response.SetData(JsonConvert.DeserializeObject(JsonConvert.SerializeObject(new { time = taketime, successmsg = responsemsgsuccess , repeatmsg = responsemsgrepeat, defaultmsg = responsemsgdefault }))); return(Ok(response)); } catch (Exception ex) { response.SetFailed(ex.Message); return(Ok(response)); } } }