public static void SetMovieProperties(GUIListItem item)
{
try
{
GUIPropertyManager.SetProperty("#isfolder", item.IsFolder.ToString());
IMDBMovie info = item.AlbumInfoTag as IMDBMovie;
if (info == null)
{
return;
}
string titleExt = info.Title + "{" + info.ID + "}";
string strThumb = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
GUIPropertyManager.SetProperty("#director", info.Director);
GUIPropertyManager.SetProperty("#genre", info.Genre.Replace(" /", ","));
GUIPropertyManager.SetProperty("#cast", info.Cast);
GUIPropertyManager.SetProperty("#dvdlabel", info.DVDLabel);
GUIPropertyManager.SetProperty("#imdbnumber", info.IMDBNumber);
GUIPropertyManager.SetProperty("#file", info.File);
GUIPropertyManager.SetProperty("#plot", HttpUtility.HtmlDecode(info.Plot));
GUIPropertyManager.SetProperty("#plotoutline", info.PlotOutline);
GUIPropertyManager.SetProperty("#userreview", info.UserReview);
GUIPropertyManager.SetProperty("#rating", info.Rating.ToString());
GUIPropertyManager.SetProperty("#userrating", info.UserRating.ToString());
GUIPropertyManager.SetProperty("#strrating", info.Rating.ToString(CultureInfo.CurrentCulture) + "/10");
GUIPropertyManager.SetProperty("#tagline", info.TagLine);
//Votes
Int32 votes = 0;
string strVotes = string.Empty;
if (Int32.TryParse(info.Votes.Replace(".", string.Empty).Replace(",", string.Empty), out votes))
{
strVotes = String.Format("{0:N0}", votes);
}
GUIPropertyManager.SetProperty("#votes", strVotes);
//
GUIPropertyManager.SetProperty("#credits", info.WritingCredits.Replace(" /", ","));
GUIPropertyManager.SetProperty("#thumb", strThumb);
GUIPropertyManager.SetProperty("#title", info.Title);
GUIPropertyManager.SetProperty("#year", ((info.Year <= 1900) ? string.Empty : info.Year.ToString()));
// MPAA
info.MPARating = Util.Utils.MakeFileName(info.MPARating);
GUIPropertyManager.SetProperty("#mpaarating", info.MPARating);
//
GUIPropertyManager.SetProperty("#studios", info.Studios.Replace(" /", ","));
GUIPropertyManager.SetProperty("#country", info.Country);
GUIPropertyManager.SetProperty("#language", info.Language);
//
GUIPropertyManager.SetProperty("#tmdbnumber", info.TMDBNumber);
GUIPropertyManager.SetProperty("#localdbnumber", info.LocalDBNumber);
GUIPropertyManager.SetProperty("#moviecollection", info.MovieCollection.Replace(" /", ","));
GUIPropertyManager.SetProperty("#usergroups", info.UserGroup.Replace(" /", ","));
GUIPropertyManager.SetProperty("#moviepath", info.Path);
GUIPropertyManager.SetProperty("#isgroup", (string.IsNullOrEmpty(info.SingleUserGroup) ? "no" : "yes"));
GUIPropertyManager.SetProperty("#iscollection", (string.IsNullOrEmpty(info.SingleMovieCollection) ? "no" : "yes"));
// Last update date
DateTime lastUpdate;
DateTime.TryParseExact(info.LastUpdate, "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture, DateTimeStyles.None, out lastUpdate);
GUIPropertyManager.SetProperty("#lastupdate", lastUpdate.ToShortDateString());
//
GUIPropertyManager.SetProperty("#movieid", info.ID.ToString());
if (info.ID == -1 || item.IsFolder)
{
if (info.IsEmpty)
{
GUIPropertyManager.SetProperty("#hideinfo", "true");
if (item.Label == "..") // No id for GoToPreviousFolder item
{
GUIPropertyManager.SetProperty("#movieid", "-1");
}
}
else
{
GUIPropertyManager.SetProperty("#hideinfo", "false");
}
if (info.RunTime <= 0)
{
GUIPropertyManager.SetProperty("#runtime", string.Empty);
}
else
{
GUIPropertyManager.SetProperty("#runtime", info.RunTime +
" " +
GUILocalizeStrings.Get(2998) +
" (" + Util.Utils.SecondsToHMString(info.RunTime * 60) + ")");
}
if (info.RunTime <= 0)
{
GUIPropertyManager.SetProperty("#runtimeMins", string.Empty);
}
else
{
int runtimeMins = info.RunTime * 60;
GUIPropertyManager.SetProperty("#runtimeMins", runtimeMins.ToString());
}
if (info.Duration <= 0)
{
GUIPropertyManager.SetProperty("#videoruntime", string.Empty);
}
else
{
GUIPropertyManager.SetProperty("#videoruntime", Util.Utils.SecondsToHMSString(info.Duration));
}
}
else
{
GUIPropertyManager.SetProperty("#hideinfo", "false");
if (info.RunTime <= 0)
{
GUIPropertyManager.SetProperty("#runtime", string.Empty);
}
else
{
GUIPropertyManager.SetProperty("#runtime", info.RunTime +
" " +
GUILocalizeStrings.Get(2998) +
" (" + Util.Utils.SecondsToHMString(info.RunTime * 60) + ")");
}
if (info.Duration <= 0)
{
GUIPropertyManager.SetProperty("#videoruntime", string.Empty);
}
else
{
GUIPropertyManager.SetProperty("#videoruntime", Util.Utils.SecondsToHMSString(info.Duration));
}
}
// Watched property
string strValue = "no";
if (info.Watched > 0)
{
strValue = "yes";
}
GUIPropertyManager.SetProperty("#iswatched", strValue);
if (!item.IsFolder && !VirtualDirectories.Instance.Movies.IsRootShare(info.VideoFileName))
{
// Watched percent property
GUIPropertyManager.SetProperty("#watchedpercent", info.WatchedPercent.ToString());
// Watched count
GUIPropertyManager.SetProperty("#watchedcount", info.WatchedCount.ToString());
}
else
{
if (!string.IsNullOrEmpty(info.SingleUserGroup) || !string.IsNullOrEmpty(info.SingleMovieCollection))
{
// Watched percent property
GUIPropertyManager.SetProperty("#watchedpercent", info.WatchedPercent.ToString());
// Watched count
GUIPropertyManager.SetProperty("#watchedcount", "0");
}
else
{
GUIPropertyManager.SetProperty("#watchedpercent", "0");
// Watched count
GUIPropertyManager.SetProperty("#watchedcount", "-1");
}
}
string hasSubtitles = "false";
string videoMediaSource = string.Empty;
if (info.MediaInfo.HasSubtitles)
{
hasSubtitles = "true";
}
GUIPropertyManager.SetProperty("#VideoMediaSource", videoMediaSource);
GUIPropertyManager.SetProperty("#VideoCodec", Util.Utils.MakeFileName(info.MediaInfo.VideoCodec));
GUIPropertyManager.SetProperty("#VideoResolution", info.MediaInfo.VideoResolution);
GUIPropertyManager.SetProperty("#AudioCodec", Util.Utils.MakeFileName(info.MediaInfo.AudioCodec));
GUIPropertyManager.SetProperty("#AudioChannels", info.MediaInfo.AudioChannels);
GUIPropertyManager.SetProperty("#HasSubtitles", hasSubtitles);
GUIPropertyManager.SetProperty("#AspectRatio", info.MediaInfo.AspectRatio);
GUIPropertyManager.SetProperty("#myvideosuserfanart", info.UserFanart);
}
catch (Exception ex)
{
Log.Error("IMDBMovie Set movie properties error: {0}", ex.Message);
}
}