Пример #1
0
        private bool Func_NMAnalysisLStars(HtmlNode hnode)
        {
            NewMovieStars.Clear();
            listInformation.SelectedIndex = listInformation.Items.Add("READ: STARS...");
            HtmlNode ncast = hnode.SelectSingleNode("//div[@id='video_cast']");

            string jname = string.Empty;

            NewMovieInfo.ActorUIDs = new List <Guid>();

            if (!ncast.SelectSingleNode("//td[@class='text']").HasChildNodes)
            {
                MessageBox.Show($"No cast information from {NewMovieQuerySite.QName.ToUpper()}.\nTry other web source.", "Expect Cast Data");
                return(false);
            }

            HtmlNodeCollection ncasts = ncast.SelectNodes("//span[@class='star']/a");

            foreach (HtmlNode _nc in ncasts)
            {
                bool is_star_stored = true;
                jname = XService.IllegalFiltered(_nc.InnerText.Replace("&nbsp;", "").Trim());
                StarInfo star = XGlobal.CurrentContext.TotalStars.Find(s => s.JName == jname);
                if (star is null)
                {
                    star           = new StarInfo(jname);
                    is_star_stored = false;
                }

                star.CreateLocalStarDirectory(NewMovieInfo);
                listInformation.SelectedIndex = listInformation.Items.Add($"CREATE: DIR/{System.IO.Path.Combine(System.IO.Path.GetPathRoot(NewMovieInfo.SourcePath), ConfigurationManager.AppSettings["ArchiveName"], star.JName)}");

                star.StoredMovieIDs.Add(NewMovieInfo.ReleaseID);
                NewMovieStars.Add(star);
                NewMovieInfo.ActorUIDs.Add(star.UniqueID);
                if (!is_star_stored)
                {
                    XGlobal.CurrentContext.TotalStars.Add(star);
                }
            }

            return(true);
        }
Пример #2
0
        private async Task <bool> Func_AnalysisStars(HtmlNode sourcenode)
        {
            NewMovieStars.Clear();
            listInformation.SelectedIndex = listInformation.Items.Add("READ: STARS...");

            HtmlNodeCollection _hncc = sourcenode.SelectNodes("//a[@class='avatar-box']");

            string name_ja = string.Empty;

            NewMovieInfo.ActorUIDs = new List <Guid>();

            if (_hncc == null)
            {
                MessageBox.Show($"No movie information from{NewMovieQuerySite.QName.ToUpper()}.\nTry other web source.", "數據缺損");
                //return false;
            }
            else
            {
                foreach (HtmlNode _node in _hncc)
                {
                    bool is_star_stored = true;
                    name_ja = XService.IllegalFiltered(_node.SelectSingleNode(".//span").InnerText.Trim());
                    StarInfo star = XGlobal.CurrentContext.TotalStars.Find(s => s.JName == name_ja);
                    if (star is null)
                    {
                        star           = new StarInfo(name_ja);
                        is_star_stored = false;
                    }

                    //Read Avator to Stream
                    listInformation.SelectedIndex = listInformation.Items.Add($"CREATE: DIR/{star.JName}/TEMP");

                    star.AvatorWebUrl = XService.UrlCheck(_node.SelectSingleNode(".//img").Attributes["src"].Value);
                    //star.CreateStarDirectoryTemp();
                    star.CreateLocalStarDirectory(NewMovieInfo);

                    Stream temp = await XService.Func_Net_ReadWebStream(star.AvatorWebUrl, NewMovieInfo.OfficialWeb);

                    var au = new Uri(star.AvatorWebUrl);
                    star.AvatorFileName = System.IO.Path.Combine(star.DirStored, au.Segments[au.Segments.Length - 1]);

                    using (FileStream sourceStream = new FileStream(star.AvatorFileName, FileMode.Create, FileAccess.Write, FileShare.None, bufferSize: 4096, useAsync: true))
                    {
                        await temp.CopyToAsync(sourceStream);

                        await sourceStream.FlushAsync();
                    }

                    //list_CurrentStars.Images.Add(Image.FromStream(temp));

                    star.StoredMovieIDs.Add(NewMovieInfo.ReleaseID);
                    NewMovieStars.Add(star);
                    NewMovieInfo.ActorUIDs.Add(star.UniqueID);
                    if (!is_star_stored)
                    {
                        XGlobal.CurrentContext.TotalStars.Add(star);
                    }
                }
            }

            return(true);
        }