Friday, September 30, 2011
Thursday, September 1, 2011
I had to deal with parsing the multiple flickr urls that exist to access an image.
Did you know that there are many different Url's for a single photo?
Here are the one's I've discovered:
flickr.com/photos/userId/id/someone else's list/
flickr.com/photos/userName/id/someone else's list/
And here is some code to strip all these suckers to get the photo Id:
public string GetFlickrPhotoId(string url)
string s = url.ToLower();
// remove everything after /in/ if it exists
s = s.Substring(0, s.IndexOf("/in/") > 0 ? s.IndexOf("/in/") : s.Length);
// remove url, user name, userid, photo.gne?id=id, "/"
s = s.Substring(s.Contains("/") ? s.LastIndexOf("/") : 0, s.Length - (s.Contains("/") ? s.LastIndexOf("/") : 0));
s = s.Replace("photo.gne?id=", string.Empty);
s = s.Replace("/", string.Empty);