Skip to main content

Synchronize streaming libraries easily!

Project description

<style> .logo { filter: invert(100%); } @media (prefers-color-scheme: dark) { .logo { filter: invert(0%); } } </style>

downmixer is a library to support connecting between streaming services. It can match any song, from any streaming service (or any arbitrary library of files), with the same song or as close as possible when it straight up isn't available.

It's flexible, and provides a comprehensive API that can be extended for almost any use case. Making your own **provider ** (the bridge between services and downmixer) is as easy as...

import ... from ...


# Every provider needs a separate connection object
class MyProviderConnection(Connection):
    def initialize(self) -> bool:
        # Implement your APIs here
        pass

    # [...]


class MyProvider(BaseProvider):
    def fetch_song(self, id: str) -> Song:
        # Implement your APIs here
        pass

    def fetch_album(self, id: str) -> Album:
        # Implement your APIs here
        pass

    # [...]

    def fetch_audio(self, song: SearchResult | str, path: Path) -> LocalFile:
        # Implement your APIs here
        pass

Providers inherit from a base class, which has only the basic skeleton of a downmixer Provider; the actual interface the class will have is determined by the Protocols it implements.

You can make your classes inherit all the protocols it uses, but duck typing is recommended and used by the built-in Providers.

With your own providers, you can then automate tasks easily with any other service:

import

...
from ...


async def download_song(song_id: str, output: Path):
    # Initialize Spotify connection (requires OAuth)
    spotify_conn = SpotifyConnection()
    spotify_conn.initialize()
    spotify_conn.authenticate()
    spotify = SpotifyProvider(spotify_conn)

    # Get metadata from Spotify
    song = spotify.fetch_song(song_id)

    # Initialize your custom provider
    custom_conn = MyProviderConnection()
    custom_conn.initialize()
    custom = MyProvider(custom_conn)

    # First search the song on your provider
    results = custom.search(song.title, [ResourceType.SONG])
    # Then download it! 
    local_file = custom.fetch_audio(results[0], output)

    # Convert and tag
    converted = await Converter(local_file).convert()
    tag.tag_download(converted)

    return converted


# You can run it like this:
asyncio.run(download_song("spotify:track:abc123", Path("./downloads")))

The documentation is comprehensive and has a few guides to get you started.

Installation

Install the package with:

pip install downmixer

Building

Uses uv package manager. To build from source, run:

git clone https://github.com/neufter/downmixer
cd downmixer
uv build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

downmixer-0.1.0b1.tar.gz (163.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

downmixer-0.1.0b1-py3-none-any.whl (58.7 kB view details)

Uploaded Python 3

File details

Details for the file downmixer-0.1.0b1.tar.gz.

File metadata

  • Download URL: downmixer-0.1.0b1.tar.gz
  • Upload date:
  • Size: 163.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for downmixer-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 3501dc3202fdc490256eb07ba6f2a278e531d1224fb9f2745c67e54814586f25
MD5 1bf4b98f77105145aa8dafaca60d2a2b
BLAKE2b-256 8e474984809bcb116e602106c3c62461c910a3b0c43b18cb3173c929408e7a19

See more details on using hashes here.

File details

Details for the file downmixer-0.1.0b1-py3-none-any.whl.

File metadata

File hashes

Hashes for downmixer-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 d72590b366b996af6be72d96e6b899cf09901f02fe54f9eb56c47fe65ef33766
MD5 84becd9e53297196ebb3b29289e0290b
BLAKE2b-256 bb04a2b2931b1d2dbdd20df7da2e2c67871fbddb50be6536474a5e63bd24bf0f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page