Skip to content

Instantly share code, notes, and snippets.

@Nightdavisao
Last active January 19, 2022 10:53
Show Gist options
  • Save Nightdavisao/0672523db440d0285ab3298aa3acb0f6 to your computer and use it in GitHub Desktop.
Save Nightdavisao/0672523db440d0285ab3298aa3acb0f6 to your computer and use it in GitHub Desktop.
python script to download your desired sticker pack (note that you need to have installed "requests" and "slugify" dependencies)
# encoding: utf-8
from requests import get
from slugify import slugify
import os, sys
def main(stickerid):
print("sticker.ly sticker pack downloader")
print("Sticker ID:", stickerid)
headers = {
"User-Agent": "androidapp.stickerly/1.13.3 (G011A; U; Android 22; pt-BR; br;)",
"Host": "api.sticker.ly"
}
res = get("http://api.sticker.ly/v3.1/stickerPack/{}".format(stickerid.upper()), headers=headers)
if res.status_code == 200:
json = res.json()
if json.get("error"):
print("Error when fetching sticker pack!")
print(json)
return
result = json["result"]
# create folder
folder_name = slugify(result["name"], spaces=True, only_ascii=True)
if not os.path.isdir(folder_name):
try:
os.mkdir(folder_name)
except Exception as e:
print("Not able to create folder for sticker pack in cwd")
raise e
else:
print("Folder for downloading sticker pack already exists, exiting")
return
url_prefix = result["resourceUrlPrefix"]
stickers = result["stickers"]
for sticker in stickers:
resolved = get(url_prefix + sticker["fileName"])
print(sticker["fileName"])
open(os.path.join(folder_name, sticker["fileName"]), 'wb').write(resolved.content)
with open(os.path.join(folder_name, "info.txt"), "a") as info_file:
info_file.write("Author: {}\nName: {}\nID: {}\nShare URL: {}"
.format(result["authorName"], result["name"], result["packId"], result["shareUrl"]))
info_file.close()
print("Done")
else:
print("Not good to go:", str(res.status_code))
print("Maybe that sticker pack doesn't exists or this code is outdated :(")
if __name__ == '__main__':
try:
main(sys.argv[1])
except IndexError:
print("Invalid argument, you need to provide a valid sticker pack ID")
@deepakgarg08
Copy link

Hello, I am looking for something, which can convert gif into sticker (especially for WhatsApp), It will be nice if we can provide directory location and code will take all files one by one and convert them all as individual sticker. See if you can make it?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment