def get_image_list(self, media_id):
     data = get_json(self.url % (media_id, self.api_key))
     image_list = []
     # Get fanart
     try:
         for item in data['backdrops']:
             info = {}
             info['url'] = self.imageurl + 'original' + item[
                 'file_path']  # Original image url
             info['preview'] = self.imageurl + 'w300' + item[
                 'file_path']  # Create a preview url for later use
             info['id'] = item['file_path'].lstrip('/').replace(
                 '.jpg', '')  # Strip filename to get an ID
             info['type'] = ['fanart',
                             'extrafanart']  # Set standard to 'fanart'
             info['height'] = item['height']
             info['width'] = item['width']
             #info['aspect_ratio'] = item['aspect_ratio']                    # Who knows when we may need it
             # Convert the 'None' value to default 'n/a'
             if item['iso_639_1']:
                 info['language'] = item['iso_639_1']
             else:
                 info['language'] = 'n/a'
             info[
                 'rating'] = 'n/a'  # Rating may be integrated at later time
             # Create Gui string to display
             info[
                 'generalinfo'] = 'Language: %s  |  Rating: %s  |  Size: %sx%s   ' % (
                     info['language'], info['rating'], info['width'],
                     info['height'])
             if info:
                 image_list.append(info)
     except Exception, e:
         log(str(e), xbmc.LOGNOTICE)
def _search_movie(medianame, year=''):
    medianame = normalize(medianame)
    log('TMDB API search criteria: Title['
        '%s'
        '] | Year['
        '%s'
        ']' % (medianame, year))
    illegal_char = ' -<>:"/\|?*%'
    for char in illegal_char:
        medianame = medianame.replace(char,
                                      '+').replace('++',
                                                   '+').replace('+++', '+')
    api_key = '4be68d7eab1fbd1b6fd8a3b80a65a95e'
    json_url = 'http://api.themoviedb.org/3/search/movie?query=%s+%s&api_key=%s' % (
        medianame, year, api_key)
    tmdb_id = ''
    log('TMDB API search:   %s ' % json_url)
    try:
        data = get_json(json_url)
        for item in data['results']:
            if item['id']:
                tmdb_id = item['id']
                break
    except Exception, e:
        log(str(e), xbmc.LOGERROR)
 def get_image_list(self, media_id):
     data = get_json(self.url %(media_id, self.api_key))
     image_list = []
     # Get fanart
     try:
         for item in data['backdrops']:
             info = {}
             info['url'] = self.imageurl + 'original' + item['file_path']    # Original image url
             info['preview'] = self.imageurl + 'w300' + item['file_path']    # Create a preview url for later use
             info['id'] = item['file_path'].lstrip('/').replace('.jpg', '')  # Strip filename to get an ID
             info['type'] = ['fanart','extrafanart']                         # Set standard to 'fanart'
             info['height'] = item['height']
             info['width'] = item['width']
             #info['aspect_ratio'] = item['aspect_ratio']                    # Who knows when we may need it
             # Convert the 'None' value to default 'n/a'
             if item['iso_639_1']:
                 info['language'] = item['iso_639_1']
             else:
                 info['language'] = 'n/a'
             info['rating'] = 'n/a'                                          # Rating may be integrated at later time
             # Create Gui string to display
             info['generalinfo'] = 'Language: %s  |  Rating: %s  |  Size: %sx%s   ' %(info['language'], info['rating'], info['width'],info['height'])
             if info:
                 image_list.append(info)
     except Exception, e:
         log( str( e ), xbmc.LOGNOTICE )
def _search_movie(medianame,year=''):
    medianame = normalize(medianame)
    log('TMDB API search criteria: Title[''%s''] | Year[''%s'']' % (medianame,year) )
    illegal_char = ' -<>:"/\|?*%'
    for char in illegal_char:
        medianame = medianame.replace( char , '+' ).replace( '++', '+' ).replace( '+++', '+' )
    api_key = '4be68d7eab1fbd1b6fd8a3b80a65a95e'
    json_url = 'http://api.themoviedb.org/3/search/movie?query=%s+%s&api_key=%s' %( medianame, year, api_key )
    tmdb_id = ''
    log('TMDB API search:   %s ' % json_url)
    try:
        data = get_json(json_url)
        for item in data['results']:
            if item['id']:
                tmdb_id = item['id']
                break
    except Exception, e:
        log( str( e ), xbmc.LOGERROR )
    def get_image_list(self, media_id):
        data = get_json(self.url %(media_id, self.api_key))
        image_list = []
        # Get fanart
        try:
            for item in data['backdrops']:
                info = {}
                info['url'] = self.imageurl + 'original' + item['file_path']    # Original image url
                info['preview'] = self.imageurl + 'w300' + item['file_path']    # Create a preview url for later use
                info['id'] = item['file_path'].lstrip('/').replace('.jpg', '')  # Strip filename to get an ID
                info['type'] = ['fanart','extrafanart']                         # Set standard to 'fanart'
                info['height'] = item['height']
                info['width'] = item['width']
                #info['aspect_ratio'] = item['aspect_ratio']                    # Who knows when we may need it

                # Convert the 'None' value to default 'n/a'
                if item['iso_639_1']:
                    info['language'] = item['iso_639_1']
                else:
                    info['language'] = 'n/a'

                # find image ratings
                if int(item['vote_count']) >= 1:
                    info['rating'] = float( "%.1f" % float( item['vote_average']) ) #output string with one decimal
                    info['votes'] = item['vote_count']
                else:
                    info['rating'] = 'n/a'
                    info['votes'] = 'n/a'

                # Create Gui string to display
                info['generalinfo'] = '%s: %s  |  %s: %s  |  %s: %s  |  %s: %sx%s  |  ' %( __localize__(32141), info['language'], __localize__(32142), info['rating'], __localize__(32143), info['votes'], __localize__(32145), info['width'], info['height'])

                if info:
                    image_list.append(info)
        except Exception, e:
            log( 'Problem report: %s' %str( e ), xbmc.LOGNOTICE )