Esempio n. 1
0
def douban_spider_task():
    print 'tasks.spider_task.douban_spider_task: start %s' % (datetime.datetime.now())
    login()
    print 'tasks.spider_task.douban_spider_task: login success %s' % (datetime.datetime.now())
    channels = update_channel_list()
    print 'tasks.spider_task.douban_spider_task: updated_channel %s' % (channels)
    for channel in get_channel():
        music_list = update_music_by_channel(channel, channel.update_num)
        print (u'tasks.spider_task.douban_spider_task: channel %s, updated_num %d' % (channel, len(music_list))).encode('utf8')
    print 'tasks.spider_task.douban_spider_task: end %s' % (datetime.datetime.now())
Esempio n. 2
0
def douban_spider_task():
    print 'tasks.spider_task.douban_spider_task: start %s' % (
        datetime.datetime.now())
    login()
    print 'tasks.spider_task.douban_spider_task: login success %s' % (
        datetime.datetime.now())
    channels = update_channel_list()
    print 'tasks.spider_task.douban_spider_task: updated_channel %s' % (
        channels)
    for channel in get_channel():
        music_list = update_music_by_channel(channel, channel.update_num)
        print(
            u'tasks.spider_task.douban_spider_task: channel %s, updated_num %d'
            % (channel, len(music_list))).encode('utf8')
    print 'tasks.spider_task.douban_spider_task: end %s' % (
        datetime.datetime.now())
Esempio n. 3
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))
Esempio n. 4
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)
Esempio n. 5
0
 def test_update_music_by_channel(self):
     assert login(), 'check the DOUBAN_USER_NAME, DOUBAN_USER_PASSWORD in config.py'
     assert len(update_channel_list()) > 0
     assert len(get_music()) == 0
     channel = get_channel()[0]
     music_list = update_music_by_channel(channel, 1)
     assert len(music_list) == 1
     assert len(get_music()) == 1
     channel = get_channel()[0]
     assert len(channel.music_list) == 1
Esempio n. 6
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)
Esempio n. 7
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))
Esempio n. 8
0
def setup():
    '''setup db & update channel & get demo music'''
    print 'setuping...'
    print 'setting admin'
    try:
        assert add_user(ADMIN_NAME, ADMIN_PASSWORD, 'admin'), 'admin already exist!!!this will pass'
    except:
        pass
    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)
Esempio n. 9
0
def setup():
    '''setup db & update channel & get demo music'''
    print 'setuping...'
    print 'setting admin'
    try:
        assert add_user(ADMIN_NAME, ADMIN_PASSWORD,
                        'admin'), 'admin already exist!!!this will pass'
    except:
        pass
    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)