Skip to content

Commit

Permalink
format script
Browse files Browse the repository at this point in the history
  • Loading branch information
luisg0nc committed Apr 26, 2023
1 parent 663752c commit 7051c9d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
db = client.bangerlink
collection = db.bangerlink


def save_song(chat_id, user, song_title, artist, youtube_url):
"""
Saves music entry data in db.
Expand All @@ -52,6 +53,7 @@ def save_song(chat_id, user, song_title, artist, youtube_url):

logger.info(f"New song added {result}")


def search_song_on_youtube(song_title, artist):
"""
Searches YouTube for a song with the given title and artist and returns the first result.
Expand Down Expand Up @@ -159,7 +161,7 @@ def search_song(bot, update):
result = collection.find_one(query)
if result is not None:
date_str = result["date"].strftime("%d of %m in %Y")

update.message.reply_text(
f'This banger has been mentioned here {result["hits"]} times. {result["user"]["name"]} first mentioned this banger in this chat {date_str}! \n{result["youtube"]}')

Expand All @@ -171,9 +173,9 @@ def search_song(bot, update):

# Search YouTube for the song
youtube_url = search_song_on_youtube(song_title, artist)
save_song(chat_id,user, song_title, artist, youtube_url)

save_song(chat_id, user, song_title, artist, youtube_url)

# Send the YouTube link as a message
update.message.reply_text(
f'Here is the Youtube Link, keep on bangin\' 😎\n{youtube_url}')
Expand Down

0 comments on commit 7051c9d

Please sign in to comment.