Exemple #1
0
def refreshepisodes(showid, data=None, showdatapath=None):
    if data == None:
        data = tvdb.getshow(showid)
        
    if showdatapath == None:
        showdatapath = loadshow(showid)
        
    if not "seasons" in showdatapath:
        showdatapath["seasons"] = {}
    
    for episode in data.findChildren("episode"):
        season = episode.seasonnumber.string 
        ep = episode.episodenumber.string
        date = 0
        etstr = episode.firstaired.string
        if etstr is not None:
            etime = time.strptime(etstr, "%Y-%m-%d")
            date = int(time.mktime(etime))
            
        newvalues = {
                     "name":episode.episodename.string,
                     "airdate":date,
                     "tvdbid":episode.id.string
                     }
        
        if not season in showdatapath["seasons"]:
            showdatapath["seasons"][season] = {"episodes":{}}
        
        if not ep in showdatapath["seasons"][season]["episodes"]:
            showdatapath["seasons"][season]["episodes"][ep] = newvalues
            showdatapath["seasons"][season]["episodes"][ep]["status"] = "skipped"
        else:
            showdatapath["seasons"][season]["episodes"][ep].update(newvalues)
Exemple #2
0
def refreshshow(showid, path=None):
    global shows
    
    if showid not in shows:
        shows[showid] = {}
    data = tvdb.getshow(showid)
    
    shows[showid]["name"] = data.data.series.seriesname.string
    shows[showid]["network"] = data.data.series.network.string
    shows[showid]["status"] = data.data.series.status.string
    shows[showid]["imdb_id"] = data.data.series.imdb_id.string
    
    if path is not None:
        shows[showid]["path"] = path
    
    print str.format("Refreshed data for '{name}' status: {status}",**shows[showid])
    
    showdatapath = loadshow(showid)  
    
    refreshepisodes(showid, data, showdatapath)
    
    saveshow(showid, showdatapath)