コード例 #1
0
 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:
             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)
コード例 #2
0
 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')
     elif self.type == "episode":
         tvdb_id = self.listitem.getProperty("tvdb_id")
         imdb_id = self.listitem.getProperty("imdb_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']
     if self.type == "tv":
         listitems += ['Rate TV show']
     elif self.type == "episode":
         listitems += ['Library: all tvshows']
     else:
         listitems += ['Rate movie']
     listitems += [LANG(14076)]
     if self.type == "tv" or self.type == "episode":
         if self.listitem.getProperty("dbid"):
             listitems = [LANG(208)]
     if not self.type == "tv" or self.type == "episode":
         listitems += ['Add to list']
     if self.mode == "list":
         listitems += ['Remove from list']
     if self.type == "movie" and xbmc.getCondVisibility(
             "system.hasaddon(plugin.video.couchpotato_manager)"):
         listitems += ['Add to CouchPotato']
     if xbmc.getCondVisibility(
             "system.hasaddon(plugin.video.trakt_list_manager)"):
         listitems += ['Visit : [COLOR skyblue]%s[/COLOR]']
     if self.type == "tv" and xbmc.getCondVisibility(
             "system.hasaddon(plugin.video.sickrage)"):
         listitems += ['Add to SickBeard']
     if self.trakt_account and (self.type == 'movie'
                                or self.type == 'tv'):
         listitems += ['Trakt Manager']
     selection = xbmcgui.Dialog().select(heading='Choose option',
                                         list=listitems)
     if selection != -1 and listitems[selection] == 'Trakt Manager':
         name = self.listitem.getProperty("title")
         if self.type == "movie":
             content = "movie"
         else:
             content = "tvshow"
         xbmc.executebuiltin(
             "RunScript(script.extendedinfo,info=traktManager,name=%s,tmdb=%s,content=%s)"
             % (name, item_id, content))
     elif selection == 0:
         if self.listitem.getProperty('TVShowTitle'):
             url = 'plugin://plugin.video.chappaai/tv/play/%s/1/1' % tvdb_id
             PLAYER.play_from_button(url,
                                     listitem=None,
                                     window=self,
                                     dbid=0)
         else:
             if self.listitem.getProperty('dbid'):
                 dbid = self.listitem.getProperty('dbid')
                 url = ''
             else:
                 dbid = 0
                 url = 'plugin://plugin.video.chappaai/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.chappaai').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(
                         'Wraith', 'Add [B]%s[/B] to library?' %
                         self.listitem.getProperty('TVShowTitle')):
                     xbmc.executebuiltin(
                         'RunPlugin(plugin://plugin.video.chappaai/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(
                         'Wraith', '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.chappaai').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(
                         'Wraith', 'Add [B]%s[/B] to library?' %
                         self.listitem.getProperty('title')):
                     xbmc.executebuiltin(
                         'RunPlugin(plugin://plugin.video.chappaai/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)