Пример #1
0
        public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
        {
            ContextMenuExecutionResult result = new ContextMenuExecutionResult();

            try
            {
                if (choice.DisplayText == Translation.Instance.RelatedVideos)
                {
                    result.ResultItems = GetRelatedVideos(selectedItem, "Episode").ConvertAll <SearchResultItem>(v => v as SearchResultItem);
                }
                else if (choice.DisplayText == Translation.Instance.Recommendations)
                {
                    result.ResultItems = GetRelatedVideos(selectedItem, "More Like This").ConvertAll <SearchResultItem>(v => v as SearchResultItem);
                }
            }
            catch (Exception ex)
            {
                throw new OnlineVideosException(ex.Message);
            }

            return(result);
        }
Пример #2
0
 public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
 {
     if (selectedItem != null && ManuallyRetrieveSubtitles && choice.ParentEntry != null && choice.ParentEntry.DisplayText == _textningssprak && choice.ParentEntry.Other is string)
     {
         ContextMenuExecutionResult result = new ContextMenuExecutionResult();
         if (choice.DisplayText == _ingenTextning)
         {
             selectedItem.SubtitleText = "";
         }
         else
         {
             selectedItem.SubtitleText = GetSubtitle(JObject.Parse(choice.ParentEntry.Other as string), choice.DisplayText);
         }
         result.ExecutionResultMessage = selectedItem.Title + " - " + (string.IsNullOrEmpty(selectedItem.SubtitleText) && choice.DisplayText != _ingenTextning ? "Fel vid hämtning av textning!" : _textningssprak + ": " + choice.DisplayText);
         result.RefreshCurrentItems    = false;
         return(result);
     }
     else
     {
         return(base.ExecuteContextMenuEntry(selectedCategory, selectedItem, choice));
     }
 }
Пример #3
0
 public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
 {
     if (selectedItem != null && ManuallyRetrieveSubtitles && choice.ParentEntry != null && choice.ParentEntry.DisplayText == _textningssprak && choice.ParentEntry.Other is string)
     {
         ContextMenuExecutionResult result = new ContextMenuExecutionResult();
         if (choice.DisplayText == _ingenTextning)
         {
             selectedItem.SubtitleText = "";
         }
         else
         {
             selectedItem.SubtitleText = GetSubtitle(JObject.Parse(choice.ParentEntry.Other as string), choice.DisplayText);
         }
         result.ExecutionResultMessage = selectedItem.Title + " - " + (string.IsNullOrEmpty(selectedItem.SubtitleText) && choice.DisplayText != _ingenTextning ? "Fel vid hämtning av textning!" : _textningssprak + ": " + choice.DisplayText);
         result.RefreshCurrentItems    = false;
         return(result);
     }
     else if (selectedItem != null && EnableAOSearch && choice.ParentEntry != null && choice.ParentEntry.DisplayText == _amnesord && choice.Other is string)
     {
         ContextMenuExecutionResult result = new ContextMenuExecutionResult();
         RssLink cat = new RssLink()
         {
             Name = choice.DisplayText,
             Url  = choice.Other as string
         };
         List <SearchResultItem> results = new List <SearchResultItem>();
         foreach (VideoInfo vi in GetVideos(cat))
         {
             results.Add(vi);
         }
         result.ResultItems = results;
         return(result);
     }
     else
     {
         return(base.ExecuteContextMenuEntry(selectedCategory, selectedItem, choice));
     }
 }
Пример #4
0
 public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
 {
     if (selectedItem != null && choice.DisplayText.Contains("watchlist"))
     {
         ContextMenuExecutionResult result = new ContextMenuExecutionResult();
         string  other   = selectedItem.GetOtherAsString();
         JObject json    = (JObject)JsonConvert.DeserializeObject(other);
         bool    isSaved = json["saved"].Value <bool>();
         string  guid    = json["guid"].Value <string>();
         bool    success;
         if (isSaved)
         {
             success = UnsaveVideo(guid);
         }
         else
         {
             success = SaveVideo(guid);
         }
         result.RefreshCurrentItems    = success;
         result.ExecutionResultMessage = (success ? "OK: " : "ERROR: ") + choice.DisplayText + " (" + selectedItem.Title + ")";
         return(result);
     }
     return(base.ExecuteContextMenuEntry(selectedCategory, selectedItem, choice));
 }
Пример #5
0
        public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
        {
            ContextMenuExecutionResult result = new ContextMenuExecutionResult();

            if (choice.DisplayText == Translation.Instance.DeleteAll)
            {
                result.RefreshCurrentItems = OnlineVideoSettings.Instance.FavDB.RemoveAllFavoriteVideos(((RssLink)selectedCategory).Url);
                // we have to manually refresh the categories
                if (result.RefreshCurrentItems && selectedCategory.ParentCategory != null)
                {
                    DiscoverDynamicCategories();
                }
            }
            else if (choice.DisplayText == Translation.Instance.RemoveFromFavorites)
            {
                if (selectedCategory is FavoriteCategory)
                {
                    result.RefreshCurrentItems = OnlineVideoSettings.Instance.FavDB.RemoveFavoriteCategory(((FavoriteCategory)selectedCategory).FavoriteDbCategory);
                    if (result.RefreshCurrentItems)
                    {
                        selectedCategory.ParentCategory.SubCategories.Remove(selectedCategory);
                    }
                    return(result);
                }
                else
                {
                    result.RefreshCurrentItems = OnlineVideoSettings.Instance.FavDB.RemoveFavoriteVideo(selectedItem as FavoriteDbVideoInfo);
                }
                // we have to manually refresh the categories
                if (result.RefreshCurrentItems && selectedCategory.ParentCategory != null)
                {
                    DiscoverDynamicCategories();
                }
            }
            return(result);
        }
Пример #6
0
        public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
        {
            ContextMenuExecutionResult result = new ContextMenuExecutionResult();
            if (choice.DisplayText == GetTranslation("Unstar", "Unstar"))
            {
                JToken data = MyGetWebData((selectedItem.Other as SerializableDictionary<string, string>)["starUrl"] + "false");
                result.RefreshCurrentItems = true;
                if (data["success"] != null && (bool)data["success"])
                    result.ExecutionResultMessage = GetTranslation("Unstar", "Unstar") + ": OK";
                else
                    result.ExecutionResultMessage = GetTranslation("Unstar", "Unstar") + ": Error";
                return result;
            }

            if (choice.DisplayText == GetTranslation("Star", "Star"))
            {
                JToken data = MyGetWebData((selectedItem.Other as SerializableDictionary<string, string>)["starUrl"] + "true");
                result.ExecutionResultMessage = GetTranslation("Star", "Star");
                if (data["success"] != null && (bool)data["success"])
                {
                    result.RefreshCurrentItems = true;
                    result.ExecutionResultMessage += ": OK";
                }
                else
                    result.ExecutionResultMessage += ": Error";
                return result;
            }
            if (choice.DisplayText == selectedCategory.Name + ": " + GetTranslation("Remove from History", "Remove from History"))
            {
                JObject json = MyGetWebData(ApiUrl);
                string userId = json["user"]["userId"].Value<string>();
                json = MyGetWebData((selectedItem.Other as SerializableDictionary<string, string>)["watchedUrl"].Replace("{userId}",userId), string.Empty);
                result.ExecutionResultMessage = GetTranslation("Remove from History", "Remove from History");
                if (json["status"] != null && json["status"].Value<string>() == "ok")
                {
                    result.RefreshCurrentItems = true;
                    result.ExecutionResultMessage += ": OK";
                }
                else
                    result.ExecutionResultMessage += ": Error";
                return result;
            }
            //People search
            if (choice.DisplayText != null && choice.DisplayText is string && (string)choice.DisplayText == GetTranslation("Cast", "Cast"))
            {
                List<SearchResultItem> results = new List<SearchResultItem>();
                foreach (string actor in (selectedItem.Other as SerializableDictionary<string, string>)["actors"].Split(';'))
                {
                    results.Add(new RssLink()
                    {
                        Name = actor,
                        Url = ApiUrl + "/search?query=" + HttpUtility.UrlEncode("\"" + actor + "\"") + "&block=1&partial=1&pageNumber=1",
                        Other = _search,
                        ParentCategory = selectedCategory,
                        HasSubCategories = true,
                        SubCategories = new List<Category>()
                    });
                }
                result.ResultItems = results;
                return result;
            }
            if (choice.DisplayText != null && choice.DisplayText is string && (string)choice.DisplayText == GetTranslation("Director", "Director"))
            {
                List<SearchResultItem> results = new List<SearchResultItem>();
                foreach (string director in (selectedItem.Other as SerializableDictionary<string, string>)["directors"].Split(';'))
                {
                    results.Add(new RssLink()
                    {
                        Name = director,
                        Url = ApiUrl + "/search?query=" + HttpUtility.UrlEncode("\"" + director + "\"") + "&block=1&partial=1&pageNumber=1",
                        Other = _search,
                        ParentCategory = selectedCategory,
                        HasSubCategories = true,
                        SubCategories = new List<Category>()
                    });
                }
                result.ResultItems = results;
                return result;
            }
            return base.ExecuteContextMenuEntry(selectedCategory, selectedItem, choice);
        }
Пример #7
0
        public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
        {
            ContextMenuExecutionResult result = new ContextMenuExecutionResult();

            try
            {
                if (choice.DisplayText == Translation.Instance.AddToFavourites + " (" + Settings.Name + ")")
                {
                    addFavorite(selectedItem);
                }
                else if (choice.DisplayText == Translation.Instance.RemoveFromFavorites + " (" + Settings.Name + ")")
                {
                    removeFavorite(selectedItem);
                    result.RefreshCurrentItems = true;
                }
                else if (choice.DisplayText == Translation.Instance.RelatedVideos)
                {
                    YouTubeQuery query = new YouTubeQuery()
                    {
                        Uri = new Uri((selectedItem.Other as MyYouTubeEntry).YouTubeEntry.RelatedVideosUri.Content), NumberToRetrieve = pageSize
                    };
                    result.ResultItems = parseGData(query).ConvertAll <SearchResultItem>(v => v as SearchResultItem);
                    currentVideosTitle = Translation.Instance.RelatedVideos + " [" + selectedItem.Title + "]";
                }
                else if (choice.DisplayText.StartsWith(Translation.Instance.UploadsBy))
                {
                    string       username = selectedItem == null ? selectedCategory.Name : (selectedItem.Other as MyYouTubeEntry).YouTubeEntry.Uploader.Value;
                    YouTubeQuery query    = new YouTubeQuery(YouTubeQuery.CreateUserUri(username))
                    {
                        NumberToRetrieve = pageSize
                    };
                    result.ResultItems = parseGData(query).ConvertAll <SearchResultItem>(v => v as SearchResultItem);
                    currentVideosTitle = Translation.Instance.UploadsBy + " [" + username + "]";
                }
                else if (choice.DisplayText.StartsWith(Translation.Instance.Playlists))
                {
                    string       username = selectedItem == null ? selectedCategory.Name : (selectedItem.Other as MyYouTubeEntry).YouTubeEntry.Uploader.Value;
                    YouTubeQuery query    = new YouTubeQuery(YouTubeQuery.CreatePlaylistsUri(username))
                    {
                        NumberToRetrieve = pageSize
                    };
                    YouTubeFeed feed           = service.Query(query);
                    Category    parentCategory = new Category()
                    {
                        SubCategories = new List <Category>()
                    };
                    GetPlaylistEntriesAsCategories(parentCategory, feed);
                    result.ResultItems = parentCategory.SubCategories.ConvertAll <SearchResultItem>(v => v as SearchResultItem);
                }
                else if (choice.DisplayText == Translation.Instance.AddComment)
                {
                    addComment(selectedItem, choice.UserInputText);
                }
                else if (choice.ParentEntry != null && choice.ParentEntry.DisplayText == Translation.Instance.RateVideo)
                {
                    rateVideo(selectedItem, byte.Parse(choice.DisplayText));
                }
                else if (choice.ParentEntry != null && choice.ParentEntry.DisplayText == Translation.Instance.AddToPlaylist)
                {
                    if (choice.Other == null)
                    {
                        choice.Other = request.Insert <Playlist>(new Uri(YouTubeQuery.CreatePlaylistsUri(accountname)), new Playlist()
                        {
                            Title = choice.UserInputText
                        }).PlaylistsEntry.Content.Src.Content;
                    }
                    addToPlaylist(selectedItem, choice.Other as string);
                    // force re-discovery of dynamic subcategories for my playlists category (as either a new catgeory was added or the count changed)
                    var playlistsCategory = Settings.Categories.FirstOrDefault(c => !(c is RssLink) && c.Name == string.Format("{0}'s {1}", accountname, Translation.Instance.Playlists));
                    if (playlistsCategory != null)
                    {
                        playlistsCategory.SubCategoriesDiscovered = false;
                    }
                }
                else if (choice.DisplayText == Translation.Instance.RemoveFromPlaylist)
                {
                    removeFromPlaylist(selectedItem, choice.Other as string);
                    result.RefreshCurrentItems = true;
                    if ((selectedCategory as RssLink).EstimatedVideoCount != null)
                    {
                        (selectedCategory as RssLink).EstimatedVideoCount--;
                    }
                }
                else if (choice.DisplayText == Translation.Instance.DeletePlaylist)
                {
                    deletePlaylist((selectedCategory as RssLink).Url);
                    selectedCategory.ParentCategory.SubCategoriesDiscovered = false;
                    result.RefreshCurrentItems = true;
                }
            }
            catch (Exception ex)
            {
                throw new OnlineVideosException(ex.Message);
            }
            return(result);
        }
Пример #8
0
        public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
        {
            ContextMenuExecutionResult result = new ContextMenuExecutionResult();

            try
            {
                if (choice.DisplayText == Translation.Instance.AddToFavourites + " (" + Settings.Name + ")")
                {
                    var query = Service.PlaylistItems.Insert(
                        new Google.Apis.YouTube.v3.Data.PlaylistItem()
                    {
                        Snippet = new Google.Apis.YouTube.v3.Data.PlaylistItemSnippet()
                        {
                            Title      = selectedItem.Title,
                            PlaylistId = userFavoritesPlaylistId,
                            ResourceId = new Google.Apis.YouTube.v3.Data.ResourceId()
                            {
                                VideoId = selectedItem.VideoUrl,
                                Kind    = "youtube#video"
                            }
                        }
                    },
                        "snippet");
                    var response = query.Execute();
                    result.ExecutionResultMessage = string.Format("{0} {1}", Translation.Instance.Success, Translation.Instance.AddingToFavorites);
                }
                else if (choice.DisplayText == Translation.Instance.RemoveFromFavorites + " (" + Settings.Name + ")")
                {
                    var query    = Service.PlaylistItems.Delete((selectedItem as YouTubeVideo).PlaylistItemId);
                    var response = query.Execute();
                    result.RefreshCurrentItems = true;
                }
                else if (choice.DisplayText == Translation.Instance.RelatedVideos)
                {
                    base.HasNextPage    = false;
                    nextPageVideosQuery = null;
                    currentVideosTitle  = Translation.Instance.RelatedVideos + " [" + selectedItem.Title + "]";
                    result.ResultItems  = QuerySearchVideos(null, "videos", null, null, (selectedItem as YouTubeVideo).VideoUrl).ConvertAll <SearchResultItem>(v => v as SearchResultItem);
                }
                else if (choice.DisplayText.StartsWith(Translation.Instance.UploadsBy))
                {
                    base.HasNextPage    = false;
                    nextPageVideosQuery = null;
                    currentVideosTitle  = Translation.Instance.UploadsBy + " [" + (selectedItem as YouTubeVideo).ChannelTitle + "]";
                    result.ResultItems  = QuerySearchVideos(null, "videos", (selectedItem as YouTubeVideo).ChannelId, null, null).ConvertAll <SearchResultItem>(v => v as SearchResultItem);
                }
                else if (choice.DisplayText.StartsWith(Translation.Instance.Playlists))
                {
                    var parentCategory = new YouTubeCategory()
                    {
                        Name = Translation.Instance.Playlists + " [" + (selectedItem as YouTubeVideo).ChannelTitle + "]"
                    };
                    parentCategory.SubCategories = QueryChannelPlaylists(parentCategory, (selectedItem as YouTubeVideo).ChannelId);
                    result.ResultItems           = parentCategory.SubCategories.ConvertAll <SearchResultItem>(v => v as SearchResultItem);
                }
                else if (choice.DisplayText == Translation.Instance.RemoveFromPlaylist)
                {
                    var query    = Service.PlaylistItems.Delete((selectedItem as YouTubeVideo).PlaylistItemId);
                    var response = query.Execute();
                    result.RefreshCurrentItems = true;
                    if ((selectedCategory as YouTubeCategory).EstimatedVideoCount != null)
                    {
                        (selectedCategory as YouTubeCategory).EstimatedVideoCount--;
                    }
                }
                else if (choice.DisplayText == Translation.Instance.DeletePlaylist)
                {
                    var query    = Service.Playlists.Delete((selectedCategory as YouTubeCategory).Id);
                    var response = query.Execute();
                    selectedCategory.ParentCategory.SubCategoriesDiscovered = false;
                    result.RefreshCurrentItems = true;
                }
                else if (choice.ParentEntry != null && choice.ParentEntry.DisplayText == Translation.Instance.AddToPlaylist)
                {
                    if (choice.Other == null)
                    {
                        // create new playlist first
                        var query = Service.Playlists.Insert(
                            new Google.Apis.YouTube.v3.Data.Playlist()
                        {
                            Snippet = new Google.Apis.YouTube.v3.Data.PlaylistSnippet()
                            {
                                Title = choice.UserInputText
                            }
                        },
                            "snippet");
                        var response = query.Execute();
                        choice.Other = response.Id;
                    }
                    var queryItem = Service.PlaylistItems.Insert(
                        new Google.Apis.YouTube.v3.Data.PlaylistItem()
                    {
                        Snippet = new Google.Apis.YouTube.v3.Data.PlaylistItemSnippet()
                        {
                            Title      = selectedItem.Title,
                            PlaylistId = choice.Other as string,
                            ResourceId = new Google.Apis.YouTube.v3.Data.ResourceId()
                            {
                                VideoId = selectedItem.VideoUrl,
                                Kind    = "youtube#video"
                            }
                        }
                    },
                        "snippet");
                    var responseItem = queryItem.Execute();
                    // force re-discovery of dynamic subcategories for my playlists category (as either a new catgeory was added or the count changed)
                    var playlistsCategory = Settings.Categories.FirstOrDefault(c => (c is YouTubeCategory) && (c as YouTubeCategory).IsMine && c.Name.EndsWith(Translation.Instance.Playlists));
                    if (playlistsCategory != null)
                    {
                        playlistsCategory.SubCategoriesDiscovered = false;
                    }
                }
            }
            catch (Google.GoogleApiException apiEx)
            {
                throw new OnlineVideosException(string.Format("{0} {1}", apiEx.HttpStatusCode, apiEx.Message));
            }
            catch (Exception ex)
            {
                throw new OnlineVideosException(ex.Message);
            }
            return(result);
        }
Пример #9
0
 public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
 {
     if (selectedItem != null && ManuallyRetrieveSubtitles && choice.ParentEntry != null && choice.ParentEntry.DisplayText == _textningssprak && choice.ParentEntry.Other is string)
     {
         ContextMenuExecutionResult result = new ContextMenuExecutionResult();
         if (choice.DisplayText == _ingenTextning)
             selectedItem.SubtitleText = "";
         else
             selectedItem.SubtitleText = GetSubtitle(JObject.Parse(choice.ParentEntry.Other as string), choice.DisplayText);
         result.ExecutionResultMessage = selectedItem.Title + " - " + (string.IsNullOrEmpty(selectedItem.SubtitleText) && choice.DisplayText != _ingenTextning ? "Fel vid hämtning av textning!" : _textningssprak + ": " + choice.DisplayText);
         result.RefreshCurrentItems = false;
         return result;
     }
     else
         return base.ExecuteContextMenuEntry(selectedCategory, selectedItem, choice);
 }
Пример #10
0
 public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
 {
     ContextMenuExecutionResult result = new ContextMenuExecutionResult();
     try
     {
         if (choice.DisplayText == Translation.Instance.AddToFavourites + " (" + Settings.Name + ")")
         {
             addFavorite(selectedItem);
         }
         else if (choice.DisplayText == Translation.Instance.RemoveFromFavorites + " (" + Settings.Name + ")")
         {
             removeFavorite(selectedItem);
             result.RefreshCurrentItems = true;
         }
         else if (choice.DisplayText == Translation.Instance.RelatedVideos)
         {
             YouTubeQuery query = new YouTubeQuery() { Uri = new Uri((selectedItem.Other as MyYouTubeEntry).YouTubeEntry.RelatedVideosUri.Content), NumberToRetrieve = pageSize };
             result.ResultItems = parseGData(query).ConvertAll<SearchResultItem>(v => v as SearchResultItem);
             currentVideosTitle = Translation.Instance.RelatedVideos + " [" + selectedItem.Title + "]";
         }
         else if (choice.DisplayText.StartsWith(Translation.Instance.UploadsBy))
         {
             string username = selectedItem == null ? selectedCategory.Name : (selectedItem.Other as MyYouTubeEntry).YouTubeEntry.Uploader.Value;
             YouTubeQuery query = new YouTubeQuery(YouTubeQuery.CreateUserUri(username)) { NumberToRetrieve = pageSize };
             result.ResultItems = parseGData(query).ConvertAll<SearchResultItem>(v => v as SearchResultItem);
             currentVideosTitle = Translation.Instance.UploadsBy + " [" + username + "]";
         }
         else if (choice.DisplayText.StartsWith(Translation.Instance.Playlists))
         {
             string username = selectedItem == null ? selectedCategory.Name : (selectedItem.Other as MyYouTubeEntry).YouTubeEntry.Uploader.Value;
             YouTubeQuery query = new YouTubeQuery(YouTubeQuery.CreatePlaylistsUri(username)) { NumberToRetrieve = pageSize };
             YouTubeFeed feed = service.Query(query);
             Category parentCategory = new Category() { SubCategories = new List<Category>() };
             GetPlaylistEntriesAsCategories(parentCategory, feed);
             result.ResultItems = parentCategory.SubCategories.ConvertAll<SearchResultItem>(v => v as SearchResultItem);
         }
         else if (choice.DisplayText == Translation.Instance.AddComment)
         {
             addComment(selectedItem, choice.UserInputText);
         }
         else if (choice.ParentEntry != null && choice.ParentEntry.DisplayText == Translation.Instance.RateVideo)
         {
             rateVideo(selectedItem, byte.Parse(choice.DisplayText));
         }
         else if (choice.ParentEntry != null && choice.ParentEntry.DisplayText == Translation.Instance.AddToPlaylist)
         {
             if (choice.Other == null)
             {
                 choice.Other = request.Insert<Playlist>(new Uri(YouTubeQuery.CreatePlaylistsUri(accountname)), new Playlist() { Title = choice.UserInputText }).PlaylistsEntry.Content.Src.Content;
             }
             addToPlaylist(selectedItem, choice.Other as string);
             // force re-discovery of dynamic subcategories for my playlists category (as either a new catgeory was added or the count changed)
             var playlistsCategory = Settings.Categories.FirstOrDefault(c => !(c is RssLink) && c.Name == string.Format("{0}'s {1}", accountname, Translation.Instance.Playlists));
             if (playlistsCategory != null) playlistsCategory.SubCategoriesDiscovered = false;
         }
         else if (choice.DisplayText == Translation.Instance.RemoveFromPlaylist)
         {
             removeFromPlaylist(selectedItem, choice.Other as string);
             result.RefreshCurrentItems = true;
             if ((selectedCategory as RssLink).EstimatedVideoCount != null) (selectedCategory as RssLink).EstimatedVideoCount--;
         }
         else if (choice.DisplayText == Translation.Instance.DeletePlaylist)
         {
             deletePlaylist((selectedCategory as RssLink).Url);
             selectedCategory.ParentCategory.SubCategoriesDiscovered = false;
             result.RefreshCurrentItems = true;
         }
     }
     catch (Exception ex)
     {
         throw new OnlineVideosException(ex.Message);
     }
     return result;
 }
Пример #11
0
 public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
 {
     if (selectedItem != null && ManuallyRetrieveSubtitles && choice.ParentEntry != null && choice.ParentEntry.DisplayText == _textningssprak && choice.ParentEntry.Other is string)
     {
         ContextMenuExecutionResult result = new ContextMenuExecutionResult();
         if (choice.DisplayText == _ingenTextning)
             selectedItem.SubtitleText = "";
         else
             selectedItem.SubtitleText = GetSubtitle(JObject.Parse(choice.ParentEntry.Other as string), choice.DisplayText);
         result.ExecutionResultMessage = selectedItem.Title + " - " + (string.IsNullOrEmpty(selectedItem.SubtitleText) && choice.DisplayText != _ingenTextning ? "Fel vid hämtning av textning!" : _textningssprak + ": " + choice.DisplayText);
         result.RefreshCurrentItems = false;
         return result;
     }
     else if (selectedItem != null && EnableAOSearch && choice.ParentEntry != null && choice.ParentEntry.DisplayText == _amnesord && choice.Other is string)
     {
         ContextMenuExecutionResult result = new ContextMenuExecutionResult();
         RssLink cat = new RssLink()
         {
             Name = choice.DisplayText,
             Url = choice.Other as string
         };
         List<SearchResultItem> results = new List<SearchResultItem>();
         foreach (VideoInfo vi in GetVideos(cat))
             results.Add(vi);
         result.ResultItems = results;
         return result;
     }
     else
         return base.ExecuteContextMenuEntry(selectedCategory, selectedItem, choice);
 }
 public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
 {
     if (selectedItem != null && choice.DisplayText.Contains("watchlist"))
     {
         ContextMenuExecutionResult result = new ContextMenuExecutionResult();
         string other = selectedItem.GetOtherAsString();
         JObject json = (JObject)JsonConvert.DeserializeObject(other);
         bool isSaved = json["saved"].Value<bool>();
         string guid = json["guid"].Value<string>();
         bool success;
         if (isSaved)
         {
             success = UnsaveVideo(guid);
         }
         else
         {
             success = SaveVideo(guid);
         }
         result.RefreshCurrentItems = success;
         result.ExecutionResultMessage = (success ? "OK: " : "ERROR: ") + choice.DisplayText + " (" + selectedItem.Title + ")";
         return result;
     }
     return base.ExecuteContextMenuEntry(selectedCategory, selectedItem, choice);
 }
Пример #13
0
 public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
 {
     ContextMenuExecutionResult result = new ContextMenuExecutionResult();
     if (choice.DisplayText == Translation.Instance.DeleteAll)
     {
         result.RefreshCurrentItems = OnlineVideoSettings.Instance.FavDB.RemoveAllFavoriteVideos(((RssLink)selectedCategory).Url);
         // we have to manually refresh the categories
         if (result.RefreshCurrentItems && selectedCategory.ParentCategory != null) DiscoverDynamicCategories();
     }
     else if (choice.DisplayText == Translation.Instance.RemoveFromFavorites)
     {
         if (selectedCategory is FavoriteCategory)
         {
             result.RefreshCurrentItems = OnlineVideoSettings.Instance.FavDB.RemoveFavoriteCategory(((FavoriteCategory)selectedCategory).FavoriteDbCategory);
             if (result.RefreshCurrentItems) selectedCategory.ParentCategory.SubCategories.Remove(selectedCategory);
             return result;
         }
         else
         {
             result.RefreshCurrentItems = OnlineVideoSettings.Instance.FavDB.RemoveFavoriteVideo(selectedItem as FavoriteDbVideoInfo);
         }
         // we have to manually refresh the categories
         if (result.RefreshCurrentItems && selectedCategory.ParentCategory != null) DiscoverDynamicCategories();
     }
     return result;
 }
Пример #14
0
 public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
 {
     ContextMenuExecutionResult result = new ContextMenuExecutionResult();
     try
     {
         if (choice.DisplayText == Translation.Instance.RelatedVideos)
         {
             result.ResultItems = GetRelatedVideos(selectedItem, "Episode").ConvertAll<SearchResultItem>(v => v as SearchResultItem);
         }
         else if (choice.DisplayText == Translation.Instance.Recommendations)
         {
             result.ResultItems = GetRelatedVideos(selectedItem, "More Like This").ConvertAll<SearchResultItem>(v => v as SearchResultItem);
         }
     }
     catch (Exception ex)
     {
         throw new OnlineVideosException(ex.Message);
     }
     
     return result;
 }