{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "\n", "import json \n", "import requests \n", " \n", "import streamlit as st \n", "from streamlit_lottie import st_lottie \n", "import os\n", "folder_path = \"lotte_animation_saver/\"\n", "\n", "# Get the list of all files in the folder\n", "file_names = os.listdir(folder_path)\n", "max_file_name=max([int(i.split(\"_\")[-1][:-5]) for i in file_names]) \n", "url = requests.get( \n", " \"https://lottie.host/34b4b005-c8c9-4d57-a0fd-0e9ed3b49835/nCkgflSg9J.json\") \n", "# Creating a blank dictionary to store JSON file, \n", "# as their structure is similar to Python Dictionary \n", "url_json = dict() \n", " \n", "if url.status_code == 200: \n", "\n", " url_json = url.json() \n", " with open(\"lotte_animation_saver/animation_\"+str(max_file_name+1)+\".json\",\"w\") as read:\n", " json.dump(url_json,read,indent=2)\n", "\n", "else: \n", " print(\"Error in the URL\") " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "env", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.4" } }, "nbformat": 4, "nbformat_minor": 2 }