Created
August 9, 2012 20:49
-
-
Save webjay/3307910 to your computer and use it in GitHub Desktop.
Clean a Campfire room of uploads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'tinder' | |
# You need to put your *.campfirenow.com cookies in a cookies.txt file | |
class CampfireUploadCleaner | |
CF_DOMAIN = '' | |
CF_ROOM = '' | |
CF_TOKEN = '' | |
def initialize | |
@campfire = Tinder::Campfire.new CF_DOMAIN, :token => CF_TOKEN, :ssl => true | |
end | |
def room | |
@room ||= @campfire.find_room_by_name(CF_ROOM) | |
end | |
def connection | |
room.send(:connection) | |
end | |
def delete_uploads | |
uploads = room.send(:get,:uploads)['uploads'] | |
uploads.each do |upload| | |
id = upload['id'] | |
name = upload['name'] | |
# Delete | |
#connection.post "/uploads/delete/#{id}?n=0" | |
`curl -s --cookie cookies.txt -X DELETE https://#{CF_DOMAIN}.campfirenow.com/uploads/delete/#{id}` | |
puts "Deleted: [#{id}] #{name}" | |
#sleep(0.25) | |
end | |
end | |
def sweep_uploads | |
while room.files.present? | |
delete_uploads | |
end | |
end | |
end | |
cleaner = CampfireUploadCleaner.new | |
cleaner.delete_uploads # => Deletes the top 5 uploads. | |
#cleaner.sweep_uploads # => Deletes all uploads. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this. No need for cookies, though if you change your curl to this: