Esempio n. 1
0
async def glyrics(message: Message):
    if (GCS_ENGINE_ID and GCS_API_KEY) is None:
        await message.edit(
            "**Requirements Missing**\n\n"
            "Please Configure `GCS_ENGINE_ID` & `GCS_API_KEY`\n\n\n"
            "**More Info on How to Configure:**\n"
            "[NOTE: Read all Steps First, Coz No one's gonna help ya]\n"
            "1. Create your new Custom Search Engine here to get your Engine ID: https://cse.google.com/cse/create/new \n"
            "2. Add any of the following or all (adding all is recommended) websites as per your choice in your Custom Search Engine:\n\n"
            "   »`https://genius.com/` \n"
            "   »`http://www.lyricsted.com/` \n"
            "   »`http://www.lyricsbell.com/` \n"
            "   »`https://www.glamsham.com/` \n"
            "   »`http://www.lyricsoff.com/` \n"
            "   »`http://www.lyricsmint.com/` \n"
            "\n**NOTE:** Please **don't turn on** the '**Search the entire Web**' feature as it is currently not possible to scrape from any random"
            " sites appearing in the search results.\n"
            "3. Visit here to get your API key: https://developers.google.com/custom-search/v1/overview")
        return

    if not message.input_str:
        await message.edit("Give Song Name Sir")
        return

    song = message.input_str
    try:
        gcsl = Song_Lyrics(GCS_API_KEY, GCS_ENGINE_ID)
        song_title, song_lyrics = gcsl.get_lyrics(song)
        out = f"**{song_title}**\n\n**Lyrics:**\n\n__{song_lyrics}__"
        await message.edit(out)
    except Exception as e:
        await message.err(e)
Esempio n. 2
0
def handle_command(channel, message):
    """
        Executes bot command if the command is known
    """

    response = None
   

    if message.startswith("lyrics for "):
        get_song_name = message[11:]
        lyrics_gen = Song_Lyrics('AIzaSyDtY1j0Bezk8BXw_9SKAXWYG6EyAoDryI8','004427544878426260376:axdgrmc-h0m')
        song = lyrics_gen.get_lyrics(get_song_name)
        response = '*' + song[0] + '*' + '\n\n' + song[1].replace('<br>','\n')

        slack_client.api_call(
            "chat.postMessage",
            channel = channel,
            text = response,
        )
Esempio n. 3
0
from lyrics_extractor import Song_Lyrics
import settings
import re

extract_lyrics = Song_Lyrics(settings.GCS_API_KEY, settings.GCS_ENGINE_ID)


def song_lyrics(song_msg):
    result = re.finditer('"([^"]*)"', song_msg)
    len, itterator = getIterLenAndIter(result)
    if len <= 0:
        return 'please search as : lyrics for "your_song_name"\n              or \ncheck your internet Connection'
    else:
        for res in itterator:
            song_name = res.group()
            song_name = song_name.replace('"', '')

    title, lyrics = extract_lyrics.get_lyrics(song_name)
    return title, lyrics


def getIterLenAndIter(iterator):
    temp = list(iterator)
    return len(temp), iter(temp)


# content = song_lyrics('lyrics for "shape of you"')
# if type(content) == str:
# print(content)
# if type(content) == tuple:
# for data in content:
Esempio n. 4
0
#!/usr/bin/python3

from lyrics_extractor import Song_Lyrics
import sys

# API and Search engine
extract_lyrics = Song_Lyrics("API-KEY", "ENGINE-ID")

query = ""

# Check for cli arguments, [0] is always filename
if len(sys.argv) > 1:
    args = sys.argv
    for a in args[1:]:
        query = query + " " + a
# Otherwise, prompt for input
else:
    query = input("Lyrics search: ")

song_title, song_lyrics = extract_lyrics.get_lyrics(query)

print(song_title)
print(song_lyrics)
Esempio n. 5
0
from mutagen.id3 import ID3
from lyrics_extractor import Song_Lyrics
import re
import urllib.request
from bs4 import BeautifulSoup

if __name__ == '__main__':
    # audio = MP3("/home/shehyaaz/Music/Ishq Mubarak.mp3")
    # print(audio)

    audio = ID3(
        "/home/shehyaaz/Music/04 Phir Mohabbat Murder 2-(Pagalworld.Com).mp3")
    #print(audio)
    print("Artist: %s" % audio['TPE1'].text[0])
    print("Track: %s" % audio["TIT2"].text[0])
    print("Release Year: %s" % audio["TDRC"].text[0])
    GCS_API_KEY = 'AIzaSyAZ59uTzToEyzWfBl7v-7yiCfTyZP94cBw'
    GCS_ENGINE_ID = '015343239474702540304:7l81lnsakdy'
    extract_lyrics = Song_Lyrics(GCS_API_KEY, GCS_ENGINE_ID)
    song_title, song_lyrics = extract_lyrics.get_lyrics('Phir Mohabbat')
    print(song_title)
    print(song_lyrics)
# API :  AIzaSyAZ59uTzToEyzWfBl7v-7yiCfTyZP94cBw
# Search Engine ID : 015343239474702540304:7l81lnsakdy
Esempio n. 6
0
EXIT_SYMBOLS = ['e', 'q']
indentation_symbol = "============================================================"

from lyrics_extractor import Song_Lyrics

extract_lyrics = Song_Lyrics("GOOGLEKEY")

while True:
    song_words = input("Enter the song of your interest: ")
    if not song_words:
        print(
            "I don't see anything that have a meaning.\nTry again (or exit with 'e')\n"
        )
    elif song_words in EXIT_SYMBOLS:
        print('Exited Successfully')
        break
    else:
        song_title, song_lyrics = extract_lyrics.get_lyrics(song_words)
        pagination = len(indentation_symbol) - len(song_title)
        if pagination > 1:
            song_title = ' ' * (pagination //
                                2) + song_title + ' ' * (pagination // 2)
        print("\n============================================================",
              song_title,
              "============================================================",
              sep='\n',
              end='\n\n')
        print(song_lyrics)
        print()
#Dependecy - python-dotenv (for the key-value pair from .env file and adds them to environment variable.)
#https://github.com/theskumar/python-dotenv
from dotenv import load_dotenv
load_dotenv(verbose=True)

#Dependecy Song_Lyrics - https://github.com/Techcatchers/PyLyrics-Extractor
from lyrics_extractor import Song_Lyrics

import sys
import os

#The Google API key and Custom Search Engine ID required for the Song_Lyrics Class
Google_Api_Key = os.getenv("GGL_API")
Search_Engine_ID = os.getenv("Search_Engine_ID")

extract_lyrics = Song_Lyrics(Google_Api_Key, Search_Engine_ID)

#extracting lyrics where the song title is taken as input
song_title, song_lyrics = extract_lyrics.get_lyrics(str(sys.argv))

#output the lyrics
print(song_title, song_lyrics)
Esempio n. 8
0
from bs4 import BeautifulSoup
from lyrics_extractor import Song_Lyrics

GCS_API_KEY = 'AIzaSyASpbvc4JUJ8IrGpD8s0fce-Z5-fR-fVMg'
GCS_ENGINE_ID = '017219377714881096991:vkzb1r4mghe'
SONG_NAME = input('Enter Song Name =>')

extract_lyrics = Song_Lyrics(GCS_API_KEY, GCS_ENGINE_ID)
song_title, song_lyrics = extract_lyrics.get_lyrics(SONG_NAME)

print(song_lyrics)
Esempio n. 9
0
def lyrics(x):
    extract_lyrics = Song_Lyrics('AIzaSyAdIJNVZTPQRrGGWx8A7BE3b9o-yvg0lo8',
                                 '003841451045928909730:culhppn6_lo')
    title, lrcs = extract_lyrics.get_lyrics(x)
    r = title + "\n" + lrcs
    return r
Esempio n. 10
0
def handle_command(channel, message):
    """
        Executes bot command if the command is known
    """

    response = None
    # This is where you start to implement more commands!
    if message in COMMANDS or message.startswith(
            "listen ") or message.startswith(
                "lyrics for ") or message.startswith("remind me on "):
        if message == 'drink water':
            response = "Yay... You are going in the right way. Now you will be reminded to drink a glass of water in every 2 hours.\n\nTo deactivate from drink water notifications, type *No water*."

        elif message == 'no water':
            response = "Eh! You are leaving a good habit to stay fit or may be you don't need reminders any more. But please make sure to drink at least 8-10 glasses of water per day.\n\nTo reactivate drink water notifications, type *Drink water*."

        elif message == 'help':
            response = user_help()

        elif message == "quotes":
            quote = requests.get(
                "http://quotes.rest/qod.json?category=inspire")
            data = quote.json()
            quote = data["contents"]["quotes"][0]["quote"]
            author = data["contents"]["quotes"][0]["author"]
            response = "Cool! You are now subscribed for receiving Daily Inspiring Quotes.\n\nTo deactivate from Daily Inspiring Quotes, type *No quotes*.\n\n"
            response += "*Quote of the day.*\n\n" + quote + "\n - _*" + author + "*_"

        elif message == 'no quotes':
            response = "Eh! You are unsubscribed from receiving Daily Inspiring Quotes. But always try to stay motivated to reach your goals as this tool can make you achieve anything you aspire in your life.\n\nTo reactivate Daily Inspiring Quotes, type *quotes*."

        elif message == 'facts':
            fact = requests.get(
                "http://randomuselessfact.appspot.com/random.json?language=en")
            data = fact.json()
            fact = data["text"]
            response = "Cool! You are now subscribed to Random Facts.\n\nTo deactivate from random facts, type *No facts*.\n\n" + "*Did you know?*\n\n" + fact

        elif message == 'no facts':
            response = 'Eh! You are unsubscribed from Random Facts. But make sure to keep learning and exploring things around you and never let your curiousity die in you.\n\nTo reactivate Random Facts, type *facts*.'

        elif message == "news":
            response = "Cool! You are now subscribed to latest news.\n\nTo deactivate from latest national news, type *No news*.\n\n"
            response += '*Current Affairs*\n\n' + get_news()

        elif message == "no news":
            response = "Eh! You are unsubscribed from latest National news. But make sure to keep yourself updated with the latest current affairs.\n\nTo reactivate latest news, type *news*."

        elif message == "health tips":
            response = "Cool! You are now subscribed to Health Tips.\n\nTo deactivate from health tips, type *No health tips*.\n\n"
            health = health_tips()
            response += "*Today's health tips is about " + health[
                0] + "*\n\n*_" + health[1] + "_*\n" + health[2]

        elif message == "no health tips":
            response = "Eh! You are unsubscribed from Health Tips. But make sure to stay fit and try to follow all the tips you have received till now.\n\nTo reactivate Health Tips, type *health tips*."

        elif message == "live football":
            response = "We provide live scores for *Premier League*, *Championship*, *Serie A*, *Primeira Liga*, *La Liga*. Which of these would you like to subscribe to receive match updates?\n\nYou can select mutiple competitions by seperating each of them with commas(,)."
            # f_res = threading.Thread(target=football_response, args=(channel, slack_client))
            # f_res.start()
            global foot_res
            foot_res = Football_res(channel, slack_client)

        elif message == "live cricket":
            response = "Subscribed for Cricket live scores."

        elif message.startswith("listen "):
            get_music_name = message[7:]
            store_music = music(get_music_name)
            response = "*" + store_music[0] + "*\n\nAudio Link: " + store_music[
                1] + "\n\nVideo Link: " + store_music[2]

        elif message.startswith("lyrics for "):
            get_song_name = message[11:]
            lyrics_gen = Song_Lyrics(settings.GCS_API_KEY,
                                     settings.GCS_ENGINE_ID)
            song = lyrics_gen.get_lyrics(get_song_name)
            response = '*' + song[0] + '*' + '\n\n' + song[1].replace(
                '<br>', '\n')

        # This will execute for tasks which will be scheduled for only once.
        elif message.startswith('remind me on ') and 'at ' in message:
            store_task_vals = parse_tasks(message)
            if len(store_task_vals) == 1:
                # if error, pass the error response to the user.
                response = store_task_vals[0]
            else:
                # Save store_tasks_vals to our db and notifies the user.
                response = 'All set. Your task is scheduled on ' + store_task_vals[
                    0] + ' at ' + store_task_vals[2] + ' hrs.'

        # This will execute for reminders which will be scheduled for every year.
        elif message.startswith('remind me on '):
            store_reminder_vals = parse_reminders(message)
            if len(store_reminder_vals) == 1:
                # if error, pass the error response to the user.
                response = store_reminder_vals[0]
            else:
                # Save store_tasks_vals to our db and notifies the user.
                response = 'Reminder set. Now you will be reminded on ' + store_reminder_vals[
                    0] + ' every year for ' + store_reminder_vals[
                        1] + '\'s ' + store_reminder_vals[2]

        # Sends the response back to the channel
        slack_client.api_call(
            "chat.postMessage",
            channel=channel,
            text=response,
        )
Esempio n. 11
0
import auths
import dblayer
from lyrics_extractor import Song_Lyrics
#from PyLyrics import *

tracks = []
artists = []

index = 0

f = open("lyrics.txt", "a+")

dblayer.opendb('music_history')

dblayer.getAllEntries()

tracks = dblayer.returnTracks()
artists = dblayer.returnArtists()

for track in tracks:
    #f.write(PyLyrics.getLyrics(artists[index], tracks[index]))
    #index = index + 1
    extract_lyrics = Song_Lyrics(auths.apiEngineKey, auths.engineID)
    song_title, song_lyrics = extract_lyrics.get_lyrics(track)
    f.write(song_lyrics)