Skip to content

Instantly share code, notes, and snippets.

@mxey
Created May 10, 2013 17:48
Show Gist options
  • Select an option

  • Save mxey/5556112 to your computer and use it in GitHub Desktop.

Select an option

Save mxey/5556112 to your computer and use it in GitHub Desktop.
def completed_putio_transfers(user_token)
putio_connection = Faraday.new('https://api.put.io/v2/') do |faraday|
faraday.request :oauth2, user_token, param_name: :oauth_token
faraday.response :json, content_type: /\bjson$/
faraday.response :raise_error
faraday.adapter Faraday.default_adapter
end
transfers = putio_connection.get('transfers/list').body['transfers']
transfers.select! { |t| t['status'] == 'COMPLETED' || t['status'] == 'SEEDING' }
return Hash[transfers.map { |t| [t['id'], t['name']] }]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment