public Person GetPersonDetails(Int64 PersonCode) { string Page = ""; Person person = new Person(); WebClient web = new WebClient(); string strPersonCode = PersonCode.ToString("0000000"); //Page = GetString("p_" + strPersonCode + "_main.txt", "http://www.imdb.com/name/nm" + strPersonCode + "/"); Page = GetString("p_" + strPersonCode + "_main.txt", "/name/nm" + strPersonCode + "/"); if (Page.Length == 0) { //tragically exit return null; } person.iCode = PersonCode; MatchCollection vMC_Name = rPersonDetails_Name.Matches(Page); if (vMC_Name.Count != 1) { //WTF? } person.sName = vMC_Name[0].Groups["Name"].Value; string HeadshotLink = ""; MatchCollection vMC_Headshot = rPersonDetails_Headshot.Matches(Page); if (vMC_Headshot.Count != 1) { //WTF? } else { HeadshotLink = vMC_Headshot[0].Groups["Headshot"].Value; } MatchCollection vMC_DateOfBirth = rPersonDetails_DateOfBirth.Matches(Page); if (vMC_DateOfBirth.Count != 1) { //WTF? } else { int day = int.Parse(vMC_DateOfBirth[0].Groups["Day"].Value); int year = int.Parse(vMC_DateOfBirth[0].Groups["Year"].Value); string month = vMC_DateOfBirth[0].Groups["Month"].Value; int imonth = 0; if (month == "January") imonth = 1; if (month == "February") imonth = 2; if (month == "March") imonth = 3; if (month == "April") imonth = 4; if (month == "May") imonth = 5; if (month == "June") imonth = 6; if (month == "July") imonth = 7; if (month == "August") imonth = 8; if (month == "September") imonth = 9; if (month == "October") imonth = 10; if (month == "November") imonth = 11; if (month == "December") imonth = 12; person.dDateOfBirth = new DateTime(year, imonth, day); person.hasDateOfBirth = true; } MatchCollection vMC_Acted = rPersonDetails_Acted.Matches(Page); if (vMC_Acted.Count != 1) { //WTF? - may be empty } else { MatchCollection vMC_LIRegion = rPersonDetails_LIRegion.Matches(vMC_Acted[0].Groups["Acted"].Value); if (vMC_LIRegion.Count <= 0) { //WTF? } foreach (Match vM_LIRegion in vMC_LIRegion) { MatchCollection vMC_MainValues = rPersonDetails_MainValues.Matches(vM_LIRegion.Groups["LIRegion"].Value); if (vMC_MainValues.Count != 1) { //WTF? } foreach (Match vM_MainValues in vMC_MainValues) { Movie m = new Movie(); m.lTitles.Add(new Movie.MovieTitle(vM_MainValues.Groups["Title"].Value, false)); m.iCode = long.Parse(vM_MainValues.Groups["Code"].Value); m.iYear = int.Parse(vM_MainValues.Groups["Year"].Value); MatchCollection vMC_AKA = rPersonDetails_AKA.Matches(vM_MainValues.Groups["AKAs"].Value); foreach (Match vM_AKA in vMC_AKA) { m.lTitles.Add(new Movie.MovieTitle(QCleanup(vM_AKA.Groups["AKA"].Value), true)); } person.lCasted.Add(m); } } } //Directed MatchCollection vMC_Directed = rPersonDetails_Directed.Matches(Page); if (vMC_Directed.Count != 1) { //WTF? - may be empty } else { MatchCollection vMC_LIRegion = rPersonDetails_LIRegion.Matches(vMC_Directed[0].Groups["Directed"].Value); if (vMC_LIRegion.Count <= 0) { //WTF? } foreach (Match vM_LIRegion in vMC_LIRegion) { MatchCollection vMC_MainValues = rPersonDetails_MainValues.Matches(vM_LIRegion.Groups["LIRegion"].Value); if (vMC_MainValues.Count != 1) { //WTF? } foreach (Match vM_MainValues in vMC_MainValues) { Movie m = new Movie(); m.lTitles.Add(new Movie.MovieTitle(vM_MainValues.Groups["Title"].Value, false)); m.iCode = long.Parse(vM_MainValues.Groups["Code"].Value); m.iYear = int.Parse(vM_MainValues.Groups["Year"].Value); MatchCollection vMC_AKA = rPersonDetails_AKA.Matches(vM_MainValues.Groups["AKAs"].Value); foreach (Match vM_AKA in vMC_AKA) { m.lTitles.Add(new Movie.MovieTitle(QCleanup(vM_AKA.Groups["AKA"].Value), true)); } person.lDirected.Add(m); } } } //Writed MatchCollection vMC_Writed = rPersonDetails_Writed.Matches(Page); if (vMC_Writed.Count != 1) { //WTF? - may be empty } else { MatchCollection vMC_LIRegion = rPersonDetails_LIRegion.Matches(vMC_Writed[0].Groups["Writed"].Value); if (vMC_LIRegion.Count <= 0) { //WTF? } foreach (Match vM_LIRegion in vMC_LIRegion) { MatchCollection vMC_MainValues = rPersonDetails_MainValues.Matches(vM_LIRegion.Groups["LIRegion"].Value); if (vMC_MainValues.Count != 1) { //WTF? } foreach (Match vM_MainValues in vMC_MainValues) { Movie m = new Movie(); m.lTitles.Add(new Movie.MovieTitle(vM_MainValues.Groups["Title"].Value, false)); m.iCode = long.Parse(vM_MainValues.Groups["Code"].Value); m.iYear = int.Parse(vM_MainValues.Groups["Year"].Value); MatchCollection vMC_AKA = rPersonDetails_AKA.Matches(vM_MainValues.Groups["AKAs"].Value); foreach (Match vM_AKA in vMC_AKA) { m.lTitles.Add(new Movie.MovieTitle(QCleanup(vM_AKA.Groups["AKA"].Value), true)); } person.lWritten.Add(m); } } } if (HeadshotLink.Length > 0) { //atentie poate nu e jpg!!! person.bHeadshot = LoadData("p_" + strPersonCode + "_headshot.dat"); if (person.bHeadshot == null) { web.Headers.Add("user-agent", global::Alexandria.Imdb.Properties.Settings.Default["UserAgent"].ToString()); person.bHeadshot = web.DownloadData(HeadshotLink); SaveData("p_" + strPersonCode + "_headshot.dat", person.bHeadshot); } } //Donwload damn bio page //Page = GetString("p_" + strPersonCode + "_bio.txt", "http://www.imdb.com/name/nm" + strPersonCode + "/bio"); Page = GetString("p_" + strPersonCode + "_bio.txt", "/name/nm" + strPersonCode + "/bio"); if (Page.Length != 0) { MatchCollection vMC_Bio = rPersonDetails_Bio.Matches(Page); if (vMC_Bio.Count != 1) { //WTF? } else { person.sBio = QCleanup(vMC_Bio[0].Groups["Bio"].Value); } } //Most voted movies...damn...this is hard ;) //Page = GetString("p_" + strPersonCode + "_mostvoted.txt", "http://www.imdb.com/name/nm" + strPersonCode + "/filmovote"); Page = GetString("p_" + strPersonCode + "_mostvoted.txt", "/name/nm" + strPersonCode + "/filmovote"); if (Page.Length != 0) { MatchCollection vMC_MostVoted = rPersonDetails_MostVoted.Matches(Page); if (vMC_MostVoted.Count != 1) { //WTF? } else { MatchCollection vMC_TRRegion = rPersonDetails_TRRegion.Matches(vMC_MostVoted[0].Groups["MostVoted"].Value); foreach (Match vM_TRRegion in vMC_TRRegion) { MatchCollection vMC_MostVotedMain = rPersonDetails_MostVotedMain.Matches(vM_TRRegion.Groups["TRRegion"].Value); foreach (Match vM_MostVotedMain in vMC_MostVotedMain) { Int64 code = Int64.Parse(vM_MostVotedMain.Groups["Code"].Value); int votes = int.Parse(vM_MostVotedMain.Groups["Votes"].Value.Replace(",", "")); for (int index = 0; index < person.lCasted.Count; index++) { if (person.lCasted[index].iCode == code) { person.lCasted[index].iVotes = votes; } } } } } } return person; }
public bool Expired(Person pd) { //return true if pd expired return false; }