Skip to content

Commit

Permalink
Fixed some small errors in notify.py !
Browse files Browse the repository at this point in the history
Made a readme.md
Updated requirements.txt to have the latest version of Instagrapi !
  • Loading branch information
nil-malh committed Feb 15, 2023
1 parent 3f35a41 commit 0ebafbb
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
ig_settings.json
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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")


22 changes: 20 additions & 2 deletions notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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...")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0ebafbb

Please sign in to comment.