Add delays when downloading Mozilla dictionaries
This commit is contained in:
parent
98fc32a65e
commit
31fc4dc950
1 changed files with 3 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import urllib.request, json, re
|
import urllib.request, json, re, time
|
||||||
from functools import cmp_to_key
|
from functools import cmp_to_key
|
||||||
from locale import strcoll
|
from locale import strcoll
|
||||||
|
|
||||||
|
@ -87,6 +87,7 @@ with urllib.request.urlopen("https://services.addons.mozilla.org/api/v4/addons/l
|
||||||
'url': dictionary['current_version']['files'][0]['url'],
|
'url': dictionary['current_version']['files'][0]['url'],
|
||||||
'users': dictionary['average_daily_users'],
|
'users': dictionary['average_daily_users'],
|
||||||
})
|
})
|
||||||
|
time.sleep(1)
|
||||||
dictionaries.sort(key=lambda x: x.get('users'), reverse=True)
|
dictionaries.sort(key=lambda x: x.get('users'), reverse=True)
|
||||||
|
|
||||||
# Find dictionaries best matching the specified locales
|
# Find dictionaries best matching the specified locales
|
||||||
|
@ -138,6 +139,7 @@ for d in final_dictionaries:
|
||||||
'dictionaries/' + d['id'] + '-' + d['version'] + '.xpi'
|
'dictionaries/' + d['id'] + '-' + d['version'] + '.xpi'
|
||||||
)
|
)
|
||||||
del(d['url'])
|
del(d['url'])
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
with open('dictionaries/dictionaries.json', 'w', encoding='utf-8') as f:
|
with open('dictionaries/dictionaries.json', 'w', encoding='utf-8') as f:
|
||||||
json.dump(final_dictionaries, f, ensure_ascii=False, sort_keys=True, indent='\t')
|
json.dump(final_dictionaries, f, ensure_ascii=False, sort_keys=True, indent='\t')
|
||||||
|
|
Loading…
Reference in a new issue