Programming


UPDATE: I wrote this up much more nicely at StackOverflow:

 

http://superuser.com/questions/1029610/how-do-view-flickr-com-using-the-old-style-consistently-automatically/1029614#1029614

 

My wife & I have gmail filters set up to forward each others’ facebook emails to each other. It brings a level of postmodern closeness and togetherness and awareness, and indeed keeps us from tripping each other up and having to have redundant exchanges of information. But then Facebook changed, and clicking each others’ links logged each other out. I can’t tell you how many times I’ve logged into facebook. Probably at least 100 in 2015 alone, if not more. IT. GETS. OLD. Then one day Carolyn played with the URL and discovered you could remove the last 2 parts of it, and it would bring you to the correct place (assuming you both had access). Then I realized I already had a plugin (chrome plugin id pajiegeliagebegjdhebejdlknciafen) called Redirector that lets you run a regular expression modification on any URLs you visit.  Why the hell was I not using this?   So just do this:

From To
(.*)(facebook.com)(.*)(&mid=.*) $1$2$3

And the problem is solved. Don’t bitch to me about the 4th set of parenthesis being unnecessary. It looks way better.

BONUS FEATURE: How to make the new flickr look like the old flickr:

From To
(https://www.flickr.com/photos/[a-zA-Z0-9]+/*)$
$1?details=1

When you download photos from flickr, the photo ID is actually stored in the filename, and you can use this to get back to the original photo. I decided to make any photos that are uploaded with the flickr filename automatically link to the original via perl code that I first posted here.

However, I have since realized that some pictures I post are actually a combination of several original pictures. Thus, I am now updating my code to properly deal with giving the link to all original images it is comprised of. The hardest part was dealing with the english rules for commas and “and”. “1 and 2” vs “1, 2, and 3” vs “1, 2, 3, and 4”.

Anyway, here is the revised code for auto-flickr-linking-to-original-pic:

my $FLICKR_PHOTOID_URL = "http://flickr.com/photo.gne?id=";
my @matches = $file =~ /([0-9]{10})_[0-9a-f]{10}[_ ][a-z]/ig;
my $matchNum = 0;
foreach $tmpmatch (@matches) {
  $tmpid = $tmpmatch;
  $matchNum++;
  if ($matchNum == 1) {
    $caption .= "Originally posted at ";
    $caption .= "$FLICKR_PHOTOID_TO_URL_PREFIX$tmpid";
  } elsif ($matchNum == @matches) {
    if (@matches > 2) { $s .= "	, ";	}
    $caption .= " and $FLICKR_PHOTOID_TO_URL_PREFIX$tmpid";
  } else {
    $caption .= " , $FLICKR_PHOTOID_TO_URL_PREFIX$tmpid";
  }
}
if (@matches > 0) { $s .= "\n"; }

This is definitely a bit more complex than the original version:

my $FLICKR_PHOTOID_URL = "http://flickr.com/photo.gne?id=";
if ($file =~ /([0-9]{10})_[0-9a-f]{10}_[a-z]/i) {
    $caption .= "Originally posted at $FLICKR_PHOTOID_URL$1\n";
}

(more…)

This may be helpful to others. If you are uploading flickr photos via Perl, and you would like your caption to automatically include a link to the original photo — all it requires is this tiny snippet of code:

NOTE!!! I HAVE COME UP WITH BETTER CODE FOR THIS HERE!!! YOU SHOULD PROBABLY USE THAT INSTEAD!

my $FLICKR_PHOTOID_URL = “http://flickr.com/photo.gne?id=”;
if ($file =~ /([0-9]{10})_[0-9a-f]{10}_[a-z]/i) {
$caption .= “Originally posted at $FLICKR_PHOTOID_URL$1\n”;
}

NOTE!!! I HAVE COME UP WITH BETTER CODE FOR THIS HERE!!! YOU SHOULD PROBABLY USE THAT INSTEAD!

Note that this only works if you keep the numbers from the filename that flickr gives you when you save a picture. IE “3375260709_1eb18b2012_o.jpg”. You can of course add anything else to the filename, but the “3375260709_1eb18b2012_o” part must be in there for this to work. (more…)