public void SetLabels(YouTubeEntry vid, string type) { if (vid == null) { ClearLabels(type, false); return; } if (vid == label_last_entry && type == label_last_type) { return; } ClearLabels(type, false); label_last_entry = vid; label_last_type = type; try { if (vid.Duration != null && vid.Duration.Seconds != null) { int sec = int.Parse(vid.Duration.Seconds); int min = sec / 60; GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Duration", string.Format("{0}:{1:0#}", min, (sec - (min * 60)))); } LocalFileStruct fileStruct = Youtube2MP._settings.LocalFile.Get(Youtube2MP.GetVideoId(vid)); GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.IsDownloaded", fileStruct != null ? "true" : "false"); int watchcount = DatabaseProvider.InstanInstance.GetWatchCount(vid); GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.WatchCount", watchcount.ToString("0,0")); GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.IsWatched", watchcount > 0 ? "true" : "false"); GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.PublishDate", vid.Published.ToShortDateString()); if (vid.Authors != null && vid.Authors.Count > 0) { GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Autor", vid.Authors[0].Name); } if (vid.Rating != null) { GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Rating", (vid.Rating.Average * 2).ToString()); GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.RatingText", (vid.Rating.Average * 2).ToString("0.0") + "/10"); } if (vid.Statistics != null) { if (vid.Statistics.ViewCount != null) { GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.ViewCount", Youtube2MP.FormatNumber(vid.Statistics.ViewCount)); } if (vid.Statistics.FavoriteCount != null) { GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.FavoriteCount", Youtube2MP.FormatNumber(vid.Statistics.FavoriteCount)); } } GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Image", Youtube2MP.GetLocalImageFileName(GetBestUrl(vid.Media.Thumbnails))); if (vid.Media.Description != null) { GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Summary", vid.Media.Description.Value); } if (vid.YtRating != null && !string.IsNullOrEmpty(vid.YtRating.NumLikes) && !string.IsNullOrEmpty(vid.YtRating.NumDislikes)) { GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.NumLike", Youtube2MP.FormatNumber(vid.YtRating.NumLikes)); GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.NumDisLike", Youtube2MP.FormatNumber(vid.YtRating.NumDislikes)); double numlike = Convert.ToDouble(vid.YtRating.NumLikes); double numdislike = Convert.ToDouble(vid.YtRating.NumDislikes); if (numlike + numdislike > 0) { double proc = numlike / (numdislike + numlike) * 100; GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.PercentLike", proc.ToString()); } } bool ishd = vid.ExtensionElements.Any( extensionElementFactory => extensionElementFactory.XmlPrefix == "yt" && extensionElementFactory.XmlName == "hd"); GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.IsHD", ishd ? "true" : "false"); } catch (Exception ex) { Log.Error(ex); } if (vid.Title.Text.Contains("-")) { GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Title", vid.Title.Text.Split('-')[1].Trim()); if (type == "NowPlaying") { GUIPropertyManager.SetProperty("#Play.Current.Title", vid.Title.Text.Split('-')[1].Trim().Trim()); } GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Artist.Name", vid.Title.Text.Split('-')[0].Trim()); GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.FanArt", GetFanArtImage(vid.Title.Text.Split('-')[0]).Trim()); } else { GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Title", vid.Title.Text); GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Artist.Name", " "); } if (type != "Curent" || type != "Current") { ArtistManager.Instance.SetSkinProperties(vid, type, false, false); //GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Artist.Name", GetArtistName(vid)); //string imgurl = // ArtistManager.Instance.GetArtistsImgUrl(GUIPropertyManager.GetProperty("#Youtube.fm." + type + ".Artist.Name")); //string artistimg = Youtube2MP.GetLocalImageFileName(imgurl); //if (!string.IsNullOrEmpty(imgurl)) //{ // DownloadFile(imgurl, artistimg); // if (File.Exists(artistimg)) // { // GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Artist.Image", artistimg); // } //} } }