Commits

Peter Hosey  committed 3828838

Added support and a test case for another kind of Amazon URL I've spotted.

  • Participants
  • Parent commits ee6e857

Comments (0)

Files changed (2)

 	echo 'http://amzn.com/B002BAX76G' >> amazon.out.correct
 	echo 'http://www.amazon.com/Primer-Graphics-Development-Wordware-Library/dp/1556229119/ref=sr_1_1?ie=UTF8&s=books&qid=1303216717&sr=8-1' | ./Shorten-URLs.py >> amazon.out
 	echo 'http://amzn.com/1556229119' >> amazon.out.correct
+	echo 'http://www.amazon.com/Planets-Op-32-Bringer-Allegro/dp/album-redirect/B0013D9YB4/ref=sr_1_album_1?ie=UTF8&s=dmusic&qid=1311514320&sr=1-1' | ./Shorten-URLs.py >> amazon.out
+	echo 'http://amzn.com/B0013D9YB4' >> amazon.out.correct
 	diff -u amazon.out.correct amazon.out
 
 test-amazon-wishlist:

File Shorten-URLs.py

 		return short_URL
 
 class AmazonURLShortener(URLShortener):
-	canonical_URL_exp = re.compile('(?:http://)?(?:www\.)?(?:amazon\.com(?:(?:/[-_a-zA-Z0-9]+){2}|/dp)/)(B[A-Z0-9]+|[0-9]{10})(/ref=.*)?(\?.*)?')
+	canonical_URL_exp = re.compile('(?:http://)?(?:www\.)?(?:amazon\.com(?:(?:/[-_a-zA-Z0-9]+){2}|/dp)/)(?:album-redirect/)?(B[A-Z0-9]+|[0-9]{10})(/ref=.*)?(\?.*)?')
 
 	def shorten_URL_from_match(self, match):
 		item_ID = match.group(1)