#NEWLINE# def __init__( self , conf ) : #NEWLINE# #INDENT# super ( Discogs , self ) . __init__ ( ) #NEWLINE# self . rate_limit = 3.0 #NEWLINE# import rauth #NEWLINE# discogs = rauth . OAuth1Service ( consumer_key = 'sYGBZLljMPsYUnmGOzTX' , consumer_secret = 'TtuLoHxEGvjDDOVMgmpgpXPuxudHvklk' , request_token_url = 'https://api.discogs.com/oauth/request_token' , access_token_url = 'https://api.discogs.com/oauth/access_token' , authorize_url = 'https://www.discogs.com/oauth/authorize' ) #NEWLINE# token = ( conf . get ( 'discogs' , 'token' ) , conf . get ( 'discogs' , 'secret' ) ) #NEWLINE# if ( ( not token ) or ( not all ( token ) ) ) : #NEWLINE# #INDENT# ( req_token , req_secret ) = discogs . get_request_token ( headers = HEADERS ) #NEWLINE# print ( ( 'Discogs requires authentication with your own account.\nDisable discogs in the config file or use this link to authenticate:\n%s' % discogs . get_authorize_url ( req_token ) ) ) #NEWLINE# data = { #NEWLINE# #INDENT# 'oauth_verifier' : raw_input ( 'Verification code: ' ) , #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# token = discogs . get_access_token ( req_token , req_secret , data = data , headers = HEADERS ) #NEWLINE# #UNINDENT# except KeyError as err : #NEWLINE# #INDENT# self . log . critical ( err . message ) #NEWLINE# exit ( ) #NEWLINE# #UNINDENT# if ( not conf . has_section ( 'discogs' ) ) : #NEWLINE# #INDENT# conf . add_section ( 'discogs' ) #NEWLINE# #UNINDENT# conf . set ( 'discogs' , 'token' , token [ 0 ] ) #NEWLINE# conf . set ( 'discogs' , 'secret' , token [ 1 ] ) #NEWLINE# conf . save ( ) #NEWLINE# #UNINDENT# self . session = discogs . get_session ( token ) #NEWLINE# self . session . headers . update ( HEADERS ) #NEWLINE# if ( requests_cache and ( not hasattr ( self . session . cache , '_ignored_parameters' ) ) ) : #NEWLINE# #INDENT# self . session . _is_cache_disabled = True