Exemplo n.º 1
0
    def test_request(self):
        logging.getLogger("supysonic.lastfm").addHandler(logging.NullHandler())
        lastfm = LastFm({"api_key": "key", "secret": "secret"}, None)

        rv = lastfm._LastFm__api_request(False,
                                         method="dummy",
                                         accents=u"àéèùö")
        self.assertIsInstance(rv, dict)
Exemplo n.º 2
0
def lastfm_unreg(uid):
	if uid == 'me':
		lfm = LastFm(UserManager.get(store, session.get('userid'))[1], app.logger)
	else:
		if not UserManager.get(store, session.get('userid'))[1].admin or not UserManager.get(store, uid)[0] is UserManager.SUCCESS:
			return redirect(url_for('index'))
		lfm = LastFm(UserManager.get(store, uid)[1], app.logger)
	lfm.unlink_account()
	store.commit()
	flash('Unliked LastFM account')
	return redirect(url_for('user_profile', uid = uid))
Exemplo n.º 3
0
def lastfm_reg(uid, user):
    token = request.args.get('token')
    if token in ('', None):
        flash('Missing LastFM auth token')
        return redirect(url_for('user_profile', uid = uid))

    lfm = LastFm(app.config['LASTFM'], user, app.logger)
    status, error = lfm.link_account(token)
    store.commit()
    flash(error if not status else 'Successfully linked LastFM account')

    return redirect(url_for('user_profile', uid = uid))
Exemplo n.º 4
0
def lastfm_reg():
	token = request.args.get('token')
	if token in ('', None):
		flash('Missing LastFM auth token')
		return redirect(url_for('user_profile'))

	lfm = LastFm(UserManager.get(store, session.get('userid'))[1], app.logger)
	status, error = lfm.link_account(token)
	store.commit()
	flash(error if not status else 'Successfully linked LastFM account')

	return redirect(url_for('user_profile'))
Exemplo n.º 5
0
def lastfm_reg(uid):
	token = request.args.get('token')
	if token in ('', None):
		flash('Missing LastFM auth token')
		return redirect(url_for('user_profile', uid = uid))

	if uid == 'me':
		lfm = LastFm(UserManager.get(store, session.get('userid'))[1], app.logger)
	else:
		if not UserManager.get(store, session.get('userid'))[1].admin or not UserManager.get(store, uid)[0] is UserManager.SUCCESS:
			return redirect(url_for('index'))
		lfm = LastFm(UserManager.get(store, uid)[1], app.logger)
	status, error = lfm.link_account(token)
	store.commit()
	flash(error if not status else 'Successfully linked LastFM account')

	return redirect(url_for('user_profile', uid = uid))
Exemplo n.º 6
0
def scrobble():
	status, res = get_entity(request, Track)
	if not status:
		return res

	t, submission = map(request.values.get, [ 'time', 'submission' ])

	if t:
		try:
			t = int(t) / 1000
		except:
			return request.error_formatter(0, 'Invalid time value')
	else:
		t = int(time.time())

	lfm = LastFm(request.user, app.logger)

	if submission in (None, '', True, 'true', 'True', 1, '1'):
		lfm.scrobble(res, t)
	else:
		lfm.now_playing(res)

	return request.formatter({})
Exemplo n.º 7
0
def scrobble():
    status, res = get_entity(request, Track)
    if not status:
        return res

    t, submission = map(request.args.get, ['time', 'submission'])

    if t:
        try:
            t = int(t) / 1000
        except:
            return request.error_formatter(0, 'Invalid time value')
    else:
        t = int(time.time())

    lfm = LastFm(request.user, app.logger)

    if submission in (None, '', True, 'true', 'True', 1, '1'):
        lfm.scrobble(res, t)
    else:
        lfm.now_playing(res)

    return request.formatter({})
Exemplo n.º 8
0
def lastfm_unreg(uid, user):
    lfm = LastFm(app.config['LASTFM'], user, app.logger)
    lfm.unlink_account()
    store.commit()
    flash('Unlinked LastFM account')
    return redirect(url_for('user_profile', uid = uid))
Exemplo n.º 9
0
def lastfm_unreg():
	lfm = LastFm(UserManager.get(store, session.get('userid'))[1], app.logger)
	lfm.unlink_account()
	store.commit()
	flash('Unliked LastFM account')
	return redirect(url_for('user_profile'))
Exemplo n.º 10
0
def lastfm_unreg(uid, user):
    lfm = LastFm(user, app.logger)
    lfm.unlink_account()
    store.commit()
    flash('Unlinked LastFM account')
    return redirect(url_for('user_profile', uid = uid))