Beispiel #1
0
def info_status():
    return jsonify({
        'active': bool(lib.SpPlaybackIsActiveDevice()),
        'playing': bool(lib.SpPlaybackIsPlaying()),
        'shuffle': bool(lib.SpPlaybackIsShuffled()),
        'repeat': bool(lib.SpPlaybackIsRepeated()),
        'logged_in': bool(lib.SpConnectionIsLoggedIn())
    })
Beispiel #2
0
    def __init__(self):
        self.credentials = dict({
            'username': None,
            'password': None,
            'api_key': None,
            'api_secret': None
        })

        if args.lastfm_credentials:
            with open(args.lastfm_credentials) as f:
                self.credentials.update({
                    k: v.encode('utf-8') if isinstance(v, unicode) else v
                    for (k, v) in json.loads(f.read()).iteritems()
                })

        if args.lastfm_username:
            self.credentials['username'] = args.lastfm_username
        if args.lastfm_password:
            self.credentials['password'] = args.lastfm_password
        if args.lastfm_api_key:
            self.credentials['api_key'] = args.lastfm_api_key
        if args.lastfm_api_secret:
            self.credentials['api_secret'] = args.lastfm_api_secret

        if not (self.credentials['username'] and self.credentials['password']
                and self.credentials['api_key']
                and self.credentials['api_secret']):
            self.on = False
            print 'Last.fm: incomplete credentials, not launched'
            return

        self.on = True
        self.lastfm_network = pylast.LastFMNetwork(
            api_key=self.credentials['api_key'],
            api_secret=self.credentials['api_secret'],
            username=self.credentials['username'],
            password_hash=pylast.md5(self.credentials['password']))
        self.metadata = None
        self.timestamp = None
        self.playing = bool(lib.SpPlaybackIsPlaying())
        self.play_cumul = 0
        self.play_beg = time.time()
Beispiel #3
0
    def __init__(self):
        self.credentials = dict({
            "username": None,
            "password": None,
            "api_key": None,
            "api_secret": None
        })

        try:
            with open(args.lastfm_credentials) as f:
                self.credentials.update(json.loads(f.read()).items())
        except IOError:
            pass

        if args.lastfm_username:
            self.credentials["username"] = args.lastfm_username
        if args.lastfm_password:
            self.credentials["password"] = args.lastfm_password
        if args.lastfm_api_key:
            self.credentials["api_key"] = args.lastfm_api_key
        if args.lastfm_api_secret:
            self.credentials["api_secret"] = args.lastfm_api_secret

        if not (self.credentials["username"] and self.credentials["password"]
                and self.credentials["api_key"]
                and self.credentials["api_secret"]):
            self.on = False
            print("Last.fm: incomplete credentials, not launched")
            return

        self.on = True
        self.lastfm_network = pylast.LastFMNetwork(
            api_key=self.credentials["api_key"],
            api_secret=self.credentials["api_secret"],
            username=self.credentials["username"],
            password_hash=pylast.md5(self.credentials["password"]),
        )
        self.metadata = None
        self.timestamp = None
        self.playing = bool(lib.SpPlaybackIsPlaying())
        self.play_cumul = 0
        self.play_beg = time.time()