コード例 #1
0
ファイル: main.py プロジェクト: octatone/Top-Poster
def weekDaily():
    """tasks for weekdays"""
    # POST NEW TOP SONG
    periods = ["month", "week"]
    tops = []

    print "Logging in to reddit and retriving top rr song for for the week and month"
    rio = RedditIO()

    for period in periods:
        top = rio.getTopSong(period)
        tops.append(top)
        if top:
            print "Top song retrieved for", period, top
            # check for old post
            last = Last()
            if last.isStored(top):
                print "Not a new song.  Done."
            else:
                print "Is a new song!"
                # post to reddit
                print "Posting to reddit ..."
                try:
                    rio.postToReddit("music", "top for the %s on radio reddit: %s" % (period, top.title), top.url)
                    print "All done here!"
                except:
                    e = sys.exc_info()[1]
                    fatalError("Error: %s" % e)
                print "Posting to twitter ..."
                twit = TwitterIO()
                twit.postToTwitter("New top song: %s %s" % (top.title, top.url))
        else:
            fatalError("No top song found, time to die.")
    # store tops
    last.store(tops)
コード例 #2
0
def weekDaily():
    """tasks for weekdays"""
    # POST NEW TOP SONG
    periods = ['month','week']
    tops = []

    print 'Logging in to reddit and retriving top rr song for for the week and month'
    rio = RedditIO()

    for period in periods:
        top = rio.getTopSong(period)
        tops.append(top)
        if top:
            print 'Top song retrieved for', period, top
            # check for old post
            last = Last()
            if last.isStored(top):
                print 'Not a new song.  Done.'
            else:
                print 'Is a new song!'
                # post to reddit
                print 'Posting to reddit ...'
                try:
                    rio.postToReddit('music','top for the %s on radio reddit: %s' % (period, top.title), top.url)
                    print 'All done here!'
                except:
                    e = sys.exc_info()[1]
                    fatalError("Error: %s" % e)
                print 'Posting to twitter ...'
                twit = TwitterIO()
                twit.postToTwitter('New top song: %s %s' % (top.title, top.url))
        else:
            fatalError('No top song found, time to die.')
    # store tops
    last.store(tops)