Last active
October 25, 2019 12:59
-
-
Save henryjfry/c22d25036de75fc1f133df14542cf006 to your computer and use it in GitHub Desktop.
~/.kodi/addons/script.extendedinfo/resources/lib/DialogVideoList.py => Genre Multi Select
This file contains hidden or 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
########################### | |
#change play behaviour for movies for greater speed + show_busy/hide_busy | |
########################### | |
@ch.action('contextmenu', 500) | |
def context_menu(self): | |
if self.listitem.getProperty('dbid') and self.listitem.getProperty('dbid') != 0: | |
dbid = self.listitem.getProperty('dbid') | |
else: | |
dbid = 0 | |
item_id = self.listitem.getProperty('id') | |
if self.type == 'tv': | |
imdb_id = Utils.fetch(TheMovieDB.get_tvshow_ids(item_id), 'imdb_id') | |
tvdb_id = Utils.fetch(TheMovieDB.get_tvshow_ids(item_id), 'tvdb_id') | |
else: | |
imdb_id = TheMovieDB.get_imdb_id_from_movie_id(item_id) | |
if self.listitem.getProperty('TVShowTitle'): | |
listitems = ['Play first episode'] | |
else: | |
listitems = ['Play'] | |
if self.listitem.getProperty('dbid'): | |
listitems += ['Remove from library'] | |
else: | |
listitems += ['Add to library'] | |
listitems += ['Trailer'] | |
selection = xbmcgui.Dialog().select(heading='Choose option', list=listitems) | |
if selection == 0: | |
if self.listitem.getProperty('TVShowTitle'): | |
url = 'plugin://plugin.video.openmeta/tv/play/%s/1/1' % tvdb_id | |
PLAYER.play_from_button(url, listitem=None, window=self, dbid=0) | |
else: | |
Utils.show_busy() | |
url = 'plugin://plugin.video.openmeta/movies/play/tmdb/%s' % item_id | |
Utils.hide_busy() | |
xbmc.executebuiltin('RunPlugin(%s)' % url) | |
# if self.listitem.getProperty('dbid'): | |
# dbid = self.listitem.getProperty('dbid') | |
# url = '' | |
# else: | |
# dbid = 0 | |
# url = 'plugin://plugin.video.openmeta/movies/play/tmdb/%s' % item_id | |
# PLAYER.play_from_button(url, listitem=None, window=self, type='movieid', dbid=dbid) | |
if selection == 1: | |
if self.listitem.getProperty('TVShowTitle'): | |
TVLibrary = xbmcaddon.Addon('plugin.video.openmeta').getSetting('tv_library_folder') | |
if self.listitem.getProperty('dbid'): | |
Utils.get_kodi_json(method='VideoLibrary.RemoveTVShow', params='{"tvshowid": %s}' % dbid) | |
if os.path.exists(xbmc.translatePath('%s%s/' % (TVLibrary, tvdb_id))): | |
shutil.rmtree(xbmc.translatePath('%s%s/' % (TVLibrary, tvdb_id))) | |
Utils.after_add(type='tv') | |
Utils.notify(header='[B]%s[/B]' % self.listitem.getProperty('TVShowTitle'), message='Removed from library', icon=self.listitem.getProperty('poster'), time=5000, sound=False) | |
xbmc.sleep(250) | |
self.update(force_update=True) | |
self.getControl(500).selectItem(self.position) | |
else: | |
if xbmcgui.Dialog().yesno('OpenInfo', 'Add [B]%s[/B] to library?' % self.listitem.getProperty('TVShowTitle')): | |
xbmc.executebuiltin('RunPlugin(plugin://plugin.video.openmeta/tv/add_to_library/%s)' % tvdb_id) | |
Utils.after_add(type='tv') | |
Utils.notify(header='[B]%s[/B] added to library' % self.listitem.getProperty('TVShowTitle'), message='Exit & re-enter to refresh', icon=self.listitem.getProperty('poster'), time=5000, sound=False) | |
else: | |
if self.listitem.getProperty('dbid'): | |
if xbmcgui.Dialog().yesno('OpenInfo', 'Remove [B]%s[/B] from library?' % self.listitem.getProperty('title')): | |
Utils.get_kodi_json(method='VideoLibrary.RemoveMovie', params='{"movieid": %s}' % dbid) | |
MovieLibrary = xbmcaddon.Addon('plugin.video.openmeta').getSetting('movies_library_folder') | |
if os.path.exists(xbmc.translatePath('%s%s/' % (MovieLibrary, imdb_id))): | |
shutil.rmtree(xbmc.translatePath('%s%s/' % (MovieLibrary, imdb_id))) | |
Utils.after_add(type='movie') | |
Utils.notify(header='[B]%s[/B]' % self.listitem.getProperty('title'), message='Removed from library', icon=self.listitem.getProperty('poster'), time=5000, sound=False) | |
xbmc.sleep(250) | |
self.update(force_update=True) | |
self.getControl(500).selectItem(self.position) | |
else: | |
if xbmcgui.Dialog().yesno('OpenInfo', 'Add [B]%s[/B] to library?' % self.listitem.getProperty('title')): | |
xbmc.executebuiltin('RunPlugin(plugin://plugin.video.openmeta/movies/add_to_library/tmdb/%s)' % item_id) | |
Utils.after_add(type='movie') | |
Utils.notify(header='[B]%s[/B] added to library' % self.listitem.getProperty('title'), message='Exit & re-enter to refresh', icon=self.listitem.getProperty('poster'), time=5000, sound=False) | |
if selection == 2: | |
if self.listitem.getProperty('TVShowTitle'): | |
url = 'plugin://script.extendedinfo?info=playtvtrailer&&id=' + item_id | |
else: | |
url = 'plugin://script.extendedinfo?info=playtrailer&&id=' + item_id | |
PLAYER.play(url, listitem=None, window=self) | |
def set_genre_filter(self): | |
response = TheMovieDB.get_tmdb_data('genre/%s/list?language=%s&' % (self.type, xbmcaddon.Addon().getSetting('LanguageID')), 10) | |
id_list = [item['id'] for item in response['genres']] | |
label_list = [item['name'] for item in response['genres']] | |
# index = xbmcgui.Dialog().select(heading='Choose genre', list=label_list) | |
index = xbmcgui.Dialog().multiselect('Choose genre', label_list) | |
if index == -1: | |
return None | |
try: | |
self.add_filter('with_genres', str(id_list[index]), 'Genres', label_list[index]) | |
except: | |
for x in index: | |
self.add_filter('with_genres', str(id_list[x]), 'Genres', label_list[x]) | |
# xbmc.log(str(label_list[x])+'===>OPENINFO', level=xbmc.LOGNOTICE) | |
pass | |
self.mode = 'filter' | |
self.page = 1 | |
self.update() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment