MLB Plugin - Add more condensed games *** Submit changes? ***
#1
I am trying to add more days to the condensed games list but I cannot figure out how to add the date as a string. This is the code I am working on:

Code:
def condensedGames():
        base = 'http://www.mlb.com/gdcross/components/game/mlb/'
        thumb = 'http://mlbmc-xbmc.googlecode.com/svn/icons/condensed.png'
        addGameDir(__language__(30010),base+dateStr.day[0]+'/grid.json',13,thumb)
        addGameDir(__language__(30011),base+dateStr.day[1]+'/grid.json',13,thumb)
        addGameDir(__language__(30012),base+dateStr.day[3]+'/grid.json',13,thumb)
        addGameDir(__language__(30014),'',15,'http://mlbmc-xbmc.googlecode.com/svn/icons/condensed.png')

I want to add a loop to add 3-5 more days. I was able to add 1 day by modifying the strings and adding a dateStr.day[4] but I cannot seem to add the text of the dateStr like so:

Code:
addGameDir(dateStr.day[4],base+dateStr.day[3]+'/grid.json',13,thumb)

It errors out on that. How can I make the list show the date for the day before the day before yesterday so I don't have to add several strings and do it the hard way?

(Hopefully that all makes sense)

J_K_M_A_N

Reply
#2
I think what I am looking for is some kind of str$() function to convert the date to a string. (Sorry, I have only programmed in visual basic)

J_K_M_A_N
Reply
#3
I think I figured it out (good enough for me at least). Here is the code I changed:

Code:
def condensedGames():
        sformat = "%B %d, %A"
        sformat2 = "year_%Y/month_%m/day_%d"
        sone_day = datetime.timedelta(days=1)
        sitems = [1,2,3,4,5,6,7,8,9,10]
        t1 = datetime.datetime.today()
        t1 = t1 + sone_day
        
        base = 'http://www.mlb.com/gdcross/components/game/mlb/'
        thumb = 'http://mlbmc-xbmc.googlecode.com/svn/icons/condensed.png'
    
        for si in sitems:
                t2 = t1 - (sone_day * si)
                addGameDir(t2.strftime(sformat),base+t2.strftime(sformat2)+'/grid.json',13,thumb)

        addGameDir(__language__(30014),'',15,'http://mlbmc-xbmc.googlecode.com/svn/icons/condensed.png')

I took out where it says today's games and yesterdays games and the day before yesterdays games. I instead made a loop and I can add as many days as I want in the sitems set to go back however many days. I'm sure it is not the best code and there is probably a much easier way to loop a certain number of days but...what the heck. It works.

J_K_M_A_N
Reply
#4
I made more changes and added an option in the settings to show scores for the condensed games or not. I also added an option to show 1 to 9 more days in the condensed game list. I would like to submit it to see if other people would like those changes. Any idea how I would go about doing that?

J_K_M_A_N
Reply

Logout Mark Read Team Forum Stats Members Help
MLB Plugin - Add more condensed games *** Submit changes? ***0