Adapt screenshot script to new Lychee API

master
Quentin Duchemin 2023-02-20 16:09:56 +01:00
parent 72b0bb96a4
commit d2f2fe6980
Signed by: Chosto
GPG Key ID: 96AB8AE7DFEA3D74
2 changed files with 4 additions and 3 deletions

View File

@ -48,6 +48,7 @@ ttf-font-awesome-5
ttf-material-icons-git ttf-material-icons-git
ttf-symbola ttf-symbola
ttf-weather-icons ttf-weather-icons
unzip
usb_modeswitch usb_modeswitch
vim vim
vscodium-bin vscodium-bin

View File

@ -90,7 +90,7 @@ def upload_image(client, album_id, binary_img, img_format):
return client.add_photo(binary_img, str(uuid.uuid4()) + '.' + img_format, album_id) return client.add_photo(binary_img, str(uuid.uuid4()) + '.' + img_format, album_id)
def get_image_direct_link(client, image_id): def get_image_direct_link(client, image_id):
return SCREENSHOT_CONFIG['base_url'] + '/' + client.get_photo(image_id)['url'] return 'https://pic.chosto.me' + '/' + client.get_photo(image_id)['size_variants']['original']['url']
def main(argv): def main(argv):
upload, save, path = read_args(argv) upload, save, path = read_args(argv)
@ -108,8 +108,8 @@ def main(argv):
if upload: if upload:
s = login() s = login()
album_id = get_album_id(s, SCREENSHOT_CONFIG['album_name']) album_id = get_album_id(s, SCREENSHOT_CONFIG['album_name'])
image_id = upload_image(s, album_id, img, img_format) image_info = upload_image(s, album_id, img, img_format)
image_link = get_image_direct_link(s, image_id) image_link = get_image_direct_link(s, image_info['id'])
pyperclip.copy(image_link) pyperclip.copy(image_link)
subprocess.run(['notify-send', '-u', 'low', '-i', 'Info', '-a', 'Screenchost', 'Screenshot uploaded', 'Link copied to clipboard!']) subprocess.run(['notify-send', '-u', 'low', '-i', 'Info', '-a', 'Screenchost', 'Screenshot uploaded', 'Link copied to clipboard!'])
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e: