Beispiel #1
0
def list_season(show_id, season_id):
    xbmc.log("List Season")
    season = []
    thumb = xbmc.getInfoLabel('ListItem.Thumb')
    fanart = xbmc.getInfoLabel('ListItem.Art(fanart)')
    xbmc.log("season_id")
    xbmc.log(str(season_id))
    dir_show = get_appended_path(dir_shows, str(show_id))
    file_db = get_appended_path(dir_show, 'episodes.json')
    xbmc.log('filedb')
    xbmc.log(str(file_db))
    data = read_json(file_db)
    for episode in data:
        xbmc.log("Sonarr list_season(episodes): " + str(episode))
        if str(episode['seasonNumber']) != season_id:
            continue
        else:
            episodeid = str(episode['id'])
            name = get_episode_name(episode)
            episode = episode['episodeNumber']
            season.append({
                'name': name,
                'mode': 'addEpisode',
                'show': str(show_id),
                'episode': episode,
                'episodeid': episodeid,
                'type': 'dir',
                'images': {
                    'thumb': thumb,
                    'fanart': fanart
                }
            })
    add_entries(season)
    xbmcplugin.endOfDirectory(pluginhandle)
Beispiel #2
0
def list_season(show_id, season_id):
    xbmc.log("List Season")
    season = []
    #show_id = xbmc.getInfoLabel("ListItem.tvshowtitle")
    #season_id = xbmc.getInfoLabel("ListItem.season")
    xbmc.log("season_id")
    xbmc.log(str(season_id))
    dir_show = get_appended_path(dir_shows, str(show_id))
    file_db = get_appended_path(dir_show, 'episodes.json')
    xbmc.log('filedb')
    xbmc.log(str(file_db))
    data = read_json(file_db)
    for episode in data:
        if str(episode['seasonNumber']) != season_id:
            continue
        else:
            xbmc.log("FOUND")
            name = get_episode_name(episode)
            episode = episode['episodeNumber']
            season.append({
                'name': name,
                'mode': 'end',
                'show': str(show_id),
                'episode': episode,
                'type': 'dir'
            })
    add_entries(season)
    xbmcplugin.endOfDirectory(pluginhandle)
Beispiel #3
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)
Beispiel #4
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)
Beispiel #5
0
def list_seasons(show_id):
    seasons = []
    #show_id = xbmc.getInfoLabel("ListItem.tvshowtitle")
    dir_show = get_appended_path(dir_shows, str(show_id))
    file_db = get_appended_path(dir_show, 'seasons.json')
    data = read_json(file_db)
    #show_id = xbmc.getInfoLabel("ListItem.tvshowtitle")
    for season in data:
        name = get_season_name(season)
        season_id = season['seasonNumber']
        seasons.append({
            'name': name,
            'url': str(show_id),
            'season': str(season_id),
            'mode': 'getSeason',
            'type': 'dir'
        })
    add_entries(seasons)
    xbmcplugin.endOfDirectory(pluginhandle)
Beispiel #6
0
def list_seasons(show_id):
    seasons = []
    thumb = xbmc.getInfoLabel('ListItem.Art(thumb)')
    fanart = xbmc.getInfoLabel('ListItem.Art(fanart)')
    dir_show = get_appended_path(dir_shows, str(show_id))
    file_db = get_appended_path(dir_show, 'seasons.json')
    data = read_json(file_db)
    for season in data:
        xbmc.log("Sonarr list_seasons: " + str(season))
        name = get_season_name(season)
        season_id = season['seasonNumber']
        seasons.append({
            'name': name,
            'url': str(show_id),
            'season': str(season_id),
            'mode': 'getSeason',
            'type': 'dir',
            'images': {
                'thumb': thumb,
                'fanart': fanart
            }
        })
    add_entries(seasons)
    xbmcplugin.endOfDirectory(pluginhandle)
Beispiel #7
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)
Beispiel #8
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)