Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View album_description.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
 
require 'watir-webdriver'
 
puts "== Album Description Updater =="
description = File.read(ARGV[0])
 
parts = description.scan(/https:\/\/www\.facebook\.com\/.*?\/media_set\S+/)
puts "There are #{parts.length} albums whose descriptions are to be updated!"
 
browser = Watir::Browser.new :firefox, :profile => 'watir'
 
parts.each do |part|
 
album_url = if part =~ /a\.(\d+)\.\d+\.(\d+)/
"https://m.facebook.com/#{$2}/albums/#{$1}/"
else
raise "Cannot generate Edit Album URL"
end
 
browser.goto album_url
 
# Click the Edit link
browser.a(href: /photos\/edit\/album/).click
album_title = browser.input(name: 'title').value
puts "- Updating: #{album_title}"
 
# Update the description
text = description.gsub(part) { "(this album)" }
browser.textarea(name: 'description').value = text
 
# Click the Submit button
browser.input(type: 'submit').click
 
end
 
puts
puts "All done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.