 |
Thank you. I was trying to reverse engineer the base58 string, and getting close, but no cigar. (If the photo ID space wasn't quite so sparsely populated where I was sampling it, I might have managed, too.)
Posted 9 months ago.
(
permalink
)
|
 |
Cool.
Posted 9 months ago.
(
permalink
)
|
 |
Someone jam this in a twitter client, pronto!
Posted 9 months ago.
(
permalink
)
|
 |
BC math is available in PHP.
bcmod -- Get modulus of an arbitrary precision number
Posted 9 months ago.
(
permalink
)
|
 |
It would be good if this was translatable to a photo url with out any requests (in the way twitpic, twitgoo, yfrog etc. do).
Just knowing the photo id doesn't get you to photo url since you need the secret, farm and server (http://www.flickr.com/services/api/misc.urls.html). We would have to do a flickr.photos.getInfo for each photo.
unless I'm missing something?
Posted 9 months ago.
(
permalink
)
|
 |
Here's an implementation of the encoding part in Objective-C: gist.github.com/101674
Posted 8 months ago.
(
permalink
)
|
 |
And here's an implementation in Ruby:
gist.github.com/101753
Posted 8 months ago.
(
permalink
)
|
 |
C# example:
http://www.faygate.net/post/133462295/tinyurlcode
Posted 6 months ago.
(
permalink
)
|
 |
An example for a bookmarklet:
javascript:void(prompt('Flic.kr short ID (base58)',(function(num){if(typeof num!=='number')num=parseInt(num);var enc='',alpha='123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';var div=num,mod;while(num>=58){div=num/58;mod=num-(58*Math.floor(div));enc=''+alpha.substr(mod,1)+enc;num=Math.floor(div);}return(div)?''+alpha.substr(div,1)+enc:enc;})(prompt('Flickr picture ID'))))
ETA: A more useful variant, giving you the respective Flic.kr-URL, if activated on a photo display page, might be:
javascript:void((function(){var m=window.location.href.match(/^https?:\/\/[^/]*\bflickr\.com\/(photos\/[^/]+\/(\d+))/i);if(m.length&&m[2])prompt('Short Flic.kr-URL for\n"'+m[1]+'":','http://flic.kr/p/'+(function(num)
{if(typeof num!=='number')num=parseInt(num);var enc='';var alpha='123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';var div=num;while(num>=58){div=num/58;var mod=(num-(58*Math.floor(div)));enc=''+alpha.substr(mod,1)+enc;num=Math.floor(div);}
return(div)?''+alpha.substr(div,1)+enc:enc;})(m[2]));})())
Originally posted 6 months ago.
(
permalink
)
Xenocryst @ Antares Scorpii edited this topic 6 months ago.
|
 |
quick python snippet for encoding...
num=12345678
a='123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
bc=len(a)
enc=''
while num>=bc:
div,mod=divmod(num,bc)
enc = a[mod]+enc
num = int(div)
enc = a[num]+enc
print "flic.kr/p/%s" % (enc,)
Originally posted 6 months ago.
(
permalink
)
stevefaeembra edited this topic 6 months ago.
|
 |
javascript decoder.
function base58_decode( snipcode )
{
var alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ' ;
var num = snipcode.length ;
var decoded = 0 ;
var multi = 1 ;
for ( var i = (num-1) ; i >= 0 ; i-- )
{
decoded = decoded + multi * alphabet.indexOf( snipcode[i] ) ;
multi = multi * alphabet.length ;
}
return decoded;
}
I'm using above base 58 decode function on pbtweet
Originally posted 6 months ago.
(
permalink
)
taiyofj edited this topic 6 months ago.
|
 |
Great topic kellan!
I've just used your base_encode function on flicktotwitt.com
THANKS!
Posted 6 months ago.
(
permalink
)
|
 |
Thanks for the information. I've created a simple, web-based implementation at http://www.timparenti.com/dev/flickr/shortlink/
It's meant for the people who don't necessarily want or need Twitter integration, but just want to convert URLs (although I might add Twitter integration later).
It can handle conversions from a short URL to a photo ID and vice-versa. I'm planning to add full URL support so you can just paste a long URL from your browser bar and it will extract the relevant bit (the photo ID).
If anyone has any ideas to improve it, please let me know. Here's hoping someone at least finds it useful.
Originally posted 6 months ago.
(
permalink
)
Tim Parenti edited this topic 6 months ago.
|
 |
Any reason why this can't be incorporated into the "Share This" widget at the top right of each photo page?
Posted 6 months ago.
(
permalink
)
|
 |
Btw valid paths after the photo id will be passed along now.
So flic.kr/p/$photoid/sizes/l works as do flic.kr/p/$photoid/nearby and flic.kr/p/$photoid/favorites
Posted 6 months ago.
(
permalink
)
|
 |
python decoder snippet
This code based on taiyofj's javascript one,
def b58decode(s):
alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
num = len(s)
decoded = 0 ;
multi = 1;
for i in reversed(range(0, num)):
decoded = decoded + multi * ( alphabet.index( s[i] ) )
multi = multi * len(alphabet)
return decoded;
Posted 5 months ago.
(
permalink
)
|
 |
If these are really Base58, why doesn't the Math:Int2Base perl module work?
Posted 5 months ago.
(
permalink
)
|
 |
Oooh, because you aren't using regular Base58. you're using Base62 with your own characters removed. Sorry, answered my own question.
Posted 5 months ago.
(
permalink
)
|
 |
my colleague Johnath converted this to a shorter Firefox bookmarklet using the page's contained <link rev="canonical"> tag:
javascript:var%20l=document.querySelectorAll("link");for(i=l.length-1;i>=0;--i){if(/flic\.kr/.test(l.item(i).href))prompt("Have%20a%20url!",l.item(i).href);}
Originally posted 5 months ago.
(
permalink
)
robceemoz edited this topic 5 months ago.
|
 |
and a simple variation of @robceemoz's post to send it straight to twitter
javascript:var%20l=document.querySelectorAll("link");for(i=l.length-1;i>=0;--i){if(/flic\.kr/.test(l.item(i).href))document.location='http://twitter.com/?status=Just%20posted:%20'+l.item(i).href;}
Posted 5 months ago.
(
permalink
)
|
 |
I've just posted up a Greasemonkey script based on Xenocryst @ Antares Scorpii's bookmarklet (above):
flic.kr Short URL Link
at userscripts.org
It looks like this:

Hope you find it useful!
Originally posted 4 months ago.
(
permalink
)
bitrot edited this topic 4 months ago.
|
 |
Rex, don't know if you're still looking for a Perl module, but check out
search.cpan.org/~miyagawa/Encode-Base58-0.01/lib/Encode/B...
Posted 4 months ago.
(
permalink
)
|
 |
Will there ever be the ability to use this URL shortening for sets?
Originally posted 2 months ago.
(
permalink
)
andrhamm edited this topic 2 months ago.
|
 |
:
I revised your initial check against m as such:
if(m&&m.length&&m[2])
So that it doesn't introduce a javascript error when used on non-flickr pages (accidental clicks). I didn't see adding further error checking as worthwhile, but someone else might.
Posted 2 months ago.
(
permalink
)
|
 |
I wrote a Firefox extension to get flic.kr shortened URL from context menu if you right click on Flickr photo, link, or Flickr photo page. Please try it
zoolcar9.lhukie.net/extensions/flic.kr.xpi
Please report any issues or suggestions at
www.flickr.com/photos/zoolcar9/sets/72157622750210617/com...
or at Flickr Hacks group
www.flickr.com/groups/flickrhacks/discuss/72157622750913301/
Originally posted 5 weeks ago.
(
permalink
)
Zoolcar9 edited this topic 5 weeks ago.
|
 |
Here is the Java Version:
dl.dropbox.com/u/1844215/FlickrBaseEncoder.java
Posted 2 weeks ago.
(
permalink
)
|
 |
Any chance of m.flic.kr redirecting to an m.flickr.com page?
Posted 2 weeks ago.
(
permalink
)
|
Would you like to comment?
Sign up for a free account, or sign in (if you're already a member).
|