A Python wrapper around the Soundcloud API

Overview

soundcloud-python

A friendly wrapper around the Soundcloud API.

Installation

To install soundcloud-python, simply:

pip install soundcloud

Or if you're not hip to the pip:

easy_install soundcloud

Basic Use

To use soundcloud-python, you must first create a Client instance, passing at a minimum the client id you obtained when you registered your app:

import soundcloud

client = soundcloud.Client(client_id=YOUR_CLIENT_ID)

The client instance can then be used to fetch or modify resources:

tracks = client.get('/tracks', limit=10)
for track in tracks.collection:
    print track.title
app = client.get('/apps/124')
print app.permalink_url

Authentication

All OAuth2 authorization flows supported by the Soundcloud API are available in soundcloud-python. If you only need read-only access to public resources, simply provide a client id when creating a Client instance:

import soundcloud

client = soundcloud.Client(client_id=YOUR_CLIENT_ID)
track = client.get('/tracks/30709985')
print track.title

If however, you need to access private resources or modify a resource, you will need to have a user delegate access to your application. To do this, you can use one of the following OAuth2 authorization flows.

Authorization Code Flow

The Authorization Code Flow involves redirecting the user to soundcloud.com where they will log in and grant access to your application:

import soundcloud

client = soundcloud.Client(
    client_id=YOUR_CLIENT_ID,
    client_secret=YOUR_CLIENT_SECRET,
    redirect_uri='http://yourapp.com/callback'
)
redirect(client.authorize_url())

Note that redirect_uri must match the value you provided when you registered your application. After granting access, the user will be redirected to this uri, at which point your application can exchange the returned code for an access token:

access_token, expires, scope, refresh_token = client.exchange_token(
    code=request.args.get('code'))
render_text("Hi There, %s" % client.get('/me').username)

User Credentials Flow

The User Credentials Flow allows you to exchange a username and password for an access token. Be cautious about using this flow, it's not very kind to ask your users for their password, but may be necessary in some use cases:

import soundcloud

client = soundcloud.Client(
    client_id=YOUR_CLIENT_ID,
    client_secret=YOUR_CLIENT_SECRET,
    username='[email protected]',
    password='janespassword'
)
print client.get('/me').username

Examples

Resolve a track and print its id:

import soundcloud

client = soundcloud.Client(client_id=YOUR_CLIENT_ID)

track = client.get('/resolve', url='http://soundcloud.com/forss/flickermood')

print track.id

Upload a track:

import soundcloud

client = soundcloud.Client(access_token="a valid access token")

track = client.post('/tracks', track={
    'title': 'This is a sample track',
    'sharing': 'private',
    'asset_data': open('mytrack.mp4', 'rb')
})

print track.title

Start following a user:

import soundcloud

client = soundcloud.Client(access_token="a valid access token")
user_id_to_follow = 123
client.put('/me/followings/%d' % user_id_to_follow)

Update your profile description:

import soundcloud

client = soundcloud.Client(access_token="a valid access token")
client.put('/me', user={
    'description': "a new description"
})

Proxy Support

If you're behind a proxy, you can specify it when creating a client:

import soundcloud

proxies = {
    'http': 'example.com:8000'
}
client = soundcloud.Client(access_token="a valid access token",
                           proxies=proxies)

The proxies kwarg is a dictionary with protocols as keys and host:port as values.

Redirects

By default, 301 or 302 redirects will be followed for idempotent methods. There are certain cases where you may want to disable this, for example:

import soundcloud

client = soundcloud.Client(access_token="a valid access token")
track = client.get('/tracks/293/stream', allow_redirects=False)
print track.location

Will print a tracks streaming URL. If allow_redirects was omitted, a binary stream would be returned instead.

Running Tests

To run the tests, run:

$ pip install -r requirements.txt
$ nosetests --with-doctest
..................

Success!

Contributing

Contributions are awesome. You are most welcome to submit issues, or fork the repository.

soundcloud-python is published under a BSD License.

Owner
SoundCloud
SoundCloud
Python library for audio and music analysis

librosa A python package for music and audio analysis. Documentation See https://librosa.org/doc/ for a complete reference manual and introductory tut

librosa 5.6k Jan 06, 2023
PyAbsorp is a python module that has the main focus to help estimate the Sound Absorption Coefficient.

This is a package developed to be use to find the Sound Absorption Coefficient through some implemented models, like Biot-Allard, Johnson-Champoux and

Michael Markus Ackermann 8 Oct 19, 2022
nicfit 425 Jan 01, 2023
Music player - endlessly plays your music

Music player First, if you wonder about what is supposed to be a music player or what makes a music player different from a simple media player, read

Albert Zeyer 482 Dec 19, 2022
Algorithmic Multi-Instrumental MIDI Continuation Implementation

Matchmaker Algorithmic Multi-Instrumental MIDI Continuation Implementation Taming large-scale MIDI datasets with algorithms This is a WIP so please ch

Alex 2 Mar 11, 2022
Python module for handling audio metadata

Mutagen is a Python module to handle audio metadata. It supports ASF, FLAC, MP4, Monkey's Audio, MP3, Musepack, Ogg Opus, Ogg FLAC, Ogg Speex, Ogg The

Quod Libet 1.1k Dec 31, 2022
Pianote - An application that helps musicians practice piano ear training

Pianote Pianote is an application that helps musicians practice piano ear traini

3 Aug 17, 2022
A voice assistant which can be used to interact with your computer and controls your pc operations

Introduction 👨‍💻 It is a voice assistant which can be used to interact with your computer and also you have been seeing it in Iron man movies, but t

Sujith 84 Dec 22, 2022
An Amazon Music client for Linux (unpretentious)

Amusiz An Amazon Music client for Linux (unpretentious) ↗️ Install You can install Amusiz in multiple ways, choose your favorite. 🚀 AppImage Here you

Mirko Brombin 25 Nov 08, 2022
MIDI-DDSP: Detailed Control of Musical Performance via Hierarchical Modeling

MIDI-DDSP: Detailed Control of Musical Performance via Hierarchical Modeling Demos | Blog Post | Colab Notebook | Paper | MIDI-DDSP is a hierarchical

Magenta 239 Jan 03, 2023
Python interface to the WebRTC Voice Activity Detector

py-webrtcvad This is a python interface to the WebRTC Voice Activity Detector (VAD). It is compatible with Python 2 and Python 3. A VAD classifies a p

John Wiseman 1.5k Dec 22, 2022
Basically Play Pauses the song when it is safe to do so. when you die in a round

Basically Play Pauses the song when it is safe to do so. when you die in a round

AG_1436 1 Feb 13, 2022
Multi-Track Music Generation with the Transfomer and the Johann Sebastian Bach Chorales dataset

MMM: Exploring Conditional Multi-Track Music Generation with the Transformer and the Johann Sebastian Bach Chorales Dataset. Implementation of the pap

102 Dec 08, 2022
A Youtube audio player for your terminal

AudioLine A lightweight Youtube audio player for your terminal Explore the docs » View Demo · Report Bug · Request Feature · Send a Pull Request About

Haseeb Khalid 26 Jan 04, 2023
A Python wrapper around the Soundcloud API

soundcloud-python A friendly wrapper around the Soundcloud API. Installation To install soundcloud-python, simply: pip install soundcloud Or if you'r

SoundCloud 84 Dec 31, 2022
This is a python package that turns any images into MIDI files that views the same as them

image_to_midi This is a python package that turns any images into MIDI files that views the same as them. This package firstly convert the image to AS

Rainbow Dreamer 4 Mar 10, 2022
Any-to-any voice conversion using synthetic specific-speaker speeches as intermedium features

MediumVC MediumVC is an utterance-level method towards any-to-any VC. Before that, we propose SingleVC to perform A2O tasks(Xi → Ŷi) , Xi means utter

谷下雨 47 Dec 25, 2022
pyo is a Python module written in C to help digital signal processing script creation.

pyo is a Python module written in C to help digital signal processing script creation.

Olivier Bélanger 1.1k Jan 01, 2023
The project aims to develop a personal-assistant for Windows & Linux-based systems

The project aims to develop a personal-assistant for Windows & Linux-based systems. Samiksha draws its inspiration from virtual assistants like Cortana for Windows, and Siri for iOS. It has been desi

SHUBHANSHU RAI 1 Jan 16, 2022
A Quick Music Player Made Fully in Python

Quick Music Player Made Fully In Python. Pure Python, cross platform, single function module with no dependencies for playing sounds. Installation & S

1 Dec 24, 2021