Skip to main content

Python Soundcloud API

Project description

Soundcloud-lib

This is a Soundcloud API library that doesn't require a client ID to function. It's basic, it can really only fetch tracks and playlists, but doesn't require the user to go through the soundcloud app approval process.

Version

Now works again! Soundcloud please stop changing how your site works :)

Why

I once applied for API access and was approved. I used this access for months until it was revoked for some reason and all my emails and new applications were ignored. I decided to create a library that allows me to do Soundcloud API stuff without an approved application.

Features

  • Supports asyncio
  • Does not require a client ID
  • Fetches and writes mp3 metadata (Album artist, title, artwork)
  • Can fetch entire playlists of tracks

Installation

This library is installable as a pip package.

pip install soundcloud-lib

How

This library uses programming and algorithms to find a client ID that can be used to access the Soundcloud API.

Saving an mp3 to a file.

This will write the ID3 tags for album artist, track title AND will embed the album artwork into the mp3.

from sclib import SoundcloudAPI, Track, Playlist

api = SoundcloudAPI()  # never pass a Soundcloud client ID that did not come from this library

track = api.resolve('https://soundcloud.com/itsmeneedle/sunday-morning')

assert type(track) is Track

filename = f'./{track.artist} - {track.title}.mp3'

with open(filename, 'wb+') as fp:
    track.write_mp3_to(fp)

Fetch a playlist

from sclib import SoundcloudAPI, Track, Playlist

api = SoundcloudAPI()
playlist = api.resolve('https://soundcloud.com/playlist_url')

assert type(playlist) is Playlist

for track in playlist.tracks:
    filename = f'./{track.artist} - {track.title}.mp3'
    with open(filename, 'wb+') as fp:
        track.write_mp3_to(fp)

Asyncio Support

from sclib.asyncio import SoundcloudAPI, Track

api = SoundcloudAPI()
track = await api.resolve('https://soundcloud.com/user/track')

assert type(track) is Track

filename = f'{track.artist} - {track.title}.mp3'

with open(filename, 'wb+') as fp:
    await track.write_mp3_to(fp)

Fetch a playlist

from sclib.asyncio import SoundcloudAPI, Track, Playlist

api = SoundcloudAPI()
playlist = await api.resolve('https://soundcloud.com/playlist_url')

assert type(playlist) is Playlist

for track in playlist.tracks:
    filename = f'./{track.artist} - {track.title}.mp3'
    with open(filename, 'wb+') as fp:
        await track.write_mp3_to(fp)

Write Album Name or Track Number

from sclib import SoundcloudAPI, Track, Playlist

playlist = SoundcloudAPI().resolve("https://soundcloud.com/user/sets/playlist_name")

for track_number, track in enumerate(playlist):
    track.track_no = track_number
    track.album = playlist.title
    with open(f"{track.artist} - {track.title}.mp3", "wb+") as file:
        track.write_mp3_to(file)

Known Bugs

This library cannot download tracks that are not marked "Downloadable".

"Downloadable" tracks have an MP3 representation while non-"Downloadable" ones only have HLS representations. I would like to add HLS assembly to this library in the future.

Bugs or Features

Please report any and all bugs using the issues tab.

Feel free to request new features too.

Contributing

Sure, submit a pull request.

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

soundcloud-lib-0.5.4.tar.gz (7.0 kB view details)

Uploaded Source

File details

Details for the file soundcloud-lib-0.5.4.tar.gz.

File metadata

  • Download URL: soundcloud-lib-0.5.4.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for soundcloud-lib-0.5.4.tar.gz
Algorithm Hash digest
SHA256 8b692c6bd5a8c1422d4161f06d914bb09f56564664fdf8029355b82db3e3c7e8
MD5 f30f343c678452a469fab1d8ed1267b9
BLAKE2b-256 b0284ef1aafcc3ab7754cd184c8b13a518169d96257eb2e8b2ef234643dbc047

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