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 hidden or 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. |
Thanks for this. No need for cookies, though if you change your curl to this:
`curl -s -u #{CF_TOKEN}:X -X DELETE https://#{CF_DOMAIN}.campfirenow.com/uploads/delete/#{id}`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on How To Clean A Campfire Room Of Uploads.
If you would like a copy of everything, have a look at campfire_export.