Exemplo n.º 1
0
def list_shows(data):
    shows = []
    for show in data:
        name = show['title'].encode('utf-8')
        thumb = host_url + show['images'][2]['url'] + '&apikey={}'.format(
            api_key)
        #banner = host_url + show['images'][1]['url'] + '&apikey={}'.format(api_key)
        fanart = host_url + show['images'][0]['url'] + '&apikey={}'.format(
            api_key)
        show_id = show['id']
        seasons = show['seasons']
        dir_show = get_appended_path(dir_shows, str(show_id))
        file = 'seasons.json'
        file_path = get_appended_path(dir_show, file)
        write_json(file_path, seasons)
        shows.append({
            'name': name,
            'url': str(show_id),
            'mode': 'getShow',
            'type': 'dir',
            'images': {
                'thumb': thumb,
                'fanart': fanart
            }
        })
    add_entries(shows)
    xbmcplugin.endOfDirectory(pluginhandle)
Exemplo n.º 2
0
def get_queue():
    data = snr.get_queue()
    shows = []
    for show in data:
        xbmc.log("Sonarr get_queue: Show: " + str(show))
        showname = show['series']['title']
        xbmc.log("Sonarr get_queue: Timeleft: " + str(show['timeleft']))
        name = showname + " S" + str(
            show['episode']['seasonNumber']) + "E" + str(
                show['episode']['episodeNumber'])
        try:
            thumb = show['series']['images'][1]['url']
        except IndexError:
            thumb = ''
        try:
            fanart = show['series']['images'][2]['url']
        except IndexError:
            fanart = ''
            xbmc.log("Sonarr get_queue: Error setting Artwork...")
        totalsize = show['size'] * 1e-9
        perc = 100 - (100 * float(show['sizeleft']) / float(show['size']))
        name += '      [COLOR FF3576F9]%s%%[/COLOR] ' % round(perc, 1)
        name += ' [COLOR FF3576F9]of  %sGB[/COLOR] ' % round(totalsize, 2)
        #        name += ' [COLOR FF3576F9]Time Remaining: %s[/COLOR]' % str(show['timeleft'])
        show_id = show['id']
        seasons = 'na'
        dir_show = get_appended_path(dir_shows, str(show_id))
        file = 'seasons.json'
        file_path = get_appended_path(dir_show, file)
        write_json(file_path, seasons)
        if 'overview' in show:
            plot = show['overview']
        else:
            plot = ''

        shows.append({
            'name': name,
            'url': str(show_id),
            'mode': 'getRoot',
            'type': 'dir',
            'images': {
                'thumb': thumb,
                'fanart': fanart
            },
            'plot': plot
        })
    if shows == []:
        shows.append({
            'name': 'No Current Downloads',
            'url': '',
            'mode': 'getRoot',
            'type': 'dir'
        })
    add_entries(shows)
    xbmcplugin.endOfDirectory(pluginhandle)
Exemplo n.º 3
0
def delete_from_db(name, db_file):
    xbmc.log(log_msg + '!DELETE FROM DB!', loglevel)
    xbmc.log(log_msg + 'File: '+db_file, loglevel)
    db_data = read_json(db_file)
    for i in db_data:
        if name == db_data[i]['name'].encode("utf-8"):
            del db_data[i]
            write_json(db_file, db_data)
            break       #no need to keep searching
    else:
        xbmc.log(log_msg + 'Episode not found in data', loglevel)
    if auto_rem_db:
        if not db_data:
            xbmc.log(log_msg + 'File empty, delete it', loglevel)
            xbmcvfs.delete(db_file)
Exemplo n.º 4
0
def update_games():
    xbmc.log('UPDATE GAMES')
    check_dir_userdata()
    games = []
    data = xbl.get_user_xone_games(xuid)
    for game in data['titles']:
        titleId = str(game['titleId'])
        game = get_game_details(titleId)
        games.append(game)
    #optional get xbox 360 games
    '''
    if gm_xb360:
        data = xbl.get_user_x360_games(xuid)
        for game in data['titles']:
            titleId = str(game['titleId'])
            #game = get_game_details(titleId)
            games.append(game)
    '''
    write_json(file_games, games)
Exemplo n.º 5
0
def get_all_episodes(show_id):
    data = snr.get_episodes_by_series_id(show_id)
    dir_show = get_appended_path(dir_shows, str(show_id))
    file_db = get_appended_path(dir_show, 'episodes.json')
    write_json(file_db, data)
Exemplo n.º 6
0
def list_shows(data):
    shows = []
    for show in data:
        xbmc.log("Sonarr list_shows: " + str(show), xbmc.LOGINFO)
        name = show['title']
        try:
            thumb = host_url + show['images'][1]['url'] + '&apikey={}'.format(
                api_key)
        except IndexError:
            thumb = ''
        try:
            fanart = host_url + show['images'][2]['url'] + '&apikey={}'.format(
                api_key)
        except IndexError:
            fanart = ''
            xbmc.log("Sonarr list_shows: Error setting Artwork...")
        xbmc.log("THUMBB " + str(thumb))
        show_id = show['id']
        seasons = show['seasons']
        dir_show = get_appended_path(dir_shows, str(show_id))
        file = 'seasons.json'
        file_path = get_appended_path(dir_show, file)
        write_json(file_path, seasons)

        totaleps = 0
        eps = 0
        for season in show['seasons']:
            if season['monitored'] == True:
                totaleps += int(season['statistics']['totalEpisodeCount'])
                eps += int(season['statistics']['episodeCount'])

        # Get percentage
        if vw_perc:
            if totaleps > 0:
                perc = int(eps / totaleps * 100)
            else:
                perc = 100
            if perc == 100:
                perc = '[COLOR FF3576F9]{}%[/COLOR]'.format(perc)  # blue
            elif 50 <= perc < 100:
                perc = '[COLOR FFFA7544]{}%[/COLOR]'.format(perc)  # yellow
            elif perc < 50:
                perc = '[COLOR FFF7290A]{}%[/COLOR]'.format(perc)  # red
            name += ' ' + str(perc)
        # get episodes counter
        if vw_total:
            epi_count = str(eps)
            epi_total_count = str(totaleps)
            name += ' {}/{} '.format(epi_count, epi_total_count)

        if 'overview' in show:
            plot = show['overview']
        else:
            plot = ''

        name += ' [' + show['status'] + ']'
        shows.append({
            'name': name,
            'url': str(show_id),
            'mode': 'getShow',
            'type': 'dir',
            'images': {
                'thumb': thumb,
                'fanart': fanart
            },
            'plot': str(plot)
        })
    add_entries(shows)
    xbmcplugin.endOfDirectory(pluginhandle)
Exemplo n.º 7
0
def add_to_db(new_data, db_file):
    xbmc.log(log_msg + '!ADD TO DB!', loglevel)
    xbmc.log(log_msg + 'File: ' + db_file, loglevel)
    db_data = read_json(db_file)
    db_data.update(new_data)
    write_json(db_file, db_data)