old_contents: import json
  import requests
  
  DEVICE_ID = '141f72b7-fd02-11e5-981a-00155d860f42'
  DEVICE_NAME = 'DroiTaka'
  CLIENT_ID = 'b12710fc26ee46ba82e34b97f08f2305'
  CLIENT_SECRET = '4ff2284115644e04acc77c54526364d2'
  
  class YaDisk(object):
  
  	def __init__(self, token):
  		self.session = requests.session()
  		self.session.headers.update({'Authentication': 'OAuth ' + str(token),})
  		
  	def get_key_url():
  		format_url = "https://oauth.yandex.ru/authorize?response_type=code&client_id={}&device_id={}&device_name={}&force_confirm=yes"
  		return format_url.format(CLIENT_ID, DEVICE_ID, DEVICE_NAME)
  		
  	def get_token(key):
  		res = self._post('http://oauth.yandex.ru/token', data = {
  			'grant_type': 'authorization_code',
  			'code': key,
  			'client_id': CLIENT_ID,
  			'client_secret': CLIENT_SECRET,
  			'device_id': DEVICE_ID,
  			'device_name': DEVICE_NAME,
  		})
  		print(res.json())
  		return res.json()['access_token']
  
  	def _get(self, url, *args, **kwargs):
  		return self.session.get(url, *args, **kwargs)
  
  	def _post(self, url, data, *args, **kwargs):
  		return self.session.post(url, {'data': json.dumps(data), }, *args, **kwargs)
  
  	def list_files(self, dir_path):
  		file_list = []
  		res = self._get("https://cloud-api.yandex.net:443/v1/disk/resources", params={"path": dir_path,})
  		for file in res.json()['_embedded']['items']:
  			if file['type'] == 'file':
  				file_list.append(file['name'])
  		return file_list
  
  	def direct_link(self, file_path):
  		response = self.session._get("https://cloud-api.yandex.net:443/v1/disk/resources/download", 
  		                             params={"path": file_path,})
  		return response.json()['href']
  
new_contents: import json
  import requests
  
  DEVICE_ID = '141f72b7-fd02-11e5-981a-00155d860f42'
  DEVICE_NAME = 'DroiTaka'
  CLIENT_ID = 'b12710fc26ee46ba82e34b97f08f2305'
  CLIENT_SECRET = '4ff2284115644e04acc77c54526364d2'
  
  class YaDisk(object):
  
  	def __init__(self, token):
  		self.session = requests.session()
  		self.session.headers.update({'Authentication': 'OAuth ' + str(token),})
  		
  	def get_key_url():
  		format_url = "https://oauth.yandex.ru/authorize?response_type=code&client_id={}&device_id={}&device_name={}&force_confirm=yes"
  		return format_url.format(CLIENT_ID, DEVICE_ID, DEVICE_NAME)
  		
  	def get_token(key):
  		res = requests.post('http://oauth.yandex.ru/token', data = {
  			'grant_type': 'authorization_code',
  			'code': key,
  			'client_id': CLIENT_ID,
  			'client_secret': CLIENT_SECRET,
  			'device_id': DEVICE_ID,
  			'device_name': DEVICE_NAME,
  		})
  		print(res.json())
  		return res.json()['access_token']
  
  	def _get(self, url, *args, **kwargs):
  		return self.session.get(url, *args, **kwargs)
  
  	def _post(self, url, data, *args, **kwargs):
  		return self.session.post(url, {'data': json.dumps(data), }, *args, **kwargs)
  
  	def list_files(self, dir_path):
  		file_list = []
  		res = self._get("https://cloud-api.yandex.net:443/v1/disk/resources", params={"path": dir_path,})
  		for file in res.json()['_embedded']['items']:
  			if file['type'] == 'file':
  				file_list.append(file['name'])
  		return file_list
  
  	def direct_link(self, file_path):
  		response = self.session._get("https://cloud-api.yandex.net:443/v1/disk/resources/download", 
  		                             params={"path": file_path,})
  		return response.json()['href']
  
subject: Update yadisk.py