Ejemplo n.º 1
0
def auto_update():
    """update until stop manually"""
    assert login(), 'check network or the DOUBAN_USER_NAME, DOUBAN_USER_PASSWORD in config.py'
    channels = get_channel(playable=True)
    while True:
        channel = random.choice(channels)
        print datetime.datetime.now()
        print '%s\t\t%s\t\t%s' % (channel.uuid.encode('utf8'), channel.name.encode('utf8'), len(channel.music_list))
        music_list = update_music_by_channel(channel, 5)
        print '%s\t\t%s\t\t%s' % (channel.uuid.encode('utf8'), channel.name.encode('utf8'), len(channel.music_list))
Ejemplo n.º 2
0
def update_channel_num(uuid, num):
    """update channel by uuid and num"""
    num = int(num)
    print uuid, num
    channel = get_channel(uuid=uuid)[0]
    assert login(), 'check network or the DOUBAN_USER_NAME, DOUBAN_USER_PASSWORD in config.py'
    music_list = update_music_by_channel(channel, num)
    assert len(music_list) == num
    print 'update %s %s %s for %d music' % (
        channel.uuid.encode('utf8'), channel.name.encode('utf8'), len(channel.music_list), num)
Ejemplo n.º 3
0
def setup():
    """setup db & update channel & get demo music"""
    print 'setuping...'
    print 'login douban...'
    assert login(), 'check network or the DOUBAN_USER_NAME, DOUBAN_USER_PASSWORD in config.py'
    print 'update channel list'
    update_channel_list()
    print 'update demo music'
    channel = get_channel()[0]
    music_list = update_music_by_channel(channel, 1)
    assert len(music_list) == 1
    print 'add demo channel to playlist'
    update_channel(channel, playable=True)
Ejemplo n.º 4
0
def douban_spider_task():
    info = u'tasks.spider_task.douban_spider_task: start %s' % (datetime.datetime.now())
    spider_task_log.log_info(info)

    login()
    info = u'tasks.spider_task.douban_spider_task: login success %s' % (datetime.datetime.now())
    spider_task_log.log_info(info)

    channel_list = update_channel_list()
    for channel_name in channel_list:
        info = u'tasks.spider_task.douban_spider_task: updated_channel %s' % channel_name
        spider_task_log.log_info(info)

    channel_list = get_channel()
    for channel in channel_list:
        music_list = update_music_by_channel(channel, channel.update_num)
        info = u'tasks.spider_task.douban_spider_task: channel %s, updated_num %d' % (channel, len(music_list))
        print info
        spider_task_log.log_info(info)

    info = u'tasks.spider_task.douban_spider_task: end %s' % (datetime.datetime.now())
    spider_task_log.log_info(info)