public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice) { if ((choice.DisplayText.StartsWith(Translate("My List Remove")) || choice.DisplayText.StartsWith(Translate("My List Add"))) && selectedCategory != null && selectedCategory is NetflixCategory) { ContextMenuExecutionResult result = new ContextMenuExecutionResult(); bool inQ = (selectedCategory as NetflixCategory).InQueue; string addRemove = inQ ? "remove" : "add"; string videoId = (selectedCategory as NetflixCategory).Url; string title = selectedCategory.Name; string data = MyGetWebData(ShaktiApi + "/" + BuildId + "/playlistop?fallbackEsn=NFCDSF-01-", postData: @"{""operation"":"""+ addRemove + @""",""videoId"":" + videoId + @",""trackId"":0,""authURL"":""" + latestAuthUrl + @"""}", contentType: "application/json"); JObject json = (JObject)JsonConvert.DeserializeObject(data); //Do something with the result json... (selectedCategory as NetflixCategory).InQueue = !inQ; result.RefreshCurrentItems = true; result.ExecutionResultMessage = title + " - OK: " + (inQ ? Translate("My List Remove") : Translate("My List Add")); return result; } return base.ExecuteContextMenuEntry(selectedCategory, selectedItem, choice); }
public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice) { if (choice.DisplayText == "Add to My List") { ContextMenuExecutionResult result = new ContextMenuExecutionResult(); //private string addRemoveMyListUrl = @"{0}/{1}/playlistop"; //private string addRemoveMyListPostData = @"{""operation"":""{0}"",""videoId"":{1},""trackId"":{2},""authURL"":""{3}""}"; string videoId; string trackId; string title; if (selectedItem == null) { videoId = (selectedCategory as RssLink).Url; trackId = selectedCategory.GetTrackId(); title = selectedCategory.Name; } else { SerializableDictionary<string, string> other = selectedItem.Other as SerializableDictionary<string, string>; videoId = other["VideoId"]; trackId = other["TrackId"]; title = selectedItem.Title; } GetWebData(string.Format(addRemoveMyListUrl, ShaktiApi, BuildId), string.Format(addRemoveMyListPostData, addMyListOperation, videoId, trackId, latestAuthUrl), cc, userAgent: UserAgent); result.RefreshCurrentItems = true; result.ExecutionResultMessage = title + " added to My List"; return result; } if (choice.DisplayText == "Remove from My List") { string videoId; string trackId; string title; if (selectedItem == null) { videoId = (selectedCategory as RssLink).Url; trackId = selectedCategory.GetTrackId(); title = selectedCategory.Name; } else { SerializableDictionary<string, string> other = selectedItem.Other as SerializableDictionary<string, string>; videoId = other["VideoId"]; trackId = other["TrackId"]; title = selectedItem.Title; } ContextMenuExecutionResult result = new ContextMenuExecutionResult(); GetWebData(string.Format(addRemoveMyListUrl, ShaktiApi, BuildId), string.Format(addRemoveMyListPostData, removeMyListOperation, videoId, trackId, latestAuthUrl), cc, userAgent: UserAgent); result.RefreshCurrentItems = true; result.ExecutionResultMessage = title + " removed from My List"; return result; } return base.ExecuteContextMenuEntry(selectedCategory, selectedItem, choice); }