ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/dtflickr/trunk/dtflickr/__init__.py
(Generate patch)

Comparing trunk/dtflickr/__init__.py (file contents):
Revision 8 by douglas, 2008-05-05T00:43:00-07:00 vs.
Revision 9 by douglas, 2008-05-05T02:54:19-07:00

# Line 20 | Line 20
20  
21   import hashlib
22   import _methods
23 + import re
24   import simplejson
25   import time
26   import urllib
# Line 192 | Line 193 | def getBuddyiconURL(person, flickr = Non
193  
194   def __getWebPageURL():
195          return 'http://www.flickr.com/'
196 +
197 + __PhotoSourceURL = re.compile(r'^http://farm([0-9]+)\.static\.flickr\.com/([0-9]+)/([0-9]+)_([a-z0-9]+)(?:(?:_([bmst]))?\.jpg|_o\.(gif|jpg|png))$')
198 + __WebPageURL = re.compile(r'^http://www\.flickr\.com/(?:people|photos)/([^/]+)(?:/(?:([0-9]+)(?:/in/(?:photostream|set-([0-9]+)))?|sets(?:/([0-9]+))?))?/?$')
199 + __BuddyiconURL = re.compile(r'^http://farm([0-9]+)\.static\.flickr\.com/([0-9]+)/buddyicons/([^/]+)\.jpg$')
200 +
201 + def getURLDetails(url):
202 +        match = __PhotoSourceURL.match(url)
203 +
204 +        if match is not None:
205 +                if match.lastindex == 4:
206 +                        return Response({'farm_id': match.group(1), 'server_id': match.group(2), 'photo_id': match.group(3), 'secret': match.group(4), 'size': Medium})
207 +                elif match.lastindex == 5:
208 +                        return Response({'farm_id': match.group(1), 'server_id': match.group(2), 'photo_id': match.group(3), 'secret': match.group(4), 'size': match.group(5)})
209 +                elif match.lastindex == 6:
210 +                        return Response({'farm_id': match.group(1), 'server_id': match.group(2), 'photo_id': match.group(3), 'originalsecret': match.group(4), 'size': Original, 'originalformat': match.group(6)})
211 +        
212 +        match = __WebPageURL.match(url)
213 +
214 +        if match is not None:
215 +                if match.lastindex == 1:
216 +                        return Response({'user_id': match.group(1)})
217 +                elif match.lastindex == 2:
218 +                        return Response({'user_id': match.group(1), 'photo_id': match.group(2)})
219 +                elif match.lastindex == 3:
220 +                        return Response({'user_id': match.group(1), 'photo_id': match.group(2), 'photoset_id': match.group(3)})
221 +                elif match.lastindex == 4:
222 +                        return Response({'user_id': match.group(1), 'photoset_id': match.group(3)})
223 +
224 +        match = __BuddyiconURL.match(url)
225 +
226 +        if match is not None:
227 +                return Response({'icon_farm': match.group(1), 'icon_server': match.group(2), 'nsid': match.group(3)})
228 +
229 +        assert False

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines