コード例 #1
0
ファイル: Imdb.cs プロジェクト: thshr/SL-movdb
 //Parse IMDb page data
 private void parseIMDbPage(string html, bool GetExtraInfo)
 {
     Id = match(@"<link rel=""canonical"" href=""http://www.imdb.com/title/(tt\d{7})/"" />", html);
     if (!string.IsNullOrEmpty(Id))
     {
         status        = true;
         Title         = match(@"<title>(IMDb \- )*(.*?) \(.*?</title>", html, 2);
         OriginalTitle = match(@"title-extra"">(.*?)<", html);
         Year          = match(@"<title>.*?\(.*?(\d{4}).*?\).*?</title>", html);
         Rating        = match(@"ratingValue"">(\d.\d)<", html);
         Genres        = new ArrayList();
         Genres        = matchAll(@"<a.*?>(.*?)</a>", match(@"Genres:</h4>(.*?)</div>", html));
         Directors     = new ArrayList();
         Directors     = matchAll(@"<a.*?>(.*?)</a>", match(@"Directors?:[\n\r\s]*</h4>(.*?)(</div>|>.?and )", html));
         Writers       = matchAll(@"<a.*?>(.*?)</a>", match(@"Writers?:[\n\r\s]*</h4>(.*?)(</div>|>.?and )", html));
         Stars         = matchAll(@"<a.*?>(.*?)</a>", match(@"Stars?:(.*?)</div>", html));
         Cast          = matchAll(@"class=""name"">[\n\r\s]*<a.*?>(.*?)</a>", html);
         Plot          = match(@"<p itemprop=""description"">(.*?)</p>", html);
         ReleaseDate   = match(@"Release Date:</h4>.*?(\d{1,2} (January|February|March|April|May|June|July|August|September|October|November|December) (19|20)\d{2}).*(\(|<span)", html);
         Runtime       = match(@"Runtime:</h4>[\s]*.*?(\d{1,4}) min[\s]*.*?\<\/div\>", html);
         if (String.IsNullOrEmpty(Runtime))
         {
             Runtime = match(@"infobar.*?([0-9]+) min.*?</div>", html);
         }
         Top250      = match(@"Top 250 #(\d{1,3})<", html);
         Oscars      = match(@"Won (\d{1,2}) Oscars\.", html);
         Awards      = match(@"(\d{1,4}) wins", html);
         Nominations = match(@"(\d{1,4}) nominations", html);
         Storyline   = match(@"Storyline</h2>[\s]*<p>(.*?)[\s]*(<em|</p>)", html);
         Tagline     = match(@"Taglines?:</h4>(.*?)(<span|</div)", html);
         MpaaRating  = match(@"infobar"">.*?<img.*?alt=""(.*?)"" src="".*?certificates.*?"".*?>", html);
         Votes       = match(@"href=""ratings"".*?>(\d+,?\d*)</span> votes</a>", html);
         Languages   = new ArrayList();
         Languages   = matchAll(@"<a.*?>(.*?)</a>", match(@"Language.?:(.*?)(</div>|>.?and )", html));
         Countries   = new ArrayList();
         Countries   = matchAll(@"<a.*?>(.*?)</a>", match(@"Country:(.*?)(</div>|>.?and )", html));
         Poster      = match(@"img_primary"">[\n\r\s]*?<a.*?><img src=""(.*?)"".*?</td>", html);
         if (!string.IsNullOrEmpty(Poster) && Poster.IndexOf("nopicture") < 0)
         {
             PosterSmall = Poster.Substring(0, Poster.IndexOf("_V1.")) + "_V1._SY150.jpg";
             PosterLarge = Poster.Substring(0, Poster.IndexOf("_V1.")) + "_V1._SY500.jpg";
             PosterFull  = Poster.Substring(0, Poster.IndexOf("_V1.")) + "_V1._SY0.jpg";
         }
         else
         {
             Poster      = string.Empty;
             PosterSmall = string.Empty;
             PosterLarge = string.Empty;
             PosterFull  = string.Empty;
         }
         ImdbURL = "http://www.imdb.com/title/" + Id + "/";
         if (GetExtraInfo)
         {
             ReleaseDates = getReleaseDates();
             MediaImages  = getMediaImages();
         }
     }
 }