diff options
| author | mo <mo.khan@gmail.com> | 2018-06-14 10:13:21 -0600 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2018-06-14 10:13:21 -0600 |
| commit | f02b824205aae34585638cc78eefae434497eadd (patch) | |
| tree | 145530a8f862d4e6b8b31e0664a6917a69d9267e /lib | |
| parent | 8f871b2a14b4851503ade5f3af723a544683ba0c (diff) | |
lookup user info.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ghetto/blaster/cli.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/ghetto/blaster/cli.rb b/lib/ghetto/blaster/cli.rb index 6c0ad84..2860498 100644 --- a/lib/ghetto/blaster/cli.rb +++ b/lib/ghetto/blaster/cli.rb @@ -8,8 +8,12 @@ module Ghetto desc "play", "play music" def play - Net::Hippie.logger = Logger.new('/dev/null') - say client.get(build_uri("tracks?client_id=#{client_id}")).body + say client.get(build_uri("/tracks?client_id=#{client_id}")).body + end + + desc "user username", "fetch user info" + def user(username) + say client.get(resolve(username)[:location]).body end desc "version", "print version" @@ -28,7 +32,11 @@ module Ghetto end def build_uri(path) - "https://api.soundcloud.com/#{path}" + URI.join("https://api.soundcloud.com", path) + end + + def resolve(username) + JSON.parse(client.get(build_uri("/resolve?url=https://soundcloud.com/#{username}&client_id=#{client_id}")).body, symbolize_names: true) end end end |
