Exemple #1
0
def auth_prompt():
    print '===Authentication==='
    if webbrowser.open_new( common.ws('/auth') ):
        print 'A login dialog has been opened in your default web browser to achieve the authentication process.\nCheck that you are logged on Last.fm with your target account, switch between accounts if not.'
        print 'If you can\'t see this dialog, go on ' + common.ws('/auth')
    else:
        print 'Please go to ' + common.ws('/auth') + ' to achieve the authentication process.'
    
    print 'You will be redirected on a confirmation dialog showing a code, please enter your authentication code below.'
    return raw_input('Authentication code: ')
Exemple #2
0
def auth_prompt():
    print '===Authentication==='
    if webbrowser.open_new(common.ws('/auth')):
        print 'A login dialog has been opened in your default web browser to achieve the authentication process.\nCheck that you are logged on Last.fm with your target account, switch between accounts if not.'
        print 'If you can\'t see this dialog, go on ' + common.ws('/auth')
    else:
        print 'Please go to ' + common.ws(
            '/auth') + ' to achieve the authentication process.'

    print 'You will be redirected on a confirmation dialog showing a code, please enter your authentication code below.'
    return raw_input('Authentication code: ')
Exemple #3
0
def token_check(servicetoken):
    print 'Checking code validity...',
    check_r = common.jsonfetch(common.ws('/check/') + servicetoken, use_cache=False)
    if check_r.has_key('Error'):
        print check_r['Message']
        return False
    else:
        username = check_r['Username']
        print 'Valid for ' + username
        return True
Exemple #4
0
def token_check(servicetoken):
    print 'Checking code validity...',
    check_r = common.jsonfetch(common.ws('/check/') + servicetoken,
                               use_cache=False)
    if check_r.has_key('Error'):
        print check_r['Message']
        return False
    else:
        username = check_r['Username']
        print 'Valid for ' + username
        return True
Exemple #5
0
    servicetoken = auth_prompt()
    if token_check(servicetoken):
        f = open('token', 'w')
        f.write(servicetoken)
        f.close()
    else:
        servicetoken = None

if servicetoken == None:
    exit()

print '\nSelect an operation:\n1 : Scrobble tracks.\n2 : Remove previous scrobbled tracks (revert).\n3 : Unregister service token.'
mode = raw_input('[1,2,3]> ')

if mode == '3':
    print common.jsonfetch(common.ws('/unregister/' + servicetoken), use_cache=False)['Message']
    rmfile('token')
    exit()
if mode == '2':
    remove = True
    print 'Reverting operation selected.'
if mode == '1':
    remove = False
    print 'Scrobbling operation selected.'

print 'Parsing scrobbles file...'
f = open('scrobbles.json', 'r')
scrobbles = json.loads(f.read())
f.close()

#Dropping unicode scrobbles
Exemple #6
0
    servicetoken = auth_prompt()
    if token_check(servicetoken):
        f = open('token', 'w')
        f.write(servicetoken)
        f.close()
    else:
        servicetoken = None

if servicetoken == None:
    exit()

print '\nSelect an operation:\n1 : Scrobble tracks.\n2 : Remove previous scrobbled tracks (revert).\n3 : Unregister service token.'
mode = raw_input('[1,2,3]> ')

if mode == '3':
    print common.jsonfetch(common.ws('/unregister/' + servicetoken),
                           use_cache=False)['Message']
    rmfile('token')
    exit()
if mode == '2':
    remove = True
    print 'Reverting operation selected.'
if mode == '1':
    remove = False
    print 'Scrobbling operation selected.'

print 'Parsing scrobbles file...'
f = open('scrobbles.json', 'r')
scrobbles = json.loads(f.read())
f.close()