no need to overwrite save_url anymore
This commit is contained in:
parent
f96815c175
commit
86e7d12eff
1 changed files with 1 additions and 15 deletions
16
edit.py
16
edit.py
|
@ -20,20 +20,6 @@ pandora_client_config = {}
|
||||||
use_local = False
|
use_local = False
|
||||||
|
|
||||||
|
|
||||||
class API(ox.API):
|
|
||||||
|
|
||||||
def save_url(self, url, filename, overwrite=False):
|
|
||||||
if not os.path.exists(filename) or overwrite:
|
|
||||||
dirname = os.path.dirname(filename)
|
|
||||||
if dirname and not os.path.exists(dirname):
|
|
||||||
os.makedirs(dirname)
|
|
||||||
chunk_size = 16 * 1024
|
|
||||||
request = urllib.request.Request(url)
|
|
||||||
remote = self._opener.open(request)
|
|
||||||
with open(filename, 'wb') as f:
|
|
||||||
for chunk in iter(lambda: remote.read(chunk_size), b''):
|
|
||||||
f.write(chunk)
|
|
||||||
|
|
||||||
|
|
||||||
if os.path.exists('files.json'):
|
if os.path.exists('files.json'):
|
||||||
files = json.load(open('files.json'))
|
files = json.load(open('files.json'))
|
||||||
|
@ -192,7 +178,7 @@ if __name__ == '__main__':
|
||||||
credentials['password'] = getpass.getpass('Password: ')
|
credentials['password'] = getpass.getpass('Password: ')
|
||||||
update = True
|
update = True
|
||||||
|
|
||||||
api = API(base_url + '/api/')
|
api = ox.API(base_url + '/api/')
|
||||||
r = api.signin(**credentials)
|
r = api.signin(**credentials)
|
||||||
if 'errors' in r.get('data', {}):
|
if 'errors' in r.get('data', {}):
|
||||||
for kv in r['data']['errors'].items():
|
for kv in r['data']['errors'].items():
|
||||||
|
|
Loading…
Reference in a new issue