[+] Generate
This commit is contained in:
@@ -9,8 +9,9 @@ from tweepy import User
|
||||
|
||||
|
||||
def wget(url: str, file: Path):
|
||||
r = requests.get(url)
|
||||
file.write_bytes(r.content)
|
||||
if not file.is_file():
|
||||
r = requests.get(url)
|
||||
file.write_bytes(r.content)
|
||||
return str(file).replace('\\', '/')
|
||||
|
||||
|
||||
@@ -23,7 +24,7 @@ if __name__ == '__main__':
|
||||
(gen_path / 'img').mkdir(exist_ok=True, parents=True)
|
||||
|
||||
# Loop through all friends
|
||||
friends = json5.loads(Path('content/friends.json5').read_text())
|
||||
friends = json5.loads(Path('content/friends.json5').read_text('utf-8'))
|
||||
for f in friends:
|
||||
if 'twitter' not in f:
|
||||
continue
|
||||
@@ -31,12 +32,13 @@ if __name__ == '__main__':
|
||||
name = f['twitter']
|
||||
u: User = api.get_user(screen_name=name)
|
||||
|
||||
f['banner'] = '/' + wget(u.profile_banner_url, gen_path / f'img/{name}-banner.jpg')
|
||||
if 'profile_banner_url' in u.__dict__:
|
||||
f['banner'] = '/' + wget(u.profile_banner_url, gen_path / f'img/{name}-banner.jpg')
|
||||
f['avatar'] = '/' + wget(u.profile_image_url_https.replace('_normal', ''), gen_path / f'img/{name}-avatar.jpg')
|
||||
|
||||
if 'link' not in f:
|
||||
f['link'] = f'https://twitter.com/{name}'
|
||||
|
||||
(gen_path / 'friends.json').write_text(json.dumps(friends))
|
||||
(gen_path / 'friends.json').write_text(json.dumps(friends), 'utf-8')
|
||||
|
||||
print('Done')
|
||||
|
||||
@@ -30,7 +30,9 @@ jobs:
|
||||
python -m pip install pyyaml tweepy json5 requests
|
||||
|
||||
- name: "Run generator"
|
||||
run: "python .github/workflows/generator.py"
|
||||
run: |
|
||||
python .github/workflows/generator.py
|
||||
python .github/workflows/friends.py
|
||||
|
||||
- uses: EndBug/add-and-commit@v7
|
||||
with:
|
||||
|
||||
Reference in New Issue
Block a user