Ejemplo n.º 1
0
 def search(self):
     '''search for albums that match a given string'''
     if 'artistid' in self.options:
         all_items = self.kodidb.albums(self.options['artistid'])
     else:
         all_items = self.kodidb.albums()
     return process_method_on_list(self.process_album, all_items)
Ejemplo n.º 2
0
    def mainlisting(self):
        '''display the listing for the provided action and mediatype'''
        media_type = self.options['mediatype']
        action = self.options['action']
        # set widget content type
        xbmcplugin.setContent(ADDON_HANDLE, media_type)

        # call the correct method to get the content from json
        all_items = []
        log_msg(
            'MEDIATYPE: %s - ACTION: %s -- querying kodi api to get items' %
            (media_type, action))

        # dynamically import and load the correct module, class and function
        try:
            media_module = __import__(media_type)
            media_class = getattr(media_module,
                                  media_type.capitalize())(self.addon,
                                                           self.options)
            all_items = getattr(media_class, action)()
            del media_class
        except AttributeError:
            log_exception(__name__, 'Incorrect action or type called')
        except Exception as exc:
            log_exception(__name__, exc)

        matched_items = matchHeard(self.options['mediatitle'], all_items)
        if len(matched_items) > 0:
            # prepare listitems
            matched_items = process_method_on_list(prepare_listitem,
                                                   matched_items)

            # fill that listing...
            xbmcplugin.addSortMethod(int(sys.argv[1]),
                                     xbmcplugin.SORT_METHOD_UNSORTED)
            matched_items = process_method_on_list(create_listitem,
                                                   matched_items)
            xbmcplugin.addDirectoryItems(ADDON_HANDLE, matched_items,
                                         len(matched_items))

        # end directory listing
        xbmcplugin.endOfDirectory(handle=ADDON_HANDLE)
Ejemplo n.º 3
0
 def map_artwork(self, data, mapping_table):
     '''helper method to map the artwork received from fanart.tv to kodi known formats'''
     artwork = {}
     if data:
         for artwork_mapping in mapping_table:
             fanarttv_type = artwork_mapping[0]
             kodi_type = artwork_mapping[1]
             images = []
             if fanarttv_type in data and kodi_type not in artwork:
                 # artworktype is found in the data, now do some magic to select the best one
                 images = process_method_on_list(self.score_image,
                                                 data[fanarttv_type])
             # set all images in list and select the item with highest score
             if images:
                 images = sorted(images,
                                 key=itemgetter("score"),
                                 reverse=True)
                 images = [item["url"] for item in images]
                 artwork[kodi_type + "s"] = images
                 artwork[kodi_type] = images[0]
     return artwork
Ejemplo n.º 4
0
 def tvseason(self, tvshow_id, season):
     '''get season artwork - banner+landscape only as the seasonposters lacks a season in the json response'''
     data = self.get_data("tv/%s" % tvshow_id)
     artwork = {}
     mapping_table = [("seasonthumb", "landscape"),
                      ("seasonbanner", "banner")]
     for artwork_mapping in mapping_table:
         fanarttv_type = artwork_mapping[0]
         kodi_type = artwork_mapping[1]
         if fanarttv_type in data:
             images = [
                 item for item in data[fanarttv_type]
                 if item["season"] == str(season)
             ]
             images = process_method_on_list(self.score_image,
                                             data[fanarttv_type])
             if images:
                 images = sorted(images,
                                 key=itemgetter("score"),
                                 reverse=True)
                 images = [item["url"] for item in images]
                 artwork[kodi_type + "s"] = images
                 artwork[kodi_type] = images[0]
     return artwork
Ejemplo n.º 5
0
 def search(self):
     '''search for movies that match a given string'''
     all_items = self.kodidb.movies()
     return process_method_on_list(self.process_movie, all_items)
Ejemplo n.º 6
0
 def search(self):
     '''search for tvshows that match a given string'''
     all_items = self.kodidb.tvshows()
     return process_method_on_list(self.process_tvshow, all_items)
Ejemplo n.º 7
0
 def search(self):
     '''search for addons that match a given string'''
     all_items = self.kodidb.addons()
     return process_method_on_list(self.process_addon, all_items)
Ejemplo n.º 8
0
 def search(self):
     '''search for musicplaylists that match a given string'''
     all_items = self.kodidb.musicplaylists()
     return process_method_on_list(self.process_musicplaylist, all_items)