How to use the tekore.Spotify function in tekore

To help you get started, we’ve selected a few tekore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github felix-hilden / spotipy / tests / client / full.py View on Github external
def test_specifying_pos_args_until_limit(self, app_token):
        client = Spotify(app_token, max_limits_on=True)
        s1, = client.search('piano', ('track',), None, None)
        with client.max_limits(False):
            s2, = client.search('piano', ('track',), None, None)

        assert s1.limit > s2.limit
github felix-hilden / spotipy / tests / client / full.py View on Github external
def test_specifying_limit_pos_arg_overrides_max_limits(self, app_token):
        client = Spotify(app_token, max_limits_on=True)
        s, = client.search('piano', ('track',), None, None, 1)

        assert s.limit == 1
github felix-hilden / spotipy / tests / client / base.py View on Github external
def test_token_is_given_token(self):
        token = MagicMock()
        client = Spotify(token)
        assert token is client.token
github felix-hilden / spotipy / tests / sender.py View on Github external
def test_modify_default_sender_instance(self):
        instance = MagicMock()

        from tekore import sender, Spotify
        sender.default_sender_instance = instance

        s = Spotify()
        self.assertIs(s.sender, instance)
github felix-hilden / spotipy / tests / sender.py View on Github external
def test_instance_has_precedence_over_type(self):
        instance = MagicMock()
        type_mock = MagicMock(return_value=MagicMock())

        from tekore import sender, Spotify
        sender.default_sender_type = type_mock
        sender.default_sender_instance = instance

        s = Spotify()
        self.assertIs(s.sender, instance)
github thomwiggers / onebot / onebot / plugins / spotify.py View on Github external
async def sp(self, mask, target, args):
        """
        Show currently playing track via Spotify. Needs to be authed.

            %%sp
        """
        token = await self.get_spotify_token(mask.nick)
        if not token:
            return "Log in with spotify first via setspotifyuser"
        spotify = tk.Spotify(token, asynchronous=True)
        currently_playing = await spotify.playback_currently_playing()

        if currently_playing is None or currently_playing.item is None:
            return f"{mask.nick} is not playing anything at the moment."

        playing_type = currently_playing.currently_playing_type
        if playing_type == tk.model.CurrentlyPlayingType.track:
            track = currently_playing.item
            artists = ', '.join(artist.name for artist in track.artists)
            album = track.album
            response = f"{mask.nick} is playing {artists} - “{track.name}”"
            if album.name != track.name:
                response += f" (“{album.name}”)"
            response += f" ({album.release_date[:4]})"
            response += f" ({track.uri})"
            return response
github Taiko2k / TauonMusicBox / t_modules / t_spot.py View on Github external
def connect(self):
        if self.cred is None:
            self.prep_cred()
        if self.spotify is None:
            if self.token is None:
                self.load_token()
            if self.token:
                print("Init spotify support")
                self.spotify = tk.Spotify(self.token)