Permalink
Browse files

support default image.

  • Loading branch information...
1 parent 1fa00b3 commit fee8ac5e2a31aa16ea10e1117299320e0a22d45f @kou kou committed Jul 15, 2011
Showing with 10 additions and 4 deletions.
  1. +10 −4 app.rb
View
14 app.rb
@@ -139,17 +139,23 @@ def prepare_real_name(name)
def load_pixbuf(info)
screen_name = info[:screen_name]
- profile_image_url = info[:profile_image_url]
- *profile_image_url_components = profile_image_url.split(/\//)
+ original_profile_image_url = info[:profile_image_url]
+ *profile_image_url_components = original_profile_image_url.split(/\//)
profile_image_last_component = profile_image_url_components.last
profile_image_url_components[-1] =
u(profile_image_last_component.gsub(/_normal\.([a-zA-Z]+)\z/, '.\1'))
profile_image_url = profile_image_url_components.join("/")
extension = $1
image_data = cache_file("images", "#{screen_name}.#{extension}") do
- open(profile_image_url, "rb") do |image_file|
- image_file.read
+ begin
+ open(profile_image_url, "rb") do |image_file|
+ image_file.read
+ end
+ rescue OpenURI::HTTPError
+ open(original_profile_image_url, "rb") do |image_file|
+ image_file.read
+ end
end
end
loader = Gdk::PixbufLoader.new

0 comments on commit fee8ac5

Please sign in to comment.