forked from anxdpanic/plugin.video.youtube
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidate all Search Items into one module kodion.items.search_items
- Loading branch information
Showing
5 changed files
with
132 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 0 additions & 62 deletions
62
resources/lib/youtube_plugin/kodion/items/new_search_item.py
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
resources/lib/youtube_plugin/kodion/items/search_history_item.py
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
131 changes: 131 additions & 0 deletions
131
resources/lib/youtube_plugin/kodion/items/search_items.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Copyright (C) 2014-2016 bromix (plugin.video.youtube) | ||
Copyright (C) 2016-2018 plugin.video.youtube | ||
SPDX-License-Identifier: GPL-2.0-only | ||
See LICENSES/GPL-2.0-only for more information. | ||
""" | ||
|
||
from __future__ import absolute_import, division, unicode_literals | ||
|
||
from . import menu_items | ||
from .directory_item import DirectoryItem | ||
from ..constants import PATHS | ||
|
||
|
||
class SearchItem(DirectoryItem): | ||
def __init__(self, | ||
context, | ||
name=None, | ||
image=None, | ||
fanart=None, | ||
location=False): | ||
if not name: | ||
name = context.localize('search') | ||
|
||
if image is None: | ||
image = '{media}/search.png' | ||
|
||
params = {} | ||
if location: | ||
params['location'] = location | ||
|
||
super(SearchItem, self).__init__(name, | ||
context.create_uri( | ||
(PATHS.SEARCH, 'list',), | ||
params=params, | ||
), | ||
image=image, | ||
fanart=fanart) | ||
|
||
context_menu = [ | ||
menu_items.search_clear(context), | ||
menu_items.separator(), | ||
menu_items.goto_quick_search(context, params), | ||
menu_items.goto_quick_search(context, params, incognito=True) | ||
] | ||
self.add_context_menu(context_menu) | ||
|
||
|
||
class SearchHistoryItem(DirectoryItem): | ||
def __init__(self, context, query, image=None, fanart=None, location=False): | ||
if image is None: | ||
image = '{media}/search.png' | ||
|
||
if isinstance(query, dict): | ||
params = query | ||
query = params['q'] | ||
else: | ||
params = {'q': query} | ||
if location: | ||
params['location'] = location | ||
|
||
super(SearchHistoryItem, self).__init__(query, | ||
context.create_uri( | ||
(PATHS.SEARCH, 'query',), | ||
params=params, | ||
), | ||
image=image, | ||
fanart=fanart) | ||
|
||
context_menu = [ | ||
menu_items.search_remove(context, query), | ||
menu_items.search_rename(context, query), | ||
menu_items.search_clear(context), | ||
menu_items.separator(), | ||
menu_items.search_sort_by(context, params, 'relevance'), | ||
menu_items.search_sort_by(context, params, 'date'), | ||
menu_items.search_sort_by(context, params, 'viewCount'), | ||
menu_items.search_sort_by(context, params, 'rating'), | ||
menu_items.search_sort_by(context, params, 'title'), | ||
] | ||
self.add_context_menu(context_menu) | ||
|
||
|
||
class NewSearchItem(DirectoryItem): | ||
def __init__(self, | ||
context, | ||
name=None, | ||
image=None, | ||
fanart=None, | ||
incognito=False, | ||
channel_id='', | ||
addon_id='', | ||
location=False): | ||
if not name: | ||
name = context.get_ui().bold(context.localize('search.new')) | ||
|
||
if image is None: | ||
image = '{media}/new_search.png' | ||
|
||
params = {} | ||
if addon_id: | ||
params['addon_id'] = addon_id | ||
if incognito: | ||
params['incognito'] = incognito | ||
if channel_id: | ||
params['channel_id'] = channel_id | ||
if location: | ||
params['location'] = location | ||
|
||
super(NewSearchItem, self).__init__(name, | ||
context.create_uri( | ||
(PATHS.SEARCH, 'input',), | ||
params=params, | ||
), | ||
image=image, | ||
fanart=fanart) | ||
|
||
if context.is_plugin_path(context.get_uri(), (PATHS.SEARCH, 'list',)): | ||
context_menu = [ | ||
menu_items.search_clear(context), | ||
menu_items.separator(), | ||
menu_items.goto_quick_search(context, params, not incognito) | ||
] | ||
else: | ||
context_menu = [ | ||
menu_items.goto_quick_search(context, params, not incognito) | ||
] | ||
self.add_context_menu(context_menu) |