Beispiel #1
0
 def __init__(self, user, pw):
     self.auth(user, pw)
     """ Authentification """
     client = Client(client_id='00d3fbad6f8ab649c131d0e558f8387d',
                     client_secret='8b7d292013c5f4ddbbacccfee6059a54',
                     username=str(user),
                     password=str(pw))
Beispiel #2
0
 def __init__(self):
     # Initialize the auth - we will want to get a non-expiring token
     # You can read and see flow here: http://developers.soundcloud.com/docs/api/guide#authentication
     self.sc = Client(client_id=settings.SOUNDCLOUD_CLIENT,
                      client_secret=settings.SOUNDCLOUD_SECRET,
                      redirect_uri=settings.SOUNDCLOUD_REDIRECT,
                      scope='non-expiring')
Beispiel #3
0
 def sync(cls):
     client = Client(client_id=app.config['SOUNDCLOUD_APP_KEY_ID'],
                     client_secret=app.config['SOUNDCLOUD_APP_KEY_SECRET'],
                     username=app.config['SOUNDCLOUD_USERNAME'],
                     password=app.config['SOUNDCLOUD_PASSWORD'])
     cls.upload_files(client)
     cls.sync_upload_state(client)
def test_put_metadata_with_track_uri():
    cl = Client(client_id=CLIENT_ID,
                client_secret=CLIENT_SECRET,
                access_token=ACCESS_TOKEN)
    res = cl.get("/tracks/%s" % TRACK_ID)
    res = cl.put(res.uri, metadata={"title": "updated with track.uri"})
    assert res.status_code == 200
def test_put_track_metadata():
    cl = Client(client_id=CLIENT_ID,
                client_secret=CLIENT_SECRET,
                access_token=ACCESS_TOKEN)
    res = cl.put("/tracks/%s" % TRACK_ID,
                 metadata={"title": "hello live test"})
    assert res.status_code == 200
def test_get_tracks():
    cl = Client(client_id=CLIENT_ID,
                client_secret=CLIENT_SECRET,
                access_token=ACCESS_TOKEN)
    res = cl.get("/me/tracks")
    assert res.status_code == 200

    track_ids = [track.id for track in res]
    print(track_ids)
Beispiel #7
0
 def get(self, **kwargs):
     """
         Reads in the json feed and updates _raw attribute
     """
     client = Client(access_token=self.access_token)
     self.tracks = client.get(self.endpoint,
                              limit=kwargs.get('limit', 200),
                              offset=kwargs.get('offset', 0))
     return self.tracks
Beispiel #8
0
    def __init__(self):
        CLIENT_ID = os.environ.get('SOUNDCLOUD_ID')
        CLIENT_SECRET = os.environ.get('SOUNDCLOUD_SECRET')
        CLIENT_EMAIL = os.environ.get('SOUNDCLOUD_EMAIL')
        CLIENT_PASSWORD = os.environ.get('SOUNDCLOUD_PASSWORD')

        self.client = Client(client_id=CLIENT_ID,
                             client_secret=CLIENT_SECRET,
                             username=CLIENT_EMAIL,
                             password=CLIENT_PASSWORD)
Beispiel #9
0
    def list(params, auth):
        if params['page_token'] == '':
            params['page_token'] = 1

        client = Client(client_id=auth.key, client_secret=auth.secret)
        response = client.get(
            '/tracks/',
            q=params['query'],
            limit=params['page_size'],
            offset=(int(params['page_token']) - 1) * int(params['page_size']),
        )
        return json.loads(response.raw_data)
Beispiel #10
0
def sc_get_client():
    from mixtape.models import SoundCloudInfo
    from soundcloud import Client
    from django.conf import settings
    data = SoundCloudInfo.objects.filter(active=True)
    if data:
        data = data[0]
        creds = {
            'client_id': data.client_id,
            'client_secret': data.client_secret,
            'username': data.username,
            'password': data.password,
        }
        return Client(**creds)
    else:
        return None
Beispiel #11
0
 def __init__(self):
     # Initialize the auth - we will want to get a non-expiring token
     # You can read and see flow here: http://developers.soundcloud.com/docs/api/guide#authentication
     super(SoundCloudBaseView, self).__init__()
     self.sc = Client(access_token=settings.SOUNDCLOUD_ACCESS_TOKEN, )
Beispiel #12
0
            print(' 😟')
            print('error retrieving resolved url %s' % resolved_url)
            print('retrieving url %s' % resolved_url.url)
            if os.path.exists(temp):
                os.remove(temp)
        # else:
        #     print(' 😊')

    return file_name


if not os.path.exists(TRACKS_DIR):
    os.makedirs(TRACKS_DIR)

client = Client(client_id=CLIENT_ID,
                client_secret=CLIENT_SECRET,
                username=USERNAME,
                password=PASSWORD)
now = datetime.datetime.now(pytz.utc)

for set_url in sys.argv[1:]:
    fg = FeedGenerator()
    fg.load_extension('podcast', atom=True, rss=True)

    try:
        res = client.get('/resolve', url=set_url)
    except Exception as err:
        print('error resolving url %s' % set_url)
        continue

    fg.id(set_url)
Beispiel #13
0
 def auth(self, user, pw):
     self.client = Client(client_id='00d3fbad6f8ab649c131d0e558f8387d',
                          client_secret='8b7d292013c5f4ddbbacccfee6059a54',
                          username=str(user),
                          password=str(pw))
Beispiel #14
0
 def get(pk, auth):
     client = Client(client_id=auth.key, client_secret=auth.secret)
     response = client.get('/tracks/' + pk, )
     response = json.loads(response.raw_data)
     return response
Beispiel #15
0
from soundcloud import Client
from secrets import soundcloudSecrets

# Create a new client that uses the user credentials oauth flow
client = Client(client_id=soundcloudSecrets['APP_ID'],
                client_secret=soundcloudSecrets['APP_SECRET'],
                username=soundcloudSecrets['USERNAME'],
                password=soundcloudSecrets['PASSWORD'])


def postSoundcloud(barbershopID, audioPath):
    track = client.post('/tracks',
                        track={
                            'title': "BARBERSHOP'D " + str(barbershopID),
                            'sharing': 'public',
                            'asset_data': open(audioPath, 'rb')
                        })
    soundcloudURL = track.permalink_url
    return soundcloudURL


if __name__ == '__main__':
    postSoundcloud("TESTID", "../audioOutput.wav")
def test_get_track_detail():
    cl = Client(client_id=CLIENT_ID,
                client_secret=CLIENT_SECRET,
                access_token=ACCESS_TOKEN)
    res = cl.get("/tracks/%s" % TRACK_ID)
    assert res.status_code == 200