Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # Fuckr: retrieve URL to full-size Flickr images
- # Ported from jwz's galdown script: http://www.jwz.org/hacks/galdown
- # by Rena Kunisaki, 2015 May 31
- # Copyright © 2015 Rena Kunisaki
- # Original code copyright © 2006-2015 Jamie Zawinski <jwz@jwz.org>
- #
- # Permission to use, copy, modify, distribute, and sell this software and its
- # documentation for any purpose is hereby granted without fee, provided that
- # the above copyright notice appear in all copies and that both that
- # copyright notice and this permission notice appear in supporting
- # documentation. No representations are made about the suitability of this
- # software for any purpose. It is provided "as is" without express or
- # implied warranty.
- import re
- import requests
- import sys
- def search(str, pat, flags=None, group=1):
- if flags is None:
- flags = re.M | re.S | re.X
- return re.search(pat, str, flags).group(group)
- def flickr_crack_secret(img):
- #api_key = 'dc4728449ac9905195f4bd612e1c215a'
- api_key = '4fc05fa65f1adedb76e0cb0655cc6836'
- id = search(img, r'/\d+/(\d+)_[a-f\d]+', flags=re.M | re.S | re.I)
- if id is None: raise ValueError("No image ID in this URL")
- url = 'https://api.flickr.com/services/rest' + \
- '?method=flickr.photos.getInfo' + \
- '&photo_id=' + id + \
- '&api_key=' + api_key
- req = requests.get(url)
- xml = req.text
- #if not '<photo ' in xml:
- # raise ValueError("No <photo> found in response")
- return "https://farm{farm}.staticflickr.com/{serv}/{id}_{secret}_o.{fmt}".\
- format(
- id = search(xml, r'\b id="(.*?)"'),
- farm = search(xml, r'\b farm="(.*?)"'),
- serv = search(xml, r'\b server="(.*?)"'),
- fmt = search(xml, r'\b originalformat="(.*?)"'),
- secret = search(xml, r'\b originalsecret="(.*?)"'),
- )
- if __name__ == '__main__':
- if len(sys.argv) < 2:
- sys.exit("Usage: %s url [url...]" % sys.argv[0])
- for i in range(1, len(sys.argv)):
- print(flickr_crack_secret(sys.argv[i]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement