Giter VIP home page Giter VIP logo

swspotify's Introduction

SwSpotify

Discord Server Test codecov PyPI Downloads

SwSpotify is a Python library to get the song and artist of the currently playing song from the Spotify application faster and without using the API. It works on Windows, Linux, macOS and even the Spotify Web Player! ๐Ÿฅณ

In order to add support for the Spotify Web Player, the SwagLyrics Chrome Extension needs to be installed. We have plans to extend this for other browsers as well.

If you're a developer using SwSpotify, you can direct your end users to install the extension to automatically make your application work with the Spotify Web Player. The source of the Chrome Extension is open sourced at https://github.com/SwagLyrics/SwagLyrics-Chrome-Extension.

The original repository was spotilib which worked just for Windows and hasn't been updated since a long while when it broke on account of Spotify updating their application.

Originally made for use in SwagLyrics for Spotify.

Installation

Requires Python3. Use pip or pip3 depending on your installation. You might want to use the --user flag on Linux to avoid using pip as root.

pip install SwSpotify

For linux you need dbus which is usually pre-installed.

Usage

Use it in your project by importing it as:

from SwSpotify import spotify

Then you can access the song and artist as:

>>> spotify.song()
'Hello'
>>> spotify.artist()
'Adele'

Since mostly song and artist are used in conjunction, there is a current() method as well.

>>> spotify.current()
('Hello', 'Adele')

This allows you to access song and artist by tuple unpacking as:

>>> song, artist = spotify.current()

A SpotifyNotRunning Exception is raised if Spotify is closed or paused. SpotifyClosed and SpotifyPaused inherit from SpotifyNotRunning, meaning that you can catch both at the same time:

try:
    title, artist = spotify.current()
except SpotifyNotRunning as e:
    print(e)
else:
    print(f"{title} - {artist}")

In case Spotify is closed or paused, that will automatically be reflected in the value of e.

For finer control you can catch SpotifyClosed and SpotifyPaused separately.

Compiling SwSpotify for Development

  • Clone the repo by git clone https://github.com/SwagLyrics/SwSpotify.git or use ssh.
  • cd into the cloned repo.
  • pip install -e . the -e flag installs it locally in editable mode.

Contributing

Sure, improvements/fixes/issues everything is welcome :)

swspotify's People

Contributors

flabbet avatar marioortizmanero avatar aadibajpai avatar dependabot-preview[bot] avatar dependabot[bot] avatar ace314159 avatar musabkilic avatar matejmecka avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.