diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cdfda41 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +ig_settings.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..b6264f9 --- /dev/null +++ b/README.md @@ -0,0 +1,61 @@ + +# Notify + +Want to spice up your Notes on Instagram by displaying what you're currently playing on Spotify ? Here is Notify at your service ! + +## Installation + +Install Notify from GitHub + +### Download from GitHub +```bash + git clone https://github.com/nil-malh/Notify.git + cd Notify +``` + +### Download dependencies and run the project + +```bash + pip install -r requirements.txt && python notify.py +``` + +## Environment Variables + +To run this project, you will need to add the following environment variables to your .env file or input them when running the project for the first time. + +`SPOTIPY_CLIENT_ID`: +*The client_id from your Spotify application* + +`SPOTIPY_CLIENT_SECRET`: +*The client_secret from your Spotify application* + +`SPOTIPY_REFRESH_TOKEN`: +*The refresh_token for the Authentication to the Spotify API* + +`BOT_REFRESH_RATE`: +*The intervals between two notes sent to the Instagram API* + +`IG_USERNAME` +*Your Instagram username* +`IG_PASSWORD` +*Your Instagram password* + + + +## FAQ + +#### How can I generate a refresh_token ? + +You can use this [project]("https://github.com/limhenry/spotify-refresh-token-generator") made by [@limhenry]("https://github.com/limhenry") to generate your refresh_token please be sure to check the scope `user-read-currently-playing` in order to authorize Notify to ask Spotify what you are currently listening to. + +#### What value shoud I put in `BOT_REFRESH_RATE ?` + +The value in BOT_REFRESH_RATE should at least 120 seconds to avoid triggering Instagram. You can put lower value if you like the risk but I am not reponsible for your account being restricted ! + +## Used dependencies + +**Client:** +* [Instagrapi]("https://github.com/adw0rd/instagrapi") (*Note implementation made by me !*) +* [Spotipy]("https://github.com/spotipy-dev/spotipy") + + diff --git a/notify.py b/notify.py index f336da9..d785b81 100644 --- a/notify.py +++ b/notify.py @@ -13,6 +13,23 @@ from instagrapi.mixins.challenge import ChallengeChoice from instagrapi.types import NoteResponse from dotenv import load_dotenv +def print_welcome_message(): + + logo = '''⠀⠀⠀⠀⠀⠀⠀⢀⣠⣤⣤⣶⣶⣶⣶⣤⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⢀⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣤⡀⠀⠀⠀⠀ +⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⠀⠀⠀ +⠀⢀⣾⣿⡿⠿⠛⠛⠛⠉⠉⠉⠉⠛⠛⠛⠿⠿⣿⣿⣿⣿⣿⣷⡀⠀ +⠀⣾⣿⣿⣇⠀⣀⣀⣠⣤⣤⣤⣤⣤⣀⣀⠀⠀⠀⠈⠙⠻⣿⣿⣷⠀ +⢠⣿⣿⣿⣿⡿⠿⠟⠛⠛⠛⠛⠛⠛⠻⠿⢿⣿⣶⣤⣀⣠⣿⣿⣿⡄ +⢸⣿⣿⣿⣿⣇⣀⣀⣤⣤⣤⣤⣤⣄⣀⣀⠀⠀⠉⠛⢿⣿⣿⣿⣿⡇ +⠘⣿⣿⣿⣿⣿⠿⠿⠛⠛⠛⠛⠛⠛⠿⠿⣿⣶⣦⣤⣾⣿⣿⣿⣿⠃ █▄░█ █▀█ ▀█▀ █ █▀▀ █▄█ +⠀⢿⣿⣿⣿⣿⣤⣤⣤⣤⣶⣶⣦⣤⣤⣄⡀⠈⠙⣿⣿⣿⣿⣿⡿⠀ █░▀█ █▄█ ░█░ █ █▀░ ░█░ +⠀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣾⣿⣿⣿⣿⡿⠁⠀ +⠀⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠀⠀⠀ +⠀⠀⠀⠀⠈⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠛⠁⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠈⠙⠛⠛⠿⠿⠿⠿⠛⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀''' + + print(logo) def debug(message): timestamp = datetime.now().strftime('%H:%M:%S') @@ -41,6 +58,7 @@ def setup_env_file(): env_file.write(f"IG_PASSWORD={ig_password}\n") +print_welcome_message() setup_env_file() load_dotenv() @@ -140,8 +158,8 @@ def update(self,spotify): trigged_fail = False while True: try: - # bot.update(sp) - sleep(SLEEP_TIME) + bot.update(sp) + sleep(int(SLEEP_TIME)) except spotipy.exceptions.SpotifyException as e: if e.http_status == 401: debug("Token has expired, refreshing it...") diff --git a/requirements.txt b/requirements.txt index 967537c..0786d43 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -instagrapi==1.16.33 +instagrapi==1.16.41 requests==2.28.1 spotipy==2.22.1 python-dotenv==0.14.0 \ No newline at end of file