Skip to content

Instantly share code, notes, and snippets.

@mmar
Created August 30, 2011 14:34
Show Gist options
  • Save mmar/1181034 to your computer and use it in GitHub Desktop.
Save mmar/1181034 to your computer and use it in GitHub Desktop.
Get thumbnail for known media sharing URLs
sub url2thumb {
my $url = shift;
return "http://flic.kr/p/img/$1_t.jpg" if $url =~ qr{^http://flic\.kr/p/([a-zA-Z0-9]*)};
return "http://yfrog.com/$1.th.jpg" if $url =~ qr{^http://yfrog\.(?:com|ru|com\.tr|it|fr|co\.il|co\.uk|com\.pl|pl|eu)/([0-9a-zA-Z]*[jpbtgfzx])};
return "http://twitpic.com/show/thumb/$1" if $url =~ qr{^http://twitpic\.com/([a-zA-Z0-9])*};
return "http://img.ly/show/thumb/$1" if $url =~ qr{^http://img\.ly/([a-zA-Z0-9]*)};
return "http://pic.im/website/thumbnail/$1" if $url =~ qr{^http://pic\.im/([a-zA-Z0-9]*)};
return "http://twitgoo.com/$1/thumb" if $url =~ qr{^http://twitgoo\.com/([a-zA-Z0-9]*)};
return "http://ctr.lv/rest/small/thumb/$1" if $url =~ qr{^http://ctr\.lv/([a-zA-Z0-9]*)};
return "http://TweetPhotoAPI.com/api/TPAPI.svc/imagefromurl?size=thumbnail&url=$url"
if $url =~ qr{^http://(?:pic\.gd|tweetphoto.com)/([a-zA-Z0-9]*)};
return "http://img.pikchur.com/pic_$1_t.jpg" if $url =~ qr{^http://(?:pikchur\.com|pk\.gd)/([a-zA-Z0-9]*)};
return "http://picktor.com/get_photo_twitter.html?pic=$1&mode=150&crop=1"
if $url =~ qr{^http://picktor\.com/([a-zA-Z0-9]*)};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment