really ugly regex

This commit is contained in:
sanj 2010-10-26 01:14:35 +02:00
parent 00fef249ed
commit aae49b90d4

View File

@ -52,8 +52,15 @@ class Image(models.Model):
location = models.ForeignKey(Location)
flickrData = models.TextField(blank=True, editable=False)
#this function is fucked. either just get user to enter flickr id, or write a recursive function with an array of regexps and pray. but this is just crap.
def get_flickr_id(self):
regex = r'http\:\/\/.*?\/\d{4}/(.*?)_.*'
id = oxlib.findRe(self.url, regex)
if id != '':
return id
else:
regex = r'http://.*?/.*?/.*?/(.*?)/in/.*'
return oxlib.findRe(self.url, regex)
def __unicode__(self):