<s> import json <EOL> import os <EOL> import sys <EOL> import uuid <EOL> import flickr_api as fa <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> with open ( sys . argv [ <NUM_LIT:1> ] ) as conf : <EOL> config = json . load ( conf ) <EOL> KEY = config [ "<STR_LIT>" ] [ "<STR_LIT:key>" ] <EOL> SECRET = config [ "<STR_LIT>" ] [ "<STR_LIT>" ] <EOL> fa . set_keys ( KEY , SECRET ) <EOL> path_prefix = "<STR_LIT>" <EOL> w = fa . Walker ( fa . Photo . search , tags = sys . argv [ <NUM_LIT:2> ] , ) <EOL> size = "<STR_LIT>" <EOL> last_owners = [ ] <EOL> for photo in w : <EOL> info = photo . getInfo ( ) <EOL> if str ( info [ "<STR_LIT>" ] ) == "<STR_LIT:0>" : <EOL> continue <EOL> if info [ "<STR_LIT>" ] [ "<STR_LIT:username>" ] not in last_owners : <EOL> last_owners . insert ( <NUM_LIT:0> , info [ "<STR_LIT>" ] [ "<STR_LIT:username>" ] ) <EOL> if len ( last_owners ) > <NUM_LIT:10> : <EOL> last_owners . pop ( ) <EOL> title = photo . title . encode ( "<STR_LIT:utf-8>" ) <EOL> path = os . path . join ( path_prefix , "<STR_LIT>" % ( size . lower ( ) , hash ( title ) ) ) <EOL> photo . save ( path , size_label = size ) <EOL> print ( "<STR_LIT>" % ( title , path ) ) </s>
