Exemple #1
0
        private void FindMovies_New(string strSearchInit, string strConfigFile, int strPage, bool alwaysAsk, out ArrayList ListUrl, out short WIndex)
        {
            #region variables
              WIndex = -1;
              string strSearch = strSearchInit;
              string strTemp = string.Empty;
              string strBody = string.Empty;
              string strItem = string.Empty;
              string strURL;
              string strSearchCleanup = string.Empty;
              string strVersion = string.Empty;
              string strStart = string.Empty;
              string strEnd = string.Empty;
              string strNext = string.Empty;
              string absoluteUri;
              string strStartItem = string.Empty; // selected item for grabbing
              string strStartTitle = string.Empty;
              string strEndTitle = string.Empty;
              string strStartYear = string.Empty;
              string strEndYear = string.Empty;
              string strStartDirector = string.Empty;
              string strEndDirector = string.Empty;
              string strStartLink = string.Empty;
              string strEndLink = string.Empty;
              string strStartID = string.Empty;
              string strEndID = string.Empty;
              string strStartOptions = string.Empty;
              string strEndOptions = string.Empty;
              string strStartAkas = string.Empty;
              string strEndAkas = string.Empty;
              string strKeyAkasRegExp = string.Empty;
              string strStartThumb = string.Empty;
              string strEndThumb = string.Empty;

              string strTitle = string.Empty;
              string strYear = string.Empty;
              string strDirector = string.Empty;
              string strID = string.Empty;
              string strOptions = string.Empty;
              string strAkas = string.Empty;
              string strThumb = string.Empty;

              string strIMDB_Id = string.Empty;
              string strTMDB_Id = string.Empty;
              string strLink = string.Empty;
              string strDBName;
              string strStartPage = string.Empty;
              int wStepPage = 0;
              int iFinItem = 0;
              int iStartItemLength = 0;
              int iStartTitle = 0;
              int iStartYear = 0;
              int iStartDirector = 0;
              int iStartID = 0;
              int iStartOptions = 0;
              int iStartAkas = 0;
              int iStartThumb = 0;
              int iStartUrl = 0;
              int iStart = 0;
              int iEnd = 0;
              int iLength = 0;
              string strRedir = string.Empty;
              string strParam1 = string.Empty;
              string strParam2 = string.Empty;
              #endregion

              elements.Clear();

              GrabUtil.RemoveStackEndings(ref strSearchInit);

              #region Regex creation with name of movie file
              byte[] bytes = Encoding.GetEncoding(1251).GetBytes(strSearchInit.ToLower());
              string file = Encoding.ASCII.GetString(bytes);
              file = GrabUtil.FilterFileName(file);
              file = file.Replace("-", " ");
              file = file.Replace("+", " ");
              file = file.Replace("!", " ");
              file = file.Replace("#", " ");
              file = file.Replace(";", " ");
              file = file.Replace(".", " ");
              file = file.Replace(",", " ");
              file = file.Replace("=", " ");
              file = file.Replace("&", " ");
              file = file.Replace("(", " ");
              file = file.Replace(")", " ");
              file = file.Replace("@", " ");
              file = file.Replace("%", " ");
              file = file.Replace("$", " ");
              file = file.Replace(":", " ");
              file = file.Replace("_", " ");
              file = file.Trim();
              var oRegex = new Regex(" +");
              file = oRegex.Replace(file, ":");
              file = file.Replace(":", ".*");
              oRegex = new Regex(file);
              #endregion

              #region Loading the configuration file
              //var doc = new XmlDocument();
              //doc.Load(strConfigFile);
              //script = doc.ChildNodes[1].FirstChild;
              // new method
              using (var fs = new FileStream(strConfigFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
              {
            grabberscript = new Grabber.Data.GrabberScript();
            //// synchronize dataset with hierarchical XMLdoc
            //xmlDoc = new XmlDataDocument(data);
            //xmlDoc.Load(fs);
            grabberscript.ReadXml(fs);
            fs.Close();
              }
              #endregion

              #region old loading method - DISABLED

              //strDBName = script.SelectSingleNodeFast("DBName").InnerText;

              //if (strDBName.ToLower().StartsWith("ofdb") && strSearchInit.Length > 3) // Optimization for searches with ofdb
              //{
              //  string strLeft = "";
              //  strLeft = strSearchInit.Substring(0, 3);
              //  if (strLeft.ToLower().Contains("der") || strLeft.ToLower().Contains("die") || strLeft.ToLower().Contains("das") || strLeft.ToLower().Contains("the"))
              //  {
              //    strSearchInit = strSearchInit.Substring(3).Trim() + ", " + strLeft.Trim();
              //    strSearch = strSearchInit;
              //  }
              //}

              //// retrieve manual encoding override, if any
              //try { strEncoding = script.SelectSingleNodeFast("Encoding").InnerText; }
              //catch (Exception) { strEncoding = ""; }

              //try // retrieve language, if any
              //{ strLanguage = script.SelectSingleNodeFast("Language").InnerText; }
              //catch (Exception) { strLanguage = ""; }

              //try // retrieve type, if any
              //{ strType = script.SelectSingleNodeFast("Type").InnerText; }
              //catch (Exception) { strType = ""; }

              //try // retrieve version, if any
              //{ strVersion = script.SelectSingleNodeFast("Version").InnerText; }
              //catch (Exception) { strVersion = ""; }

              //try // retrieve SearchCleanupDefinition, if any
              //{ strSearchCleanup = script.SelectSingleNodeFast("SearchCleanup").InnerText; }
              //catch (Exception) { strSearchCleanup = ""; }

              //try // retrieve SearchCleanupDefinition, if any
              //{ strAccept = script.SelectSingleNodeFast("Accept").InnerText; }
              //catch (Exception) { strAccept = ""; }

              //try // retrieve SearchCleanupDefinition, if any
              //{ strUserAgent = script.SelectSingleNodeFast("UserAgent").InnerText; }
              //catch (Exception) { strUserAgent = ""; }

              //try // retrieve SearchCleanupDefinition, if any
              //{ strHeaders = script.SelectSingleNodeFast("Headers").InnerText; }
              //catch (Exception) { strHeaders = ""; }

              //#region Retrieves the URL
              //strUrl = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/URL").InnerText);
              //strRedir = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/URL").Attributes["Param1"].InnerText);

              //strSearch = GrabUtil.CleanupSearch(strSearch, strSearchCleanup); // process SearchCleanup
              //strSearch = GrabUtil.EncodeSearch(strSearch, strEncoding); // Process Encoding of Search Expression

              //strUrl = strUrl.Replace("#Search#", strSearch);

              ////Retrieves the identifier of the next page
              //strNext = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyNextPage").InnerText);
              //strNext = strNext.Replace("#Search#", strSearch);
              //#endregion

              //#region Load number of first and following pages
              ////Récupère Le n° de la première page
              //strStartPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartPage").InnerText);
              ////Récupère Le step de page
              //try { wStepPage = Convert.ToInt16(XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStepPage").InnerText)); }
              //catch { wStepPage = 1; }

              //int wpage = strPage;
              //int wpagedeb;
              //int wpageprev = 0;
              ////Fetch The No. of the first page
              //try { wpagedeb = Convert.ToInt16(XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartPage").InnerText)); }
              //catch { wpagedeb = 1; }
              //if (wpage - wStepPage < wpagedeb)
              //  wpageprev = -1;
              //else
              //  wpageprev = wpage - wStepPage;
              //#endregion

              //******************************/
              //* Search titles and links
              //******************************/

              ////Gets Key to the first page if it exists (not required)...
              //strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartList").InnerText);
              //strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyEndList").InnerText);

              //strStartTitle = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartTitle").InnerText);
              //strEndTitle = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyEndTitle").InnerText);
              //strStartYear = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartYear").InnerText);
              //strEndYear = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyEndYear").InnerText);
              //strStartDirector = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartDirector").InnerText);
              //strEndDirector = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyEndDirector").InnerText);
              //strStartLink = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartLink").InnerText);
              //strEndLink = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyEndLink").InnerText);
              //strStartID = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartID").InnerText);
              //strEndID = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyEndID").InnerText);
              //strStartOptions = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartOptions").InnerText);
              //strEndOptions = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyEndOptions").InnerText);
              //strStartAkas = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartAkas").InnerText);
              //strEndAkas = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyEndAkas").InnerText);
              //strKeyAkasRegExp = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyAkasRegExp").InnerText);
              //try { strStartThumb = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartThumb").InnerText); }
              //catch (Exception) { strStartThumb = ""; }
              //try { strEndThumb = XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyEndThumb").InnerText); }
              //catch (Exception) { strEndThumb = ""; }

              #endregion

              #region new loading method

              Data.GrabberScript.SettingsRow settings = grabberscript.Settings[0];
              strDBName = settings.DBName;

              if (strDBName.ToLower().StartsWith("ofdb") && strSearchInit.Length > 3) // Optimization for searches with ofdb
              {
            string strLeft = "";
            strLeft = strSearchInit.Substring(0, 3);
            if (strLeft.ToLower().Contains("der") || strLeft.ToLower().Contains("die") || strLeft.ToLower().Contains("das") || strLeft.ToLower().Contains("the"))
            {
              strSearchInit = strSearchInit.Substring(3).Trim() + ", " + strLeft.Trim();
              strSearch = strSearchInit;
            }
              }

              // retrieve manual encoding override, if any
              try { strEncoding = settings.Encoding; }
              catch (Exception) { strEncoding = ""; }

              try // retrieve language, if any
              { strLanguage = settings.Language; }
              catch (Exception) { strLanguage = ""; }

              try // retrieve SearchCleanupDefinition, if any
              { strSearchCleanup = settings.SearchCleanup; }
              catch (Exception) { strSearchCleanup = ""; }

              try // retrieve SearchCleanupDefinition, if any
              { strAccept = settings.Accept; }
              catch (Exception) { strAccept = ""; }

              try // retrieve SearchCleanupDefinition, if any
              { strUserAgent = settings.Useragent; }
              catch (Exception) { strUserAgent = ""; }

              try // retrieve SearchCleanupDefinition, if any
              { strHeaders = settings.Headers; }
              catch (Exception) { strHeaders = ""; }

              #region Retrieves the URL

              Data.GrabberScript.URLSearchRow search = grabberscript.URLSearch[0];
              strURL = search.URL;
              strRedir = search.Redirection;

              strSearch = GrabUtil.ReplaceNormalOrRegex(strSearch, strSearchCleanup); // process SearchCleanup
              strSearch = GrabUtil.EncodeSearch(strSearch, strEncoding); // Process Encoding of Search Expression

              strURL = strURL.Replace("#Search#", strSearch);

              //Retrieves the identifier of the next page
              strNext = search.NextPage;
              strNext = strNext.Replace("#Search#", strSearch);
              #endregion

              #region Load number of first and following pages
              try { wStepPage = Convert.ToInt16(search.StepPage); }
              catch { wStepPage = 1; }

              int wpage = strPage;
              int wpagedeb;
              int wpageprev = 0;
              //Fetch The No. of the first page
              try { wpagedeb = Convert.ToInt16(search.StartPage); }
              catch { wpagedeb = 1; }
              if (wpage - wStepPage < wpagedeb)
            wpageprev = -1;
              else
            wpageprev = wpage - wStepPage;
              #endregion

              /******************************/
              /* Search titles and links
              /******************************/

              //Gets Key to the first page if it exists (not required)...
              Data.GrabberScript.SearchDetailsRow sd;
              foreach (var row in search.GetSearchDetailsRows().Where(row => row.Name == "Title"))
              {
            sd = row;
            break;
              }
              foreach (var searchdetails in search.GetSearchDetailsRows())
              {
            switch (searchdetails.Name)
            {
              case "List":
            strStart = searchdetails.Start;
            strEnd = searchdetails.End;
            break;
              case "Title":
            strStartTitle = searchdetails.Start;
            strEndTitle = searchdetails.End;
            break;
              case "Year":
            strStartYear = searchdetails.Start;
            strEndYear = searchdetails.End;
            break;
              case "Director":
            strStartDirector = searchdetails.Start;
            strEndDirector = searchdetails.End;
            break;
              case "DetailsURL":
            strStartLink = searchdetails.Start;
            strEndLink = searchdetails.End;
            break;
              case "ID":
            strStartID = searchdetails.Start;
            strEndID = searchdetails.End;
            break;
              case "Options":
            strStartOptions = searchdetails.Start;
            strEndOptions = searchdetails.End;
            break;
              case "Akas":
            strStartAkas = searchdetails.Start;
            strEndAkas = searchdetails.Start;
            strKeyAkasRegExp = searchdetails.RegExp;
            break;
              case "Thumb":
            try
            {
              strStartThumb = searchdetails.Start;
            }
            catch (Exception)
            {
              strStartThumb = "";
            }
            try
            {
              strEndThumb = searchdetails.End;
            }
            catch (Exception)
            {
              strEndThumb = "";
            }
            break;
            }
              }

              #endregion

              var cook = new CookieContainer();

              #region now load the searchresults

              //Récupère la page wpage
              strBody = GrabUtil.GetPage(strURL.Replace("#Page#", wpage.ToString()), strEncoding, out absoluteUri, cook, strHeaders, strAccept, strUserAgent);
              //redirection auto : 1 résult
              if (!absoluteUri.Equals(strURL.Replace("#Page#", wpage.ToString())))
              {
            IMDBUrl url = new IMDBUrl(absoluteUri, strSearchInit + " (AutoRedirect)", strDBName, null, wpage.ToString());
            elements.Add(url);
            ListUrl = elements;
            WIndex = 0;
            return;
              }

              if (strRedir.Length > 0)
            strBody = GrabUtil.GetPage(strRedir, strEncoding, out absoluteUri, cook, strHeaders, strAccept, strUserAgent);

              wpage += wStepPage;

              /******************************/
              /* Cutting the list
              /******************************/
              // If you have at least the key to start, we cut strBody
              iStart = 0;
              iEnd = 0;
              iLength = 0;

              if (strStart.Length > 0)
              {
            iStart = GrabUtil.FindPosition(strBody, strStart, iStart, ref iLength, true, true);
            if (iStart < 0) iStart = 0;
              }
              if (strEnd.Length > 0)
              {
            iEnd = GrabUtil.FindPosition(strBody, strEnd, iStart, ref iLength, true, false);
            if (iEnd <= 0) iEnd = strBody.Length;
              }

              // Cutting the body
              try { strBody = strBody.Substring(iStart, iEnd - iStart); }
              catch { }

              // Now grab the search data from stripped search page !
              iStart = 0;
              iFinItem = 0;
              iStartTitle = 0;
              iStartUrl = 0;
              iLength = 0;
              IMDBUrl urlprev = new IMDBUrl(strURL.Replace("#Page#", wpageprev.ToString()), "---", strDBName, script, wpageprev.ToString());

              if (strBody != "")
              {
            // Comparison between the position of URL and title to boundary elements //if (strBody.IndexOf(strStartTitle, 0) > strBody.IndexOf(strStartLink, 0))
            int iPosStartTitle = 0; iPosStartTitle = GrabUtil.FindPosition(strBody, strStartTitle, iPosStartTitle, ref iLength, true, false);
            int iPosStartLink = 0; iPosStartLink = GrabUtil.FindPosition(strBody, strStartLink, iPosStartLink, ref iLength, true, false);
            strStartItem = iPosStartTitle > iPosStartLink ? strStartLink : strStartTitle;

            // set start position for all elements (lowest possible position found)
            iFinItem = GrabUtil.FindPosition(strBody, strStartItem, iFinItem, ref iLength, true, false);
            iStartItemLength = iLength;

            // iFinItem += strStartItem.Length;
            iStartYear = iStartDirector = iStartUrl = iStartTitle = iStartID = iStartOptions = iStartAkas = iStartThumb = iFinItem;

            while (true)
            {
              // determining the end of nth Item (if the index fields are higher then found => no info for this item
              if (iFinItem <= 0) break;
              //iFinItem = GrabUtil.FindPosition(strBody, strStartItem, iFinItem + strStartItem.Length, ref iLength, true, false);
              iFinItem = GrabUtil.FindPosition(strBody, strStartItem, iFinItem + iStartItemLength, ref iLength, true, false);
              iStartItemLength = iLength;
              // Initialisation

              #region Read Movie Title

              strParam1 = SearchDetail("Title").Param1; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartTitle").Attributes["Param1"].InnerText);
              strParam2 = SearchDetail("Title").Param2; // //XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartTitle").Attributes["Param2"].InnerText);

              strTitle = strParam1.Length > 0 ? GrabUtil.FindWithAction(strBody, strStartTitle, ref iStartTitle, strEndTitle, strParam1, strParam2).Trim() : GrabUtil.Find(strBody, strStartTitle, ref iStartTitle, strEndTitle).Trim();

              if (strTitle.Length == 0)
            break;

              // Reorder article for ofdb to beginning
              if (strDBName.ToLower().StartsWith("ofdb") && strTitle.Length > 3) // Optimization for searches with ofdb
              {
            string strRight = "";
            strRight = strTitle.Substring(strTitle.Length - 3);
            if (strRight.ToLower().Contains("der") || strRight.ToLower().Contains("die") || strRight.ToLower().Contains("das") || strRight.ToLower().Contains("the"))
            {

              strTitle = strRight.Trim() + " " + strTitle.Substring(0, strTitle.Length - 3).Trim().Trim(',');
            }
              }
              #endregion

              #region Title outbound range Item re-delimit range item
              if ((iStartTitle > iFinItem) && (iFinItem != -1))
              {
            iStartYear = iStartDirector = iStartUrl = iStartTitle = iStartID = iStartOptions = iStartAkas = iStartThumb = iFinItem;
            //iFinItem = strBody.IndexOf(strStartItem, iFinItem + strStartItem.Length);
            //iFinItem = GrabUtil.FindPosition(strBody, strStartItem, iFinItem + strStartItem.Length, ref iLength, true, false);
            iFinItem = GrabUtil.FindPosition(strBody, strStartItem, iFinItem + iStartItemLength, ref iLength, true, false);
            iStartItemLength = iLength;
            if (iFinItem <= 0)
              break;
              }
              #endregion

              #region  read movie year
              strParam1 = SearchDetail("Year").Param1; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartYear").Attributes["Param1"].InnerText);
              strParam2 = SearchDetail("Year").Param2; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartYear").Attributes["Param2"].InnerText);

              strYear = strParam1.Length > 0 ? GrabUtil.FindWithAction(strBody, strStartYear, ref iStartYear, strEndYear, strParam1, strParam2).Trim() : GrabUtil.Find(strBody, strStartYear, ref iStartYear, strEndYear).Trim();

              if ((strYear.Length == 0) || ((iStartYear > iFinItem) && iFinItem != -1))
            strYear = string.Empty;
              #endregion

              #region read movie director
              strParam1 = SearchDetail("Director").Param1; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartDirector").Attributes["Param1"].InnerText);
              strParam2 = SearchDetail("Director").Param2; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartDirector").Attributes["Param2"].InnerText);

              strDirector = strParam1.Length > 0 ? GrabUtil.FindWithAction(strBody, strStartDirector, ref iStartDirector, strEndDirector, strParam1, strParam2).Trim() : GrabUtil.Find(strBody, strStartDirector, ref iStartDirector, strEndDirector).Trim();

              if ((strDirector.Length == 0) || ((iStartDirector > iFinItem) && iFinItem != -1))
            strDirector = string.Empty;
              #endregion

              #region read movie ID
              strParam1 = SearchDetail("ID").Param1; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartID").Attributes["Param1"].InnerText);
              strParam2 = SearchDetail("ID").Param2; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartID").Attributes["Param2"].InnerText);

              strID = strParam1.Length > 0 ? GrabUtil.FindWithAction(strBody, strStartID, ref iStartID, strEndID, strParam1, strParam2).Trim() : GrabUtil.Find(strBody, strStartID, ref iStartID, strEndID).Trim();

              if (strID.Length == 0 || (iStartID > iFinItem && iFinItem != -1))
            strID = string.Empty;
              #endregion

              #region read movie Options
              strParam1 = SearchDetail("Options").Param1; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartOptions").Attributes["Param1"].InnerText);
              strParam2 = SearchDetail("Options").Param2; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartOptions").Attributes["Param2"].InnerText);

              strOptions = strParam1.Length > 0 ? GrabUtil.FindWithAction(strBody, strStartOptions, ref iStartOptions, strEndOptions, strParam1, strParam2).Trim() : GrabUtil.Find(strBody, strStartOptions, ref iStartOptions, strEndOptions).Trim();

              if ((strOptions.Length == 0) || ((iStartOptions > iFinItem) && iFinItem != -1))
            strOptions = string.Empty;
              #endregion

              #region read movie Akas
              strParam1 = SearchDetail("Akas").Param1; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartAkas").Attributes["Param1"].InnerText);
              strParam2 = SearchDetail("Akas").Param2; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartAkas").Attributes["Param2"].InnerText);

              strAkas = strParam1.Length > 0 ? GrabUtil.FindWithAction(strBody, strStartAkas, ref iStartAkas, strEndAkas, strParam1, strParam2).Trim() : GrabUtil.Find(strBody, strStartAkas, ref iStartAkas, strEndAkas).Trim();

              if (strAkas.Length == 0 || (iStartAkas > iFinItem && iFinItem != -1))
            strAkas = string.Empty;
              #endregion

              #region read movie Thumb
              strParam1 = SearchDetail("Thumb").Param1; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartThumb").Attributes["Param1"].InnerText);
              strParam2 = SearchDetail("Thumb").Param2; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartThumb").Attributes["Param2"].InnerText);

              strThumb = strParam1.Length > 0 ? GrabUtil.FindWithAction(strBody, strStartThumb, ref iStartThumb, strEndThumb, strParam1, strParam2).Trim() : GrabUtil.Find(strBody, strStartThumb, ref iStartThumb, strEndThumb).Trim();

              if ((strThumb.Length == 0) || ((iStartThumb > iFinItem) && iFinItem != -1))
            strThumb = string.Empty;
              #endregion

              #region create akas string with titles
              if (!String.IsNullOrEmpty(strKeyAkasRegExp)) // strKeyAkasRegExp = @"aka." + "\"" + ".*?" + "\"" + ".-";
              {
            strTemp = strAkas;
            strTemp = HttpUtility.HtmlDecode(strTemp);
            strTemp = HttpUtility.HtmlDecode(strTemp).Replace("\n", "");
            Regex p = new Regex(strKeyAkasRegExp, RegexOptions.Singleline);
            iLength = 0;

            MatchCollection MatchList = p.Matches(strTemp);
            if (MatchList.Count > 0)
            {
              string matchstring = "";
              foreach (Match match in MatchList)
              {
                if (matchstring.Length > 0) matchstring += " | " + match.Groups["aka"].Value;
                else matchstring = match.Groups["aka"].Value;
              }
              if (matchstring.Length > 0)
                strAkas = matchstring;
            }
            // else strAkas = "";
              }
              #endregion

              #region read movie url
              strParam1 = SearchDetail("DetailsURL").Param1; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartLink").Attributes["Param1"].InnerText);
              strParam2 = SearchDetail("DetailsURL").Param2; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLSearch/KeyStartLink").Attributes["Param2"].InnerText);

              strLink = strParam1.Length > 0 ? GrabUtil.FindWithAction(strBody, strStartLink, ref iStartUrl, strEndLink, strParam1, strParam2).Trim() : GrabUtil.Find(strBody, strStartLink, ref iStartUrl, strEndLink).Trim();

              if (strLink.Length != 0)
              {
            // check, if IMDB id is existing
            if (strLink.Contains(@"/tt"))
            {
              strIMDB_Id = strLink.Substring(strLink.IndexOf(@"/tt") + 1);
              strIMDB_Id = strIMDB_Id.Substring(0, strIMDB_Id.IndexOf(@"/"));
              // Fix for redirection on AKAS site on IMDB
              if (strLink.Contains("onclick"))
                strLink = strLink.Substring(0, strLink.IndexOf("onclick"));
            }
            // check, if TMDB id is existing
            if (strLink.Contains(@"themoviedb.org/movie/"))
            {
              strIMDB_Id = strLink.Substring(strLink.IndexOf(@"themoviedb.org/movie/") + 20); // assign TMDB ID
            }
            if (!strLink.StartsWith("http://") && !strLink.StartsWith("www."))
            {
              //si les liens sont relatifs on rajoute le préfix (domaine)
              strLink = grabberscript.Settings[0].URLPrefix; // XmlConvert.DecodeName(script.SelectSingleNodeFast("URLPrefix").InnerText + strLink);
            }

            //Ajout http:// s'il n'y est pas (Pour GetPage)
            if (strLink.StartsWith("www."))
              strLink = "http://" + strLink;

            //Added new element, we pass the node of xml file to find the details

            //IMDBUrl url = new IMDBUrl(strLink, strTitle + " (" + strYear + ") " + strDirector, strDBName, n, wpage.ToString(), strYear, strDirector, strImdbId, strTmdbId) ;
            IMDBUrl url = new IMDBUrl(strLink, strTitle, strDBName, script, wpage.ToString(), strYear, strDirector, strIMDB_Id, strTMDB_Id, strID, strOptions, strAkas, strThumb);
            bytes = Encoding.GetEncoding(1251).GetBytes(strTitle.ToLower());
            MatchCollection oMatches = oRegex.Matches(Encoding.ASCII.GetString(bytes));
            if (oMatches.Count > 0)
              if (alwaysAsk)
                WIndex = -2;
              else
                if (WIndex == -1)
                  WIndex = (short)elements.Count;
                else
                  WIndex = -2;

            if ((elements.Count == 0) && (strNext.Length > 0) && (strBody.Contains(strNext.Replace("#Page#", wpageprev.ToString()))) && !(wpageprev < 0))
              elements.Add(urlprev);
            elements.Add(url);
              }
              #endregion

              // init new search indexes
              iStartYear = iStartDirector = iStartUrl = iStartTitle = iStartID = iStartOptions = iStartAkas = iStartThumb = iFinItem;
            }
              }
              IMDBUrl urlsuite = new IMDBUrl(strURL.Replace("#Page#", wpage.ToString()), "+++", strDBName, script, wpage.ToString());

              if ((strBody.Contains(strNext.Replace("#Page#", wpage.ToString()))) && (strNext.Length > 0))
            elements.Add(urlsuite);
              #endregion

              ListUrl = elements;
        }
Exemple #2
0
        public string[] GetDetail_New(string strUrl, string strPathImg, string strConfigFile, bool saveImage, string preferredLanguage, string personLimit, string titleLimit, string getRoles, string mediafile = null)
        {
            //Grabber.Data.GrabberScript data = new Grabber.Data.GrabberScript();
              //Data.GrabberScript.GrabResultDataTable results = new Data.GrabberScript.GrabResultDataTable();

              string[] datas = new string[80]; // 0-39 = original fields, 40-79 mapped fields
              elements.Clear();

              // delete all loaded content - will be loaded on demand later automatically with items
              foreach (var grabItem in grabItems.Where(grabItem => grabItem.IsRedirectionURL))
              {
            grabItem.Content = null;
              }

              string strTemp = string.Empty;

              //string strBody = string.Empty;
              //string strBodyDetails2 = string.Empty;
              //string strBodyPersons = string.Empty;
              //string strBodyTitles = string.Empty;
              //string strBodyCertification = string.Empty;
              //string strBodyComment = string.Empty;
              //string strBodyDescription = string.Empty;
              //string strBodyCover = string.Empty;

              //string strEncoding = string.Empty; // added for manual encoding override (global setting for all webgrabbing)
              string strEncodingSubPage = string.Empty; // added to override Sub Page encoding

              GrabItem grabitem = new GrabItem();

              string strStart = string.Empty;
              string strEnd = string.Empty;
              string strIndex = string.Empty;
              string strPage = string.Empty;

              string strActivePage = string.Empty;
              string absoluteUri;
              string strTitle = string.Empty;
              string strRate = string.Empty;
              string strRate2 = string.Empty;
              string strBasedRate = string.Empty;
              string strParam1 = string.Empty;
              string strParam3 = string.Empty;
              string strParam2 = string.Empty;
              string strMaxItems = string.Empty;
              string strLanguage = string.Empty;
              string strGrabActorRoles = string.Empty;
              bool boolGrabActorRoles = false;
              string allNames = string.Empty;
              string allRoles = string.Empty;
              int iStart = 0;
              int iEnd = 0;

              // Reset all webpage content
              BodyDetail = string.Empty;
              BodyDetail2 = string.Empty;
              BodyLinkGeneric1 = string.Empty;
              BodyLinkGeneric2 = string.Empty;
              BodyLinkImg = string.Empty;
              BodyLinkPersons = string.Empty;
              BodyLinkTitles = string.Empty;
              BodyLinkCertification = string.Empty;
              BodyLinkComment = string.Empty;
              BodyLinkSyn = string.Empty;
              BodyLinkMultiPosters = string.Empty;
              BodyLinkPhotos = string.Empty;
              BodyLinkPersonImages = string.Empty;
              BodyLinkMultiFanart = string.Empty;
              BodyLinkTrailer = string.Empty;
              BodyLinkDetailsPath = string.Empty;

              // reset filesystem content
              MovieDirectory = string.Empty;
              MovieFilename = string.Empty;

              #region Load the configuration file
              // old version
              XmlDocument doc = new XmlDocument();
              doc.Load(strConfigFile);
              XmlNode script = doc.ChildNodes[1].FirstChild;

              // new version:
              using (var fs = new FileStream(strConfigFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
              {
            grabberscript = new Data.GrabberScript();
            //// synchronize dataset with hierarchical XMLdoc
            //xmlDoc = new XmlDataDocument(data);
            //xmlDoc.Load(fs);
            grabberscript.ReadXml(fs);
            fs.Close();
              }
              #endregion

              // old version
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartBody").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndBody").InnerText);
              // new version
              //strStart = grabberscript.SearchDetails[0].Start;
              //strEnd = grabberscript.SearchDetails[0].End;

              // this should be loaded per detail item later, when using new methods
              strBasedRate = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/BaseRating").InnerText); // load Ratebase - valid for all items!

              #region Set DetailsPath
              BodyLinkDetailsPath = "<url>" + strUrl + "</url>";
              if (strUrl.LastIndexOf("/", StringComparison.Ordinal) > 0)
              {
            BodyLinkDetailsPath += Environment.NewLine;
            BodyLinkDetailsPath += "<baseurl>" + strUrl.Substring(0, strUrl.LastIndexOf("/", StringComparison.Ordinal)) + "</baseurl>";
            BodyLinkDetailsPath += Environment.NewLine;
            BodyLinkDetailsPath += "<pageurl>" + strUrl.Substring(strUrl.LastIndexOf("/", StringComparison.Ordinal) + 1) + "</pageurl>";
            BodyLinkDetailsPath += Environment.NewLine;
            BodyLinkDetailsPath += "<replacement>" + strUrl.Substring(0, strUrl.LastIndexOf("/", StringComparison.Ordinal)) + "%replacement%" + strUrl.Substring(strUrl.LastIndexOf("/", StringComparison.Ordinal) + 1) + "</replacement>";
              }
              #endregion

              #region Fetch the basic Details page and update DetailsPath, if possible
              if (strUrl.ToLower().StartsWith("http"))
              {
            BodyDetail = GrabUtil.GetPage(strUrl, strEncoding, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
              {
            BodyDetail = GrabUtil.GetFileContent(strUrl, strEncoding); // Read page from file !
            string physicalFile = (mediafile != null && File.Exists(mediafile)) ? mediafile : strUrl;
            if (File.Exists(physicalFile))
            {
              MovieDirectory = Path.GetDirectoryName(physicalFile);
              MovieFilename = Path.GetFileNameWithoutExtension(physicalFile);
              // Set DetailsPath
              BodyLinkDetailsPath += Environment.NewLine;
              BodyLinkDetailsPath += "<directory>" + MovieDirectory + "</directory>";
              BodyLinkDetailsPath += Environment.NewLine;
              BodyLinkDetailsPath += "<filename>" + MovieFilename + "</filename>";
              if (MovieDirectory != null)
              {
            string[] files = Directory.GetFiles(MovieDirectory, "*", SearchOption.AllDirectories);

            //foreach (string extension in files.Select(file => Path.GetExtension(file)).Distinct().ToList())
            //{
            //  BodyLinkDetailsPath += Environment.NewLine;
            //  BodyLinkDetailsPath += "<" + extension + "-files>";
            //  foreach (string file in files.Where(file => file.EndsWith("." + extension)).ToList())
            //  {
            //    BodyLinkDetailsPath += Environment.NewLine;
            //    BodyLinkDetailsPath += "<" + extension + ">" + file + "</" + extension + ">";
            //  }
            //  BodyLinkDetailsPath += Environment.NewLine;
            //  BodyLinkDetailsPath += "</" + extension + "-files>";
            //}

            BodyLinkDetailsPath += Environment.NewLine;
            BodyLinkDetailsPath += "<jpg-files>";
            foreach (string file in files.Where(file => file.EndsWith(".jpg")).ToList())
            {
              BodyLinkDetailsPath += Environment.NewLine;
              BodyLinkDetailsPath += "<jpg>" + file + "</jpg>";
            }
            BodyLinkDetailsPath += Environment.NewLine;
            BodyLinkDetailsPath += "</jpg-files>";

            BodyLinkDetailsPath += Environment.NewLine;
            BodyLinkDetailsPath += "<other-files>";
            foreach (string file in files.Where(file => !file.EndsWith(".jpg")).ToList())
            {
              BodyLinkDetailsPath += Environment.NewLine;
              BodyLinkDetailsPath += "<other>" + file + "</other>";
            }
            BodyLinkDetailsPath += Environment.NewLine;
            BodyLinkDetailsPath += "</other-files>";
              }
            }
              }

              var htmlUtil = new HtmlUtil();

              if (strStart != "")
              {
            iStart = BodyDetail.IndexOf(strStart);

            if (iStart > 0)
            {
              iEnd = strEnd != "" ? BodyDetail.IndexOf(strEnd, iStart) : BodyDetail.Length;

              iStart += strStart.Length;
              if (iEnd - iStart > 0)
            BodyDetail = BodyDetail.Substring(iStart, iEnd - iStart);
            }
              }
              #endregion

              grabItems.Add(new GrabItem("", strUrl) { Content = BodyDetail, IsRedirectionURL = true });
              grabItems.Add(new GrabItem("DetailsPath", "") { Content = BodyLinkDetailsPath, IsRedirectionURL = true });

              #region Load Sub Pages into Memory ***** // Will be used for Secondary Website Infos!

              // ***** URL Redirection Details 2 Base Page ***** // Will be used for Secondary Website Infos!
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartDetails2").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndDetails2").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartDetails2").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartDetails2").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyDetails2Index").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyDetails2Page").InnerText);
              try { strEncodingSubPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEncodingDetails2").InnerText); }
              catch (Exception) { strEncodingSubPage = ""; }
              strActivePage = LoadPage(strPage);
              if (strStart.Length > 0)
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
            BodyDetail2 = GrabUtil.GetPage(strTemp, (string.IsNullOrEmpty(strEncodingSubPage)) ? strEncoding : strEncodingSubPage, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
            BodyDetail2 = "";

              // ***** URL Redirection Generic 1 *****
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkGeneric1").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndLinkGeneric1").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkGeneric1").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkGeneric1").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkGeneric1Index").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkGeneric1Page").InnerText);
              strActivePage = LoadPage(strPage);
              try { strEncodingSubPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEncodingLinkGeneric1").InnerText); }
              catch (Exception) { strEncodingSubPage = ""; }
              if (strStart.Length > 0)
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
            BodyLinkGeneric1 = GrabUtil.GetPage(strTemp, (string.IsNullOrEmpty(strEncodingSubPage)) ? strEncoding : strEncodingSubPage, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
            BodyLinkGeneric1 = "";

              // ***** URL Redirection Generic 2 *****
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkGeneric2").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndLinkGeneric2").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkGeneric2").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkGeneric2").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkGeneric2Index").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkGeneric2Page").InnerText);
              strActivePage = LoadPage(strPage);
              try { strEncodingSubPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEncodingLinkGeneric2").InnerText); }
              catch (Exception) { strEncodingSubPage = ""; }
              if (strStart.Length > 0)
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
            BodyLinkGeneric2 = GrabUtil.GetPage(strTemp, (string.IsNullOrEmpty(strEncodingSubPage)) ? strEncoding : strEncodingSubPage, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
            BodyLinkGeneric2 = "";

              // ***** URL Redirection IMG *****
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkImg").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndLinkImg").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkImg").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkImg").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkImgIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkImgPage").InnerText);
              strActivePage = LoadPage(strPage);
              try { strEncodingSubPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEncodingLinkImg").InnerText); }
              catch (Exception) { strEncodingSubPage = ""; }
              if (strStart.Length > 0)
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
            BodyLinkImg = GrabUtil.GetPage(strTemp, (string.IsNullOrEmpty(strEncodingSubPage)) ? strEncoding : strEncodingSubPage, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
            BodyLinkImg = "";

              // ***** URL Redirection Persons ***** // Will be used for persons, if available !
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkPersons").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndLinkPersons").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkPersons").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkPersons").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkPersonsIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkPersonsPage").InnerText);
              strActivePage = LoadPage(strPage);
              try { strEncodingSubPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEncodingLinkPersons").InnerText); }
              catch (Exception) { strEncodingSubPage = ""; }
              if (strStart.Length > 0)
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
            BodyLinkPersons = GrabUtil.GetPage(strTemp, (string.IsNullOrEmpty(strEncodingSubPage)) ? strEncoding : strEncodingSubPage, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
            BodyLinkPersons = "";

              // ***** URL Redirection Titles ***** // Will be used for TTitle, if available !
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkTitles").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndLinkTitles").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkTitles").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkTitles").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkTitlesIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkTitlesPage").InnerText);
              strActivePage = LoadPage(strPage);
              try { strEncodingSubPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEncodingLinkTitles").InnerText); }
              catch (Exception) { strEncodingSubPage = ""; }
              if (strStart.Length > 0)
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
            BodyLinkTitles = GrabUtil.GetPage(strTemp, (string.IsNullOrEmpty(strEncodingSubPage)) ? strEncoding : strEncodingSubPage, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
            BodyLinkTitles = "";

              // ***** URL Redirection Certification ***** // Will be used for Certification Details, if available !
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkCertification").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndLinkCertification").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkCertification").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkCertification").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkCertificationIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkCertificationPage").InnerText);
              strActivePage = LoadPage(strPage);
              try { strEncodingSubPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEncodingLinkCertification").InnerText); }
              catch (Exception) { strEncodingSubPage = ""; }
              if (strStart.Length > 0)
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
            BodyLinkCertification = GrabUtil.GetPage(strTemp, (string.IsNullOrEmpty(strEncodingSubPage)) ? strEncoding : strEncodingSubPage, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
            BodyLinkCertification = "";

              // ***** URL Redirection Comment ***** // Will be used for Comment Details, if available !
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkComment").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndLinkComment").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkComment").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkComment").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkCommentIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkCommentPage").InnerText);
              strActivePage = LoadPage(strPage);
              try { strEncodingSubPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEncodingLinkComment").InnerText); }
              catch (Exception) { strEncodingSubPage = ""; }
              if (strStart.Length > 0)
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
            BodyLinkComment = GrabUtil.GetPage(strTemp, (string.IsNullOrEmpty(strEncodingSubPage)) ? strEncoding : strEncodingSubPage, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
            BodyLinkComment = "";

              // ***** URL Redirection Description ***** // Will be used for Description Details, if available !
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkSyn").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndLinkSyn").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkSyn").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkSyn").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkSynIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkSynPage").InnerText);
              strActivePage = LoadPage(strPage);
              try { strEncodingSubPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEncodingLinkSyn").InnerText); }
              catch (Exception) { strEncodingSubPage = ""; }
              if (strStart.Length > 0)
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
            BodyLinkSyn = GrabUtil.GetPage(strTemp, (string.IsNullOrEmpty(strEncodingSubPage)) ? strEncoding : strEncodingSubPage, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
            BodyLinkSyn = "";

              // ***** URL Redirection MultiPosters ***** // Will be used for MultiPosters Details, if available !
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkMultiPosters").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndLinkMultiPosters").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkMultiPosters").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkMultiPosters").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkMultiPostersIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkMultiPostersPage").InnerText);
              strActivePage = LoadPage(strPage);
              try { strEncodingSubPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEncodingLinkMultiPosters").InnerText); }
              catch (Exception) { strEncodingSubPage = ""; }
              if (strStart.Length > 0)
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
            BodyLinkMultiPosters = GrabUtil.GetPage(strTemp, (string.IsNullOrEmpty(strEncodingSubPage)) ? strEncoding : strEncodingSubPage, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
            BodyLinkMultiPosters = "";

              // ***** URL Redirection Photos ***** // Will be used for Photos Details, if available !
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkPhotos").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndLinkPhotos").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkPhotos").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkPhotos").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkPhotosIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkPhotosPage").InnerText);
              strActivePage = LoadPage(strPage);
              try { strEncodingSubPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEncodingLinkPhotos").InnerText); }
              catch (Exception) { strEncodingSubPage = ""; }
              if (strStart.Length > 0)
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
            BodyLinkPhotos = GrabUtil.GetPage(strTemp, (string.IsNullOrEmpty(strEncodingSubPage)) ? strEncoding : strEncodingSubPage, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
            BodyLinkPhotos = "";

              // ***** URL Redirection PersonImages ***** // Will be used for PersonImages Details, if available !
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkPersonImages").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndLinkPersonImages").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkPersonImages").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkPersonImages").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkPersonImagesIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkPersonImagesPage").InnerText);
              strActivePage = LoadPage(strPage);
              try { strEncodingSubPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEncodingLinkPersonImages").InnerText); }
              catch (Exception) { strEncodingSubPage = ""; }
              if (strStart.Length > 0)
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
            BodyLinkPersonImages = GrabUtil.GetPage(strTemp, (string.IsNullOrEmpty(strEncodingSubPage)) ? strEncoding : strEncodingSubPage, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
            BodyLinkPersonImages = "";

              // ***** URL Redirection MultiFanart ***** // Will be used for MultiFanart Details, if available !
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkMultiFanart").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndLinkMultiFanart").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkMultiFanart").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkMultiFanart").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkMultiFanartIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkMultiFanartPage").InnerText);
              strActivePage = LoadPage(strPage);
              try { strEncodingSubPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEncodingLinkMultiFanart").InnerText); }
              catch (Exception) { strEncodingSubPage = ""; }
              if (strStart.Length > 0)
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
            BodyLinkMultiFanart = GrabUtil.GetPage(strTemp, (string.IsNullOrEmpty(strEncodingSubPage)) ? strEncoding : strEncodingSubPage, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
            BodyLinkMultiFanart = "";

              // ***** URL Redirection Trailer ***** // Will be used for Trailer Details, if available !
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkTrailer").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndLinkTrailer").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkTrailer").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLinkTrailer").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkTrailerIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLinkTrailerPage").InnerText);
              strActivePage = LoadPage(strPage);
              try { strEncodingSubPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEncodingLinkTrailer").InnerText); }
              catch (Exception) { strEncodingSubPage = ""; }
              if (strStart.Length > 0)
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
            BodyLinkTrailer = GrabUtil.GetPage(strTemp, (string.IsNullOrEmpty(strEncodingSubPage)) ? strEncoding : strEncodingSubPage, out absoluteUri, new CookieContainer(), strHeaders, strAccept, strUserAgent);
              }
              else
            BodyLinkTrailer = "";
              #endregion

              #region ************* Now get the detail fields ***************************

              foreach (GrabDetail grabDetailItem in GrabDetailItems)
              {
            try
            {

              switch ((int) grabDetailItem.OutputMapping)
              {
              //case (int)Grabber_Output.PictureURL:
            case (int) Grabber_Output.PicturePathShort:
              break;
            case (int) Grabber_Output.PicturePathLong:
            {
              strTemp = grabitem.Load(script, grabDetailItem.GrabName);
              if (strTemp.Length > 0)
              {
                datas[(int) Grabber_Output.PictureURL] = strTemp;
                //Picture
                if (saveImage == true)
                {
                  if (string.IsNullOrEmpty(datas[(int) Grabber_Output.OriginalTitle]))
                    GrabUtil.DownloadCoverArt(strPathImg, strTemp, datas[(int) Grabber_Output.TranslatedTitle],
                      out strTemp);
                  else
                    GrabUtil.DownloadCoverArt(strPathImg, strTemp, datas[(int) Grabber_Output.OriginalTitle],
                      out strTemp);
                  // strTemp = MediaPortal.Util.Utils.FilterFileName(strTemp); // Guzzi: removed, as it could change the filename to an already loaded image, thus breaking the "link".
                  datas[(int) Grabber_Output.PicturePathLong] = strPathImg + "\\" + strTemp;
                }
                datas[(int) Grabber_Output.PicturePathShort] = strTemp;
              }
              break;
            }
            case (int) Grabber_Output.URL:
              datas[(int) Grabber_Output.URL] = strUrl;
              break;
            case (int) Grabber_Output.Description:
              datas[grabDetailItem.Id] =
                grabitem.Load(script, grabDetailItem.GrabName)
                  .Replace("&", "&amp;")
                  .Replace("<", "&lt;")
                  .Replace(">", "&gt;")
                  .Replace("\"", "&quot;");
                // strTemp = strTemp.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;").Replace("'", "&apos;");
              break;
            default:
              if ((int) grabDetailItem.OutputMapping < 40)
              {
                datas[(int) grabDetailItem.OutputMapping] = grabitem.Load(script, grabDetailItem.GrabName);
              }
              else
              {
                // only load data, but do not map to outputfield
                grabitem.Load(script, grabDetailItem.GrabName);
              }
              break;
              }
            }
            catch (Exception ex)
            {
              string outputmessage = ex.Message;
            }

              }

              // ***** Original TITLE *****
              // datas[(int)Grabber_Output.OriginalTitle] = grabitem.Load(script, "OTitle");
              //strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartOTitle").InnerText);
              //strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndOTitle").InnerText);
              //strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartOTitle").Attributes["Param1"].InnerText);
              //strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartOTitle").Attributes["Param2"].InnerText);
              //strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyOTitleIndex").InnerText);
              //strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyOTitlePage").InnerText);
              //strActivePage = this.LoadPage(strPage);
              //strTitle = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              //strTitle = strTitle.Replace("\n", "");

              //if (strTitle.Length > 0)
              //  datas[(int)Grabber_Output.OriginalTitle] = strTitle;
              //else
              //  datas[(int)Grabber_Output.OriginalTitle] = "";

              // ***** Translated TITLE *****
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartTTitle").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndTTitle").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartTTitle").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartTTitle").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyTTitleRegExp").InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyTTitleIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyTTitlePage").InnerText);
              try
              { strMaxItems = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyTTitleMaxItems").InnerText); }
              catch (Exception) { strMaxItems = ""; }
              try
              { strLanguage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyTTitleLanguage").InnerText); }
              catch (Exception) { strLanguage = ""; }
              strActivePage = LoadPage(strPage);

              // Overrides from MyFilms plugin:
              if (!string.IsNullOrEmpty(preferredLanguage))
            strLanguage = preferredLanguage;
              if (!string.IsNullOrEmpty(titleLimit))
            strMaxItems = titleLimit;

              allNames = string.Empty;
              allRoles = string.Empty;
              if (strParam1.Length > 0 || strParam3.Length > 0)
            strTitle = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3, strMaxItems, strLanguage, out  allNames, out allRoles).Trim();
              else
            strTitle = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
              strTitle = strTitle.Replace("\n", "");
              if (strTitle.Length > 0)
            //Translated Title
            datas[(int)Grabber_Output.TranslatedTitle] = strTitle;
              else
            datas[(int)Grabber_Output.TranslatedTitle] = "";
              //else
              //    datas[(int)Grabber_Output.TranslatedTitle] = datas[(int)Grabber_Output.OriginalTitle];
              //if (datas[(int)Grabber_Output.OriginalTitle].Length == 0)
              //    datas[(int)Grabber_Output.OriginalTitle] = datas[(int)Grabber_Output.TranslatedTitle];
              datas[(int)Grabber_Output.TranslatedTitleAllNames] = allNames;
              datas[(int)Grabber_Output.TranslatedTitleAllValues] = allRoles;

              // ***** URL for Image *****
              // ***** Fanart ***** //

              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartImg").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndImg").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartImg").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartImg").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyImgIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyImgPage").InnerText);
              strActivePage = LoadPage(strPage);

              datas[(int)Grabber_Output.Fanart] = ""; // Fanart - only for file grabber

              if (strStart.StartsWith("#NFO#") || strEnd.StartsWith("#NFO#")) //
              {
            if (strStart.StartsWith("#NFO#")) // special handling for NFO files
            {
              string covername = strStart.Substring(strStart.IndexOf("#NFO#") + 5);
              if (covername.Contains("#Filename#"))
            covername = covername.Replace("#Filename#", MovieFilename);
              datas[(int)Grabber_Output.PicturePathLong] = MovieDirectory + "\\" + covername;
              datas[(int)Grabber_Output.PicturePathShort] = covername;
              if (saveImage == true)
              {
            if (string.IsNullOrEmpty(datas[(int)Grabber_Output.OriginalTitle]))
              GrabUtil.CopyCoverArt(strPathImg, MovieDirectory + "\\" + covername, datas[(int)Grabber_Output.TranslatedTitle], out strTemp);
            else
              GrabUtil.CopyCoverArt(strPathImg, MovieDirectory + "\\" + covername, datas[(int)Grabber_Output.OriginalTitle], out strTemp);
            datas[(int)Grabber_Output.PicturePathLong] = strPathImg + "\\" + strTemp;
              }
              datas[(int)Grabber_Output.PicturePathShort] = strTemp;
            }
            if (strEnd.StartsWith("#NFO#")) // special handling for NFO files
            {
              string fanartname = strEnd.Substring(strEnd.IndexOf("#NFO#") + 5);
              if (fanartname.Contains("#Filename#"))
            fanartname = fanartname.Replace("#Filename#", MovieFilename);
              datas[(int)Grabber_Output.Fanart] = MovieDirectory + "\\" + fanartname;
            }
              }
              else
              {
            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

            strTemp = strTemp.Replace("\n", "");
            if (strTemp.Length > 0)
            {
              datas[(int)Grabber_Output.PictureURL] = strTemp;
              //Picture
              if (saveImage == true)
              {
            if (string.IsNullOrEmpty(datas[(int)Grabber_Output.OriginalTitle]))
              GrabUtil.DownloadCoverArt(strPathImg, strTemp, datas[(int)Grabber_Output.TranslatedTitle], out strTemp);
            else
              GrabUtil.DownloadCoverArt(strPathImg, strTemp, datas[(int)Grabber_Output.OriginalTitle], out strTemp);
            // strTemp = MediaPortal.Util.Utils.FilterFileName(strTemp); // Guzzi: removed, as it could change the filename to an already loaded image, thus breaking the "link".
            datas[(int)Grabber_Output.PicturePathLong] = strPathImg + "\\" + strTemp;
              }
              datas[(int)Grabber_Output.PicturePathShort] = strTemp;
            }
              }

              // ***** Synopsis ***** Description
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartSyn").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndSyn").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartSyn").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartSyn").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeySynIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeySynPage").InnerText);
              strActivePage = LoadPage(strPage);

              strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strTemp = strTemp.Replace("\n", "");

              // make sure nonvalid Chars are encoded - e.g.
              //< 	-> 	&lt;
              //> 	-> 	&gt;
              //" 	-> 	&quot;
              //' 	-> 	&apos;
              //& 	-> 	&amp;
              // strTemp = System.Web.HttpUtility.HtmlEncode(strTemp.Replace('’', '\''));
              // strTemp = System.Security.SecurityElement.Escape(strTemp); // alternative way to encode invalid Chars - avoids overhead of Web classes
              // strTemp = GrabUtil.StripIllegalXmlChars(strTemp, "1.1");
              strTemp = strTemp.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;"); // strTemp = strTemp.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;").Replace("'", "&apos;");
              // strTemp = strTemp.Replace("\"", "\'");

              if (strTemp.Length > 0) datas[(int)Grabber_Output.Description] = strTemp;

              NumberFormatInfo provider = new NumberFormatInfo();
              provider.NumberDecimalSeparator = ",";

              // ***** Base rating *****
              decimal wRate = 0;
              decimal wRate2 = 0;
              decimal wBasedRate = 10;
              try
              { wBasedRate = Convert.ToDecimal(strBasedRate, provider); }
              catch
              { }
              // ***** NOTE 1 ***** Rating 1
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartRate").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndRate").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartRate").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartRate").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyRateIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyRatePage").InnerText);
              strActivePage = LoadPage(strPage);
              strRate = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
              strRate = GrabUtil.ConvertNote(strRate);
              try
              { wRate = (Convert.ToDecimal(strRate, provider) / wBasedRate) * 10; }
              catch
              { }

              // ***** NOTE 2 ***** Rating 2
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartRate2").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndRate2").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartRate2").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartRate2").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyRate2Index").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyRate2Page").InnerText);
              strActivePage = LoadPage(strPage);
              strRate2 = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strRate2 = GrabUtil.ConvertNote(strRate2);

              try
              { wRate2 = (Convert.ToDecimal(strRate2, provider) / wBasedRate) * 10; }
              catch
              { }

              //Calcul de la moyenne des notes.
              decimal resultRate;
              if (wRate > 0 && wRate2 > 0)
            resultRate = ((wRate + wRate2) / 2);
              else
            if (wRate == 0 && wRate2 == 0)
              resultRate = -1;
            else
              resultRate = ((wRate + wRate2));

              resultRate = Math.Round(resultRate, 1);
              strRate = resultRate == -1 ? "" : Convert.ToString(resultRate);

              //Rating (calculated from Rating 1 and 2)
              strRate = strRate.Replace(",", ".");
              datas[(int)Grabber_Output.Rating] = strRate.Replace(",", ".");

              // ***** Acteurs ***** Actors
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCredits").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndCredits").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCredits").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCredits").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCreditsRegExp").InnerText);
              strMaxItems = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCreditsMaxItems").InnerText);
              strGrabActorRoles = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCreditsGrabActorRoles").InnerText);
              boolGrabActorRoles = strGrabActorRoles == "true";
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCreditsIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCreditsPage").InnerText);
              strActivePage = LoadPage(strPage);
              strLanguage = "";

              // Overrides from MyFilms plugin:
              if (!string.IsNullOrEmpty(personLimit))
            strMaxItems = personLimit.ToString();
              if (!string.IsNullOrEmpty(getRoles))
              {
            if (getRoles.ToLower() == "true") boolGrabActorRoles = true;
            if (getRoles.ToLower() == "false") boolGrabActorRoles = false;
              }

              allNames = string.Empty;
              allRoles = string.Empty;
              if (strParam1.Length > 0 || strParam3.Length > 0) //
            strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3, strMaxItems, strLanguage, out allNames, out allRoles, boolGrabActorRoles).Trim();
              else
            strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              // strTemp = strTemp.Replace("\n", ""); // removed, as it seems, the "newlines" replacements for #LF# didn't work in AMC and MP
              strTemp = GrabUtil.TrimSpaces(strTemp);
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.Actors] = strTemp;

              //// ***** Réalisateur ***** = Director
              //strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartRealise").InnerText);
              //strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndRealise").InnerText);
              //strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartRealise").Attributes["Param1"].InnerText);
              //strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartRealise").Attributes["Param2"].InnerText);
              //strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyRealiseRegExp").InnerText);
              //strMaxItems = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyRealiseMaxItems").InnerText);
              //strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyRealiseIndex").InnerText);
              //strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyRealisePage").InnerText);
              //strActivePage = this.LoadPage(strPage);

              //// Overrides from MyFilms plugin:
              //if (!string.IsNullOrEmpty(personLimit))
              //  strMaxItems = personLimit;

              //if (strParam1.Length > 0 || strParam3.Length > 0)
              //  strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3, strMaxItems).Trim();
              //else
              //  strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              //strTemp = strTemp.Replace("\n", "");
              //if (strTemp.Length > 0)
              //  datas[(int)Grabber_Output.Director] = strTemp;

              //// ***** Producteur ***** Producer // Producers also using MiltiPurpose Secondary page !
              //strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartProduct").InnerText);
              //strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndProduct").InnerText);
              //strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartProduct").Attributes["Param1"].InnerText);
              //strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartProduct").Attributes["Param2"].InnerText);
              //strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyProductRegExp").InnerText);
              //strMaxItems = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyProductMaxItems").InnerText);
              //strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyProductIndex").InnerText);
              //strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyProductPage").InnerText);
              //strActivePage = this.LoadPage(strPage);

              //// Overrides from MyFilms plugin:
              //if (!string.IsNullOrEmpty(personLimit))
              //  strMaxItems = personLimit.ToString();

              //if (strParam1.Length > 0 || strParam3.Length > 0) // Guzzi: Added param3 to execute matchcollections also !
              //  strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3, strMaxItems).Trim();
              //else
              //  strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              //strTemp = strTemp.Replace("\n", "");
              //if (strTemp.Length > 0)
              //  datas[(int)Grabber_Output.Producer] = strTemp;

              // ***** Année ***** Year
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartYear").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndYear").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartYear").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartYear").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyYearIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyYearPage").InnerText);
              strActivePage = LoadPage(strPage);

              strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            if (strTemp.Length >= 4)
              datas[(int)Grabber_Output.Year] = strTemp.Substring(strTemp.Length - 4, 4);
            else
              datas[(int)Grabber_Output.Year] = strTemp; // fallback, if scraping failed

              // ***** Pays ***** Country
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCountry").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndCountry").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCountry").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCountry").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCountryRegExp").InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCountryIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCountryPage").InnerText);
              strActivePage = LoadPage(strPage);

              if (strParam1.Length > 0 || strParam3.Length > 0)
            strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3).Trim();
              else
            strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
              {
            strTemp = strTemp.Replace(".", " ");
            strTemp = GrabUtil.TransformCountry(strTemp);
            datas[(int)Grabber_Output.Country] = strTemp;
              }

              // ***** Genre *****
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartGenre").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndGenre").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartGenre").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartGenre").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGenreRegExp").InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGenreIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGenrePage").InnerText);
              strActivePage = LoadPage(strPage);

              if (strParam1.Length > 0 || strParam3.Length > 0)
            strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3).Trim();
              else
            strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.Category] = strTemp;

              // ***** URL *****
              datas[(int)Grabber_Output.URL] = strUrl;

              // ***** Writer ***** //
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartWriter").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndWriter").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartWriter").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartWriter").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyWriterRegExp").InnerText);
              strMaxItems = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyWriterMaxItems").InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyWriterIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyWriterPage").InnerText);
              strActivePage = LoadPage(strPage);

              // Overrides from MyFilms plugin:
              if (!string.IsNullOrEmpty(personLimit))
            strMaxItems = personLimit;

              if (strParam1.Length > 0 || strParam3.Length > 0) // Guzzi: Added param3 to execute matchcollections also !
            strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3, strMaxItems).Trim();
              else
            strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.Writer] = strTemp;

              // ***** Comment *****
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartComment").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndComment").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartComment").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartComment").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCommentRegExp").InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCommentIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCommentPage").InnerText);
              strActivePage = LoadPage(strPage);

              if (strParam1.Length > 0 || strParam3.Length > 0)
            strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3).Trim();
              else
            strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strTemp = strTemp.Replace("\n", " "); // Guzzi: Replace linebreaks with space
              strTemp = strTemp.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;"); // strTemp = strTemp.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;").Replace("'", "&apos;");
              // strTemp = System.Web.HttpUtility.HtmlEncode(strTemp.Replace('’', '\''));
              // strTemp = System.Security.SecurityElement.Escape(strTemp); // alternative way to encode invalid Chars - avoids overhead of Web classes
              // strTemp = strTemp.Replace("\"", "\'");

              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.Comments] = strTemp;

              // ***** Language *****
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLanguage").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndLanguage").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLanguage").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartLanguage").Attributes["Param2"].InnerText);
              try { strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLanguageRegExp").InnerText); }
              catch (Exception) { strParam3 = ""; }

              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLanguageIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyLanguagePage").InnerText);
              strActivePage = LoadPage(strPage);

              strTemp = (strParam1.Length > 0 || strParam3.Length > 0)
            ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3).Trim()
            : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.Language] = strTemp;

              // ***** Tagline *****
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartTagline").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndTagline").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartTagline").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartTagline").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyTaglineIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyTaglinePage").InnerText);
              strActivePage = LoadPage(strPage);

              strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.Tagline] = strTemp;

              // ***** Certification *****
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCertification").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndCertification").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCertification").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCertification").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCertificationRegExp").InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCertificationIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCertificationPage").InnerText);
              strActivePage = LoadPage(strPage);
              try
              { strLanguage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCertificationLanguage").InnerText); }
              catch (Exception) { strLanguage = ""; }

              // Overrides from MyFilms plugin:
              if (!string.IsNullOrEmpty(preferredLanguage))
            strLanguage = preferredLanguage;

              allNames = string.Empty;
              allRoles = string.Empty;
              if (strParam1.Length > 0 || strParam3.Length > 0)
            strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3, "", strLanguage, out allNames, out allRoles).Trim();
              else
            strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.Certification] = strTemp;
              datas[(int)Grabber_Output.CertificationAllNames] = allNames;
              datas[(int)Grabber_Output.CertificationAllValues] = allRoles;

              // ***** IMDB_Id *****
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartIMDB_Id").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndIMDB_Id").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartIMDB_Id").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartIMDB_Id").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyIMDB_IdIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyIMDB_IdPage").InnerText);
              strActivePage = LoadPage(strPage);

              strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.IMDB_Id] = strTemp;

              // ***** IMDB_Rank *****
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartIMDB_Rank").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndIMDB_Rank").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartIMDB_Rank").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartIMDB_Rank").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyIMDB_RankIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyIMDB_RankPage").InnerText);
              strActivePage = LoadPage(strPage);

              strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.IMDB_Rank] = strTemp;

              // ***** TMDB_Id *****
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartTMDB_Id").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndTMDB_Id").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartTMDB_Id").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartTMDB_Id").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyTMDB_IdIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyTMDB_IdPage").InnerText);
              strActivePage = LoadPage(strPage);

              strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.TMDB_Id] = strTemp;

              // ***** Studio *****
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartStudio").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndStudio").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartStudio").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartStudio").Attributes["Param2"].InnerText);
              try { strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStudioRegExp").InnerText); }
              catch (Exception) { strParam3 = ""; }
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStudioIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStudioPage").InnerText);
              strActivePage = LoadPage(strPage);

              strTemp = (strParam1.Length > 0 || strParam3.Length > 0)
            ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3).Trim()
            : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.Studio] = strTemp;

              // ***** Edition *****
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartEdition").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndEdition").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartEdition").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartEdition").Attributes["Param2"].InnerText);
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEditionIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEditionPage").InnerText);
              strActivePage = LoadPage(strPage);

              strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.Edition] = strTemp;

              // ***** Collection *****
              try
              {
            strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCollection").InnerText);
            strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndCollection").InnerText);
            strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCollection").Attributes["Param1"].InnerText);
            strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCollection").Attributes["Param2"].InnerText);
            strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCollectionIndex").InnerText);
            strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCollectionPage").InnerText);
            strActivePage = LoadPage(strPage);

            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

            strTemp = strTemp.Replace("\n", "");
            if (strTemp.Length > 0)
              datas[(int)Grabber_Output.Collection] = strTemp;
              }
              catch (Exception)
              {
            datas[(int)Grabber_Output.Collection] = "";
              }

              // ***** Collection Image *****
              try
              {
            strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCollectionImageURL").InnerText);
            strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndCollectionImageURL").InnerText);
            strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCollectionImageURL").Attributes["Param1"].InnerText);
            strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartCollectionImageURL").Attributes["Param2"].InnerText);
            strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCollectionImageURLIndex").InnerText);
            strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyCollectionImageURLPage").InnerText);
            strActivePage = LoadPage(strPage);

            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

            strTemp = strTemp.Replace("\n", "");
            if (strTemp.Length > 0 && datas[(int)Grabber_Output.Collection].Length > 0) // only grab image, if there is also a collection name found !
            {
              datas[(int)Grabber_Output.CollectionImage] = strTemp;
              //Picture for Collections Download
              if (saveImage == true)
              {
            GrabUtil.DownloadCoverArt(strPathImg, strTemp, datas[(int)Grabber_Output.CollectionImage], out strTemp);
            // datas[(int)Grabber_Output.PicturePathLong] = strPathImg + "\\" + strTemp;
              }
              // datas[(int)Grabber_Output.PicturePathShort] = strTemp;
            }
              }
              catch (Exception)
              {
            datas[(int)Grabber_Output.CollectionImage] = "";
              }

              // ***** Runtime *****
              try
              {
            strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartRuntime").InnerText);
            strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndRuntime").InnerText);
            strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartRuntime").Attributes["Param1"].InnerText);
            strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartRuntime").Attributes["Param2"].InnerText);
            strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyRuntimeIndex").InnerText);
            strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyRuntimePage").InnerText);
            strActivePage = LoadPage(strPage);

            strTemp = strParam1.Length > 0 ? GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2).Trim() : GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();

            strTemp = strTemp.Replace("\n", "");
            if (strTemp.Length > 0)
              datas[(int)Grabber_Output.Runtime] = strTemp;
              }
              catch (Exception)
              {
            datas[(int)Grabber_Output.Runtime] = "";
              }

              // ***** Generic Field 1 ***** //
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartGeneric1").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndGeneric1").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartGeneric1").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartGeneric1").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric1RegExp").InnerText);
              try
              { strMaxItems = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric1MaxItems").InnerText); }
              catch (Exception) { strMaxItems = ""; }
              try
              { strLanguage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric1Language").InnerText); }
              catch (Exception) { strLanguage = ""; }
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric1Index").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric1Page").InnerText);
              strActivePage = LoadPage(strPage);

              // Overrides from MyFilms plugin:
              //if (!string.IsNullOrEmpty(PreferredLanguage)) strLanguage = PreferredLanguage;
              //if (!string.IsNullOrEmpty(TitleLimit)) strMaxItems = TitleLimit.ToString();
              //if (!string.IsNullOrEmpty(PersonLimit)) strMaxItems = PersonLimit.ToString();

              allNames = string.Empty;
              allRoles = string.Empty;
              if (strParam1.Length > 0 || strParam3.Length > 0)
            strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3, strMaxItems, strLanguage, out  allNames, out allRoles).Trim();
              else
            strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
              strTemp = strTemp.Replace("\n", "");
              strTemp = GrabUtil.StripIllegalXmlChars(strTemp, "1.0"); // strTemp = strTemp.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;"); // strTemp = strTemp.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;").Replace("'", "&apos;");

              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.Generic1] = strTemp;
              else
            datas[(int)Grabber_Output.Generic1] = "";

              // ***** Generic Field 2 ***** //
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartGeneric2").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndGeneric2").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartGeneric2").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartGeneric2").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric2RegExp").InnerText);
              try
              { strMaxItems = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric2MaxItems").InnerText); }
              catch (Exception) { strMaxItems = ""; }
              try
              { strLanguage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric2Language").InnerText); }
              catch (Exception) { strLanguage = ""; }
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric2Index").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric2Page").InnerText);
              strActivePage = LoadPage(strPage);

              // Overrides from MyFilms plugin:
              //if (!string.IsNullOrEmpty(PreferredLanguage)) strLanguage = PreferredLanguage;
              //if (!string.IsNullOrEmpty(TitleLimit)) strMaxItems = TitleLimit.ToString();
              //if (!string.IsNullOrEmpty(PersonLimit)) strMaxItems = PersonLimit.ToString();

              allNames = string.Empty;
              allRoles = string.Empty;
              if (strParam1.Length > 0 || strParam3.Length > 0)
            strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3, strMaxItems, strLanguage, out  allNames, out allRoles).Trim();
              else
            strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
              strTemp = strTemp.Replace("\n", "");
              strTemp = GrabUtil.StripIllegalXmlChars(strTemp, "1.0"); // strTemp = strTemp.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;"); // strTemp = strTemp.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;").Replace("'", "&apos;");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.Generic2] = strTemp;
              else
            datas[(int)Grabber_Output.Generic2] = "";

              // ***** Generic Field 3 ***** //
              datas[(int)Grabber_Output.Generic3] = grabitem.Load(script, "Generic3");

              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartGeneric3").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndGeneric3").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartGeneric3").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartGeneric3").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric3RegExp").InnerText);
              try
              { strMaxItems = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric3MaxItems").InnerText); }
              catch (Exception) { strMaxItems = ""; }
              try
              { strLanguage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric3Language").InnerText); }
              catch (Exception) { strLanguage = ""; }
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric3Index").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyGeneric3Page").InnerText);
              strActivePage = LoadPage(strPage);

              // Overrides from MyFilms plugin:
              //if (!string.IsNullOrEmpty(PreferredLanguage)) strLanguage = PreferredLanguage;
              //if (!string.IsNullOrEmpty(TitleLimit)) strMaxItems = TitleLimit.ToString();
              //if (!string.IsNullOrEmpty(PersonLimit)) strMaxItems = PersonLimit.ToString();

              allNames = string.Empty;
              allRoles = string.Empty;
              if (strParam1.Length > 0 || strParam3.Length > 0)
            strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3, strMaxItems, strLanguage, out  allNames, out allRoles).Trim();
              else
            strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
              strTemp = strTemp.Replace("\n", "");
              strTemp = GrabUtil.StripIllegalXmlChars(strTemp, "1.0"); // strTemp = strTemp.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;"); // strTemp = strTemp.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;").Replace("'", "&apos;");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.Generic3] = strTemp;
              else
            datas[(int)Grabber_Output.Generic3] = "";

              // ***********************************
              // new key-value listingoutputs
              // ***********************************

              // ***** MultiPosters ***** //
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartMultiPosters").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndMultiPosters").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartMultiPosters").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartMultiPosters").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyMultiPostersRegExp").InnerText);
              try
              { strMaxItems = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyMultiPostersMaxItems").InnerText); }
              catch (Exception) { strMaxItems = ""; }
              try
              { strLanguage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyMultiPostersLanguage").InnerText); }
              catch (Exception) { strLanguage = ""; }
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyMultiPostersIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyMultiPostersPage").InnerText);
              strActivePage = LoadPage(strPage);

              // Overrides from MyFilms plugin:
              //if (!string.IsNullOrEmpty(PreferredLanguage)) strLanguage = PreferredLanguage;
              //if (!string.IsNullOrEmpty(TitleLimit)) strMaxItems = TitleLimit.ToString();
              //if (!string.IsNullOrEmpty(PersonLimit)) strMaxItems = PersonLimit.ToString();

              allNames = string.Empty;
              allRoles = string.Empty;
              if (strParam1.Length > 0 || strParam3.Length > 0)
            strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3, strMaxItems, strLanguage, out  allNames, out allRoles, true).Trim();
              else
            strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.MultiPosters] = strTemp;
              else
            datas[(int)Grabber_Output.MultiPosters] = "";

              // ***** Photos ***** //
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartPhotos").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndPhotos").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartPhotos").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartPhotos").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyPhotosRegExp").InnerText);
              try
              { strMaxItems = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyPhotosMaxItems").InnerText); }
              catch (Exception) { strMaxItems = ""; }
              try
              { strLanguage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyPhotosLanguage").InnerText); }
              catch (Exception) { strLanguage = ""; }
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyPhotosIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyPhotosPage").InnerText);
              strActivePage = LoadPage(strPage);

              // Overrides from MyFilms plugin:
              //if (!string.IsNullOrEmpty(PreferredLanguage)) strLanguage = PreferredLanguage;
              //if (!string.IsNullOrEmpty(TitleLimit)) strMaxItems = TitleLimit.ToString();
              //if (!string.IsNullOrEmpty(PersonLimit)) strMaxItems = PersonLimit.ToString();

              allNames = string.Empty;
              allRoles = string.Empty;
              if (strParam1.Length > 0 || strParam3.Length > 0)
            strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3, strMaxItems, strLanguage, out  allNames, out allRoles, true).Trim();
              else
            strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.Photos] = strTemp;
              else
            datas[(int)Grabber_Output.Photos] = "";

              // ***** PersonImages ***** //
              strStart  = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartPersonImages").InnerText);
              strEnd    = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndPersonImages").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartPersonImages").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartPersonImages").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyPersonImagesRegExp").InnerText);
              try
              { strMaxItems = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyPersonImagesMaxItems").InnerText); }
              catch (Exception) { strMaxItems = ""; }
              try
              { strLanguage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyPersonImagesLanguage").InnerText); }
              catch (Exception) { strLanguage = ""; }
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyPersonImagesIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyPersonImagesPage").InnerText);
              strActivePage = LoadPage(strPage);

              // Overrides from MyFilms plugin:
              //if (!string.IsNullOrEmpty(PreferredLanguage)) strLanguage = PreferredLanguage;
              //if (!string.IsNullOrEmpty(TitleLimit)) strMaxItems = TitleLimit.ToString();
              //if (!string.IsNullOrEmpty(PersonLimit)) strMaxItems = PersonLimit.ToString();

              allNames = string.Empty;
              allRoles = string.Empty;
              if (strParam1.Length > 0 || strParam3.Length > 0)
            strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3, strMaxItems, strLanguage, out  allNames, out allRoles, true).Trim();
              else
            strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.PersonImages] = strTemp;
              else
            datas[(int)Grabber_Output.PersonImages] = "";

              // ***** MultiFanart ***** //
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartMultiFanart").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndMultiFanart").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartMultiFanart").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartMultiFanart").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyMultiFanartRegExp").InnerText);
              try
              { strMaxItems = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyMultiFanartMaxItems").InnerText); }
              catch (Exception) { strMaxItems = ""; }
              try
              { strLanguage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyMultiFanartLanguage").InnerText); }
              catch (Exception) { strLanguage = ""; }
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyMultiFanartIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyMultiFanartPage").InnerText);
              strActivePage = LoadPage(strPage);

              // Overrides from MyFilms plugin:
              //if (!string.IsNullOrEmpty(PreferredLanguage)) strLanguage = PreferredLanguage;
              //if (!string.IsNullOrEmpty(TitleLimit)) strMaxItems = TitleLimit.ToString();
              //if (!string.IsNullOrEmpty(PersonLimit)) strMaxItems = PersonLimit.ToString();

              allNames = string.Empty;
              allRoles = string.Empty;
              if (strParam1.Length > 0 || strParam3.Length > 0)
            strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3, strMaxItems, strLanguage, out  allNames, out allRoles, true).Trim();
              else
            strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.MultiFanart] = strTemp;
              else
            datas[(int)Grabber_Output.MultiFanart] = "";

              // ***** Trailer ***** //
              strStart = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartTrailer").InnerText);
              strEnd = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyEndTrailer").InnerText);
              strParam1 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartTrailer").Attributes["Param1"].InnerText);
              strParam2 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyStartTrailer").Attributes["Param2"].InnerText);
              strParam3 = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyTrailerRegExp").InnerText);
              try
              { strMaxItems = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyTrailerMaxItems").InnerText); }
              catch (Exception) { strMaxItems = ""; }
              try
              { strLanguage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyTrailerLanguage").InnerText); }
              catch (Exception) { strLanguage = ""; }
              strIndex = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyTrailerIndex").InnerText);
              strPage = XmlConvert.DecodeName(script.SelectSingleNodeFast("Details/KeyTrailerPage").InnerText);
              strActivePage = LoadPage(strPage);

              // Overrides from MyFilms plugin:
              //if (!string.IsNullOrEmpty(PreferredLanguage)) strLanguage = PreferredLanguage;
              //if (!string.IsNullOrEmpty(TitleLimit)) strMaxItems = TitleLimit.ToString();
              //if (!string.IsNullOrEmpty(PersonLimit)) strMaxItems = PersonLimit.ToString();

              allNames = string.Empty;
              allRoles = string.Empty;
              if (strParam1.Length > 0 || strParam3.Length > 0)
            strTemp = GrabUtil.FindWithAction(ExtractBody(strActivePage, strIndex, script), strStart, strEnd, strParam1, strParam2, strParam3, strMaxItems, strLanguage, out  allNames, out allRoles, true).Trim();
              else
            strTemp = GrabUtil.Find(ExtractBody(strActivePage, strIndex, script), strStart, strEnd).Trim();
              strTemp = strTemp.Replace("\n", "");
              if (strTemp.Length > 0)
            datas[(int)Grabber_Output.Trailer] = strTemp;
              else
            datas[(int)Grabber_Output.Trailer] = "";
              #endregion

              #region mapping of fields to output
              // **********************************************************************************************************
              // Do mapping, if any configured...
              // **********************************************************************************************************
              string[] source = new string[40];
              string[] destination = new string[40];
              bool[] replace = new bool[40];
              bool[] addStart = new bool[40];
              bool[] addEnd = new bool[40];
              bool[] mergePreferSource = new bool[40];
              bool[] mergePreferDestination = new bool[40];

              List<string> fields = FieldList();

              // Read Config
              for (int t = 0; t < 40; t++)
              {
            try
            {
              source[t] = XmlConvert.DecodeName(script.SelectSingleNodeFast("Mapping/Field_" + t.ToString()).Attributes["source"].InnerText);
              if (source[t] == "") source[t] = fields[t]; // replace with "right DB field name" if it is empty (for upgrade compatibility)
              destination[t] = XmlConvert.DecodeName(script.SelectSingleNodeFast("Mapping/Field_" + t.ToString()).Attributes["destination"].InnerText);
              replace[t] = Convert.ToBoolean(XmlConvert.DecodeName(script.SelectSingleNodeFast("Mapping/Field_" + t.ToString()).Attributes["replace"].InnerText));
              addStart[t] = Convert.ToBoolean(XmlConvert.DecodeName(script.SelectSingleNodeFast("Mapping/Field_" + t.ToString()).Attributes["addstart"].InnerText));
              addEnd[t] = Convert.ToBoolean(XmlConvert.DecodeName(script.SelectSingleNodeFast("Mapping/Field_" + t.ToString()).Attributes["addend"].InnerText));
              mergePreferSource[t] = Convert.ToBoolean(XmlConvert.DecodeName(script.SelectSingleNodeFast("Mapping/Field_" + t.ToString()).Attributes["mergeprefersource"].InnerText));
              mergePreferDestination[t] = Convert.ToBoolean(XmlConvert.DecodeName(script.SelectSingleNodeFast("Mapping/Field_" + t.ToString()).Attributes["mergepreferdestination"].InnerText));
            }
            catch (Exception)
            {
              source[t] = fields[t];
              destination[t] = "";
              replace[t] = false;
              addStart[t] = false;
              addEnd[t] = false;
              mergePreferSource[t] = false;
              mergePreferDestination[t] = false;
            }
              }

              for (int t = 0; t < 40; t++) // set default values = source
              {
            datas[t + 40] = !string.IsNullOrEmpty(datas[t]) ? datas[t] : string.Empty; // set destination = source as default (base if no other transformations)
              }
              for (int t = 0; t < 40; t++) // replace values if configured
              {
            for (int i = 0; i < 40; i++) // search for mapping destination
            {
              if (destination[t] == source[i]) // found mapping destination -> datas[i] is destination object !
              {
            if (replace[t]) // replace action
              datas[i + 40] = !String.IsNullOrEmpty(datas[t]) ? datas[t] : string.Empty;
              }
            }
              }
              for (int t = 0; t < 40; t++) // merge prefer source - replace values only if source is not empty
              {
            for (int i = 0; i < 40; i++)
            {
              if (destination[t] == source[i])
              {
            if (mergePreferSource[t] && !string.IsNullOrEmpty(datas[t])) // replace action
              datas[i + 40] = datas[t];
              }
            }
              }
              for (int t = 0; t < 40; t++) // merge prefer destination - replace values only if destination empty
              {
            for (int i = 0; i < 40; i++)
            {
              if (destination[t] == source[i])
              {
            if (mergePreferDestination[t] && string.IsNullOrEmpty(datas[i])) // replace action
              datas[i + 40] = datas[t];
              }
            }
              }
              for (int t = 0; t < 40; t++) // insert or append values if configured
              {
            for (int i = 0; i < 40; i++) // search for mapping destination
            {
              if (destination[t] == source[i]) // found mapping destination -> datas[i] is destination object !
              {
            if (addStart[t] && !string.IsNullOrEmpty(datas[t])) // addStart action - only of not empty (avoid empty new line)
              datas[i + 40] = datas[t] + System.Environment.NewLine + datas[i + 40];
            if (addEnd[t] && !string.IsNullOrEmpty(datas[t])) // addEnd action - only if not empty (avoid empty new line)
              datas[i + 40] = datas[i + 40] + System.Environment.NewLine + datas[t];
              }
            }
              }
              #endregion

              return datas;
        }