示例#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)
示例#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)
示例#3
0
def get_episodes(name):
    xbmc.log(log_msg + '!GET EPISODES!', loglevel)
    xbmc.log(log_msg + 'from addon: ' +name, loglevel)
    items = []
    addon_id = name
    db_file = dir_db + addon_id + '.json'
    db_all = read_json(db_file)
    name = get_addon_name(addon_id)
    if addon_id != 'unknown' and addon_id != 'Kodi-DB':
        name = TRANSLATE(30011)+' '+name
        thumb = get_addon_icon(addon_id)
        fanart = get_addon_fanart(addon_id)
        items.append({"name": name, "url": addon_id, "mode": "to_addon", "type": "dir",
                      "images": {"thumb": thumb, "fanart": fanart},
                      "infolabels": {"title": name}})
    for i in reversed(db_all):
        try:
            name = i['name']
            url = i['link']
            plot = i['plot']
            iconimage = i['icon']
            duration = i['dura']
            date_added = i['date']
            fanart = ''
            if enab_fana:
                if 'fana' in i:
                    fanart = i['fana']
            cm = get_cm(["episodes"])
            items.append({
                "name": name, "url": url, "mode": "play", "type": "video",
                "infolabels": {"title": name, "duration": duration, "writer": addon_id, "plot": plot, "aired": date_added},
                "images": {"thumb": iconimage, "fanart": fanart}, "cm": cm})
        except KeyError:
            pass
    add_entries(items)
示例#4
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)
示例#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)
示例#6
0
def get_episodes(name):
    xbmc.log(log_msg + '!GET EPISODES!', loglevel)
    xbmc.log(log_msg + 'from addon: ' +name, loglevel)
    addon_id = name
    db_file = userdataDir + addon_id + '.json'
    db_all = read_json(db_file)
    name = get_addon_name(addon_id)
    addDir(get_translation(30011)+' '+name, addon_id, 'to_addon', '')
    for i in db_all:
        try:
            name = db_all[i]['name']
            url = db_all[i]['link']
            plot = db_all[i]['plot']
            iconimage = db_all[i]['icon']
            duration = db_all[i]['dura']
            date_added = db_all[i]['date']
            fanart = ''
            if enab_fana:
                if 'fana' in db_all[i]:
                    fanart = db_all[i]['fana']
            addLink(name, url, 'play', iconimage, plot, duration, addon_id, date_added, fanart)
        except KeyError:
            pass
示例#7
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)
示例#8
0
def get_games_from_db():
    data = read_json(file_games)
    return data
示例#9
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)