mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[scripts/copy-crosscode-emoji-url] add an option for adding the emote name to the copied URL
This commit is contained in:
parent
9aa78e8c92
commit
f84dbb619c
1 changed files with 11 additions and 2 deletions
|
@ -5,6 +5,7 @@ import os
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "script-resources"))
|
sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "script-resources"))
|
||||||
|
|
||||||
|
@ -64,12 +65,20 @@ chosen_index = common_script_utils.run_chooser(
|
||||||
)
|
)
|
||||||
chosen_emote = emotes[chosen_index]
|
chosen_emote = emotes[chosen_index]
|
||||||
|
|
||||||
emote_url = chosen_emote["url"]
|
emote_url = urllib.parse.urlparse(chosen_emote["url"])
|
||||||
|
emote_url_query = urllib.parse.parse_qs(emote_url.query)
|
||||||
|
|
||||||
default_emote_image_size = config.getint(
|
default_emote_image_size = config.getint(
|
||||||
"default", "default_emote_image_size", fallback=None
|
"default", "default_emote_image_size", fallback=None
|
||||||
)
|
)
|
||||||
if default_emote_image_size is not None:
|
if default_emote_image_size is not None:
|
||||||
emote_url += "?size={}".format(default_emote_image_size)
|
emote_url_query["size"] = [str(default_emote_image_size)]
|
||||||
|
|
||||||
|
if config.getboolean("default", "add_emote_name_to_url", fallback=False):
|
||||||
|
emote_url_query["name"] = [chosen_emote["name"]]
|
||||||
|
|
||||||
|
emote_url_query = urllib.parse.urlencode(emote_url_query, doseq=True)
|
||||||
|
emote_url = urllib.parse.urlunparse(emote_url._replace(query=emote_url_query))
|
||||||
|
|
||||||
common_script_utils.set_clipboard(emote_url)
|
common_script_utils.set_clipboard(emote_url)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue