Пример #1
0
def show_cli(make_issue=False):
    try:
        song, artist = spotify.current()  # get currently playing song, artist
        print(lyrics(song, artist, make_issue))
        print('\n(Press Ctrl+C to quit)')
    except SpotifyNotRunning as e:
        print(e)
        print('\n(Press Ctrl+C to quit)')
        song, artist = None, None
    while True:
        # refresh every 5s to check whether song changed
        # if changed, display the new lyrics
        try:
            try:
                if spotify.current() == (song, artist):
                    raise SameSongPlaying
                else:
                    song, artist = spotify.current()
                    clear()
                    print(lyrics(song, artist, make_issue))
                    print('\n(Press Ctrl+C to quit)')
            except (SpotifyNotRunning, SameSongPlaying):
                time.sleep(5)
        except KeyboardInterrupt:
            print('\nSure boss, exiting.')
            exit()
Пример #2
0
	def test_that_no_song_or_artist_does_not_break_stuff(self):
		"""
		Test that None parameters in lyrics function does not break stuff
		"""
		self.assertEqual(lyrics(None, 'lol'), 'Nothing playing at the moment.')
		self.assertEqual(lyrics('lol', None), 'Nothing playing at the moment.')
		self.assertEqual(lyrics(None, None), 'Nothing playing at the moment.')
Пример #3
0
def main():
    print('Updating unsupported.txt from server.')
    with open('unsupported.txt', 'w', encoding='utf-8') as f:
        response = requests.get(
            'http://aadibajpai.pythonanywhere.com/master_unsupported')
        f.write(response.text)
    print("Updated unsupported.txt successfully.")

    parser = argparse.ArgumentParser(
        description=
        "Get lyrics for the currently playing song on Spotify. Either --tab or --cli is required."
    )

    parser.add_argument('-t',
                        '--tab',
                        action='store_true',
                        help='Display lyrics in a browser tab.')
    parser.add_argument('-c',
                        '--cli',
                        action='store_true',
                        help='Display lyrics in the command-line.')

    args = parser.parse_args()

    if args.tab:
        print('Firing up a browser tab!')
        app.template_folder = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'templates')
        app.static_folder = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'static')
        port = 5042  # random
        url = "http://127.0.0.1:{port}".format(port=port)
        threading.Timer(1.25, lambda: webbrowser.open(url)).start()
        app.run(port=port)

    elif args.cli:
        song = spotify.song()  # get currently playing song
        artist = spotify.artist()  # get currently playing artist
        print(lyrics(song, artist))
        print('\n(Press Ctrl+C to quit)')
        while True:
            # refresh every 5s to check whether song changed
            # if changed, display the new lyrics
            try:
                if song == spotify.song() and artist == spotify.artist():
                    time.sleep(5)
                else:
                    song = spotify.song()
                    artist = spotify.artist()
                    if song and artist is not None:
                        clear()
                        print(lyrics(song, artist))
                        print('\n(Press Ctrl+C to quit)')
            except KeyboardInterrupt:
                exit()
            if os.environ.get("TESTING", "False") != "False":
                break

    else:
        parser.print_help()
Пример #4
0
	def test_that_lyrics_calls_requests(self, f_get_lyrics, mock_requests):
		"""
		Test that get_lyrics calls requests when not a trivial case 
		"""
		self.assertEqual(lyrics(
			"Pixel2XL!", "Elgoog", True), "Couldn't get lyrics for Pixel2XL! by Elgoog.\nPhone is dope")
		self.assertEqual(lyrics(
			"Pixel2XL", "Elgoog", True), "Couldn't get lyrics for Pixel2XL by Elgoog.\n")
Пример #5
0
def main():
	# print(r"""
	#  ____                     _               _
	# / ___|_      ____ _  __ _| |   _   _ _ __(_) ___ ___
	# \___ \ \ /\ / / _` |/ _` | |  | | | | '__| |/ __/ __|
	#  ___) \ V  V / (_| | (_| | |__| |_| | |  | | (__\__ \
	# |____/ \_/\_/ \__,_|\__, |_____\__, |_|  |_|\___|___/
	#                     |___/      |___/
	# 	""")
	# print('\n')

	parser = argparse.ArgumentParser(
		description="Get lyrics for the currently playing song on Spotify. Either --tab or --cli is required.")

	parser.add_argument('-t', '--tab', action='store_true', help='Display lyrics in a browser tab.')
	parser.add_argument('-c', '--cli', action='store_true', help='Display lyrics in the command-line.')
	parser.add_argument('-n', '--no-issue', action='store_false', help='Disable issue-making on cli.')
	args = parser.parse_args()

	unsupported_precheck()

	if args.tab:
		print('Firing up a browser tab!')
		app.template_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
		app.static_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static')
		port = 5042  # random
		url = "http://127.0.0.1:{port}".format(port=port)
		threading.Timer(1.25, lambda: webbrowser.open(url)).start()
		app.run(port=port)

	elif args.cli:
		make_issue = args.no_issue
		song = spotify.song()  # get currently playing song
		artist = spotify.artist()  # get currently playing artist
		print(lyrics(song, artist, make_issue))
		print('\n(Press Ctrl+C to quit)')
		while True:
			# refresh every 5s to check whether song changed
			# if changed, display the new lyrics
			try:
				if song == spotify.song() and artist == spotify.artist():
					time.sleep(5)
				else:
					song = spotify.song()
					artist = spotify.artist()
					if song and artist is not None:
						clear()
						print(lyrics(song, artist, make_issue))
						print('\n(Press Ctrl+C to quit)')
			except KeyboardInterrupt:
				exit()
			if os.environ.get("TESTING", "False") != "False":
				break

	else:
		parser.print_help()
Пример #6
0
	def test_that_lyrics_works_for_unsupported_songs(self, fake_get_lyrics):
		"""
		Test that lyrics function gives 'unsupported' message to unsupported files
		"""
		fake_get_lyrics.return_value = None
		lyrics("Pixel2XL", "Elgoog", False)
		self.assertEqual(lyrics("Pixel2XL", "Elgoog"), "Lyrics unavailable for Pixel2XL by Elgoog.\n")

		# Deleting above songs and artists from unsupported.txt
		with open(unsupported_txt, "r") as f:
			lines = f.readlines()
		with open(unsupported_txt, "w") as f:
			for line in lines:
				if line not in ["Pixel2XL by Elgoog \n"]:
					f.write(line)
Пример #7
0
def main():
    parser = argparse.ArgumentParser(
        description=
        "Get lyrics for currently playing song on Spotify. Either --tab or --cli is required."
    )

    parser.add_argument('-t',
                        '--tab',
                        action='store_true',
                        help='Display lyrics in a browser tab.')
    parser.add_argument('-c',
                        '--cli',
                        action='store_true',
                        help='Display lyrics in the command-line.')

    args = parser.parse_args()

    if args.tab:
        print('Firing up a browser tab!')
        app.template_folder = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'templates')
        app.static_folder = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'static')
        app.run()

    elif args.cli:
        song = spotify.song()  # get currently playing song
        artist = spotify.artist()  # get currently playing artist
        print(lyrics(song, artist))
        print('\n(Press Ctrl+C to quit)')
        while True:
            # refresh every 5s to check whether song changed
            # if changed, display the new lyrics
            try:
                if song == spotify.song() and artist == spotify.artist():
                    time.sleep(5)
                else:
                    song = spotify.song()
                    artist = spotify.artist()
                    if song and artist is not None:
                        clear()
                        print(lyrics(song, artist))
                        print('\n(Press Ctrl+C to quit)')
            except KeyboardInterrupt:
                exit()

    else:
        parser.print_help()
Пример #8
0
def tab():
    current_lyrics = lyrics(song, artist)
    current_lyrics = current_lyrics.split('\n')  # break lyrics line by line
    return render_template('lyrics.html',
                           lyrics=current_lyrics,
                           song=song,
                           artist=artist)
Пример #9
0
    def test_that_lyrics_do_not_break_with_file_not_found(self):
        """
		test that lyrics function does not break if unsupported.txt is not found
		"""
        os.rename("unsupported.txt", "unsupported2.txt")
        self.assertEqual(lyrics("Crimes", "Grindelwald", False),
                         "Couldn\'t get lyrics for Crimes by Grindelwald.\n")
    def test_that_lyrics_does_not_break_with_request_giving_wrong_status_code(
            self, f_get_lyrics, mock_requests):
        """
		Test lyrics does not break with requests giving wrong status code
		"""
        self.assertEqual(lyrics("xyzzy", "Yello", True),
                         "Couldn\'t get lyrics for xyzzy by Yello.\n")
Пример #11
0
def tab():
	global song, artist
	song = spotify.song()
	artist = spotify.artist()
	current_lyrics = lyrics(song, artist)
	current_lyrics = current_lyrics.split('\n')
	return render_template('lyrics.html', lyrics=current_lyrics, song=song, artist=artist)
Пример #12
0
	def test_that_lyrics_do_not_break_with_file_not_found(self, fake_get_lyrics):
		"""
		test that lyrics function does not break if unsupported.txt is not found
		"""
		fake_get_lyrics.return_value = None
		shutil.move(unsupported_txt, "unsupported2.txt")
		resp = lyrics("Pixel2XL", "Elgoog", False)
		self.assertEqual(resp, "Couldn't get lyrics for Pixel2XL by Elgoog.\n")
Пример #13
0
	def test_that_lyrics_works_for_unsupported_songs(self):
		"""
		Test that lyrics function gives 'unsupported' message to unsupported files
		"""
		get_lyrics("Hello", "World", False)
		self.assertEqual(lyrics("Hello", "World"), "Lyrics unavailable for Hello by World.\n")
		get_lyrics("Foo", "Bar", False)
		self.assertEqual(lyrics("Foo", "Bar"), "Lyrics unavailable for Foo by Bar.\n")
		get_lyrics("Fantastic", "Beasts", False)
		self.assertEqual(lyrics("Fantastic", "Beasts"), "Lyrics unavailable for Fantastic by Beasts.\n")

		# Deleting above songs and artists from unsupported.txt
		with open("unsupported.txt", "r") as f:
			lines = f.readlines()
		with open("unsupported.txt", "w") as f:
			for line in lines:
				if line not in [" Hello by World \n", " Foo by Bar \n", " Fantastic by Beasts \n"]:
					f.write(line)
Пример #14
0
	def test_that_lyrics_works_for_unsupported_songs(self):
		"""
		Test that lyrics function gives 'unsupported' message to unsupported files
		"""
		get_lyrics("xyzzy", "Yeet", False)
		self.assertEqual(lyrics("xyzzy", "Yeet"), "Lyrics unavailable for xyzzy by Yeet.\n")
		get_lyrics("wiuegi", "Muhmello", False)
		self.assertEqual(lyrics("wiuegi", "Muhmello"), "Lyrics unavailable for wiuegi by Muhmello.\n")
		get_lyrics("Pixel2XL", "Elgoog", False)
		self.assertEqual(lyrics("Pixel2XL", "Elgoog"), "Lyrics unavailable for Pixel2XL by Elgoog.\n")

		# Deleting above songs and artists from unsupported.txt
		with open("unsupported.txt", "r") as f:
			lines = f.readlines()
		with open("unsupported.txt", "w") as f:
			for line in lines:
				if line not in ["xyzzy by Yeet \n", "wiuegi by Muhmello \n", "Pixel2XL by Elgoog \n"]:
					f.write(line)
Пример #15
0
def tab():
    # format lyrics for the browser tab template
    global song, artist
    song, artist = spotify.current()
    current_lyrics = lyrics(song, artist)
    current_lyrics = current_lyrics.split('\n')  # break lyrics line by line
    return render_template('lyrics.html',
                           lyrics=current_lyrics,
                           song=song,
                           artist=artist)
Пример #16
0
def tab():
    # format lyrics for the browser tab template
    global song, artist
    try:
        song, artist = spotify.current()
        current_lyrics = lyrics(song, artist)
    except SpotifyNotRunning:
        current_lyrics = 'Nothing playing at the moment.'
    current_lyrics = current_lyrics.split('\n')  # break lyrics line by line
    return render_template('lyrics.html',
                           lyrics=current_lyrics,
                           song=song,
                           artist=artist)
Пример #17
0
def tab():
    # format lyrics for the browser tab template
    # runs at the starting and when song changes to refresh changes onto browser
    global song, artist, isSameSong
    isSameSong = True

    song = spotify.song()
    artist = spotify.artist()

    current_lyrics = lyrics(song, artist)
    current_lyrics = current_lyrics.split("\n")  # break lyrics line by line

    return render_template("lyrics.html",
                           lyrics=current_lyrics,
                           song=song,
                           artist=artist)
Пример #18
0
def chromeSong():
    # Route to handle post request from browser
    global isSameSong
    isSameSong = False

    if request.method == "POST" or request.method == "OPTIONS":

        response = request.get_json(force=True)
        chrome.song = response["title"]
        chrome.artist = response["artist"]

        if chrome.isTerminal is True:
            # if called on terminal, print lyrics on terminal

            current_lyrics = lyrics(chrome.song, chrome.artist)
            print(current_lyrics)

    return chrome.artist, chrome.song
Пример #19
0
def main():
    # 	print(r"""
    #  ____                     _               _
    # / ___|_      ____ _  __ _| |   _   _ _ __(_) ___ ___
    # \___ \ \ /\ / / _` |/ _` | |  | | | | '__| |/ __/ __|
    #  ___) \ V  V / (_| | (_| | |__| |_| | |  | | (__\__ \
    # |____/ \_/\_/ \__,_|\__, |_____\__, |_|  |_|\___|___/
    #                     |___/      |___/
    # 	""")
    print("Updating unsupported.txt from server.")
    with open("unsupported.txt", "w", encoding="utf-8") as f:
        response = requests.get(
            "http://aadibajpai.pythonanywhere.com/master_unsupported")
        f.write(response.text)
    print("Updated unsupported.txt successfully.")

    parser = argparse.ArgumentParser(
        description=
        "Get lyrics for the currently playing song on Spotify. Either --tab or --cli is required."
    )

    parser.add_argument("-t",
                        "--tab",
                        action='store_true',
                        help="Display lyrics in a browser tab.")
    parser.add_argument("-c",
                        "--cli",
                        action='store_true',
                        help="Display lyrics in the command-line.")
    parser.add_argument("-cr",
                        "--chrome",
                        action='store_true',
                        help="Display lyrics in the command-line.")

    args = parser.parse_args()
    app.template_folder = os.path.join(
        os.path.dirname(os.path.abspath(__file__)), "templates")
    app.static_folder = os.path.join(
        os.path.dirname(os.path.abspath(__file__)), "static")
    port = 5042  # random
    url = "http://127.0.0.1:{port}".format(port=port)

    # A Function  to initialise Chrome extension Global variables
    def modeChecker(argg):
        chrome.initvariables()

        if argg:
            chrome.isChrome = True
            print("Listesning to chrome")
        else:
            chrome.isChrome = False
            print("Listesning to local")

    if args.tab:

        modeChecker(args.chrome)

        print("Firing up a browser tab!")

        threading.Timer(1.25, lambda: webbrowser.open(url)).start()
        app.run(port=port)

    elif args.cli:

        modeChecker(args.chrome)
        chrome.isTerminal = True

        if chrome.isChrome == True:
            # Starts a new thread with server running, to post requests from extension.
            t1 = threading.Thread(target=app.run(port=port))
            t1.start()
            exit()
        # printing logic for lyrics from extension handled from tabs.py so below code not required then.

        song = spotify.song()  # get currently playing song
        artist = spotify.artist()  # get currently playing artist
        print(lyrics(song, artist))
        print("\n(Press Ctrl+C to quit)")
        while True:
            # refresh every 5s to check whether song changed
            # if changed, display the new lyrics
            try:
                if song == spotify.song() and artist == spotify.artist():
                    time.sleep(5)
                else:
                    song = spotify.song()
                    artist = spotify.artist()
                    if song and artist is not None:
                        clear()
                        print(lyrics(song, artist))
                        print("\n(Press Ctrl+C to quit)")
            except KeyboardInterrupt:
                exit()
            if os.environ.get("TESTING", "False") != "False":
                break

    else:
        parser.print_help()
def show_cli(make_issue: bool = False) -> None:
    try:
        song, artist = spotify.current()  # get currently playing song, artist
        print(lyrics(song, artist, make_issue))
    except SpotifyNotRunning as e:
        print(e)
    def test_that_lyrics_requests_can_fail(self, f_get_lyrics, mock_requests):
        """
		Test that when get_lyrics calls requests and it does not succeed it doesn't append r.text
		"""
        self.assertEqual(lyrics("Pixel2XL!", "Elgoog", True),
                         "Couldn't get lyrics for Pixel2XL! by Elgoog.\n")
Пример #22
0
	def test_that_lyrics_do_not_break_with_file_not_found(self):
		"""
		test that lyrics function does not break if unsupported.txt is not found
		"""
		os.rename("unsupported.txt", "unsupported2.txt")
		self.assertEqual(lyrics("Pixel2XL", "Elgoog", False), "Couldn\'t get lyrics for Pixel2XL by Elgoog.\n")
    def test_that_lyrics_calls_get_lyrics(self, mock):
        """
		test that lyrics function calls get_lyrics function
		"""
        lyrics("Alone", "Marshmello")
        self.assertTrue(mock.called)
def main():
    # print(r"""
    #  ____                     _               _
    # / ___|_      ____ _  __ _| |   _   _ _ __(_) ___ ___
    # \___ \ \ /\ / / _` |/ _` | |  | | | | '__| |/ __/ __|
    #  ___) \ V  V / (_| | (_| | |__| |_| | |  | | (__\__ \
    # |____/ \_/\_/ \__,_|\__, |_____\__, |_|  |_|\___|___/
    #                     |___/      |___/
    # 	""")
    # print('\n')

    program = "Swaglyrics"
    parser = argparse.ArgumentParser(
        prog=program,
        usage='{prog} [options]'.format(prog=program),
        description=
        "Get lyrics for the currently playing song on Spotify. Either --tab or --cli is required."
    )

    # To select either one of the arguments provided in a group
    group = parser.add_mutually_exclusive_group()
    group.add_argument('-t',
                       '--tab',
                       action='store_true',
                       help='Display lyrics in a browser tab.')
    group.add_argument('-c',
                       '--cli',
                       action='store_true',
                       help='Display lyrics in the command-line.')
    parser.add_argument('-n',
                        '--no-issue',
                        action='store_false',
                        help='Disable issue-making on cli.')
    parser.add_argument('--song', help='Enter song name', type=str)
    parser.add_argument('--artist', help='Enter artist name', type=str)
    args = parser.parse_args()

    update_unsupported()

    if args.tab:
        print('Firing up a browser tab!')
        app.template_folder = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'templates')
        app.static_folder = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'static')
        port = 5042  # random
        url = "http://127.0.0.1:{port}".format(port=port)
        threading.Timer(1.25, lambda: webbrowser.open(url)).start()
        app.run(port=port)

    elif args.cli:
        make_issue = args.no_issue
        if args.song is None and args.artist is None:
            song = spotify.song()  # get currently playing song
            artist = spotify.artist()  # get currently playing artist
        else:
            song = args.song  # get song from command line argument
            artist = args.artist  # get artist from command line argument
            print(lyrics(song, artist, make_issue))
            raise SystemExit(0)

        print(lyrics(song, artist, make_issue))
        print('\n(Press Ctrl+C to quit)')
        while True:
            # refresh every 5s to check whether song changed
            # if changed, display the new lyrics
            try:
                if song == spotify.song() and artist == spotify.artist():
                    time.sleep(5)
                else:
                    song = spotify.song()
                    artist = spotify.artist()
                    if song and artist is not None:
                        clear()
                        print(lyrics(song, artist, make_issue))
                        print('\n(Press Ctrl+C to quit)')
            except KeyboardInterrupt:
                exit()
            if os.environ.get("TESTING", "False") != "False":
                break

    else:
        parser.print_help()
Пример #25
0
 def test_that_no_song_or_artist_does_not_break_stuff(self):
     self.assertEqual(lyrics(None, 'lol'), 'Nothing playing at the moment.')
     self.assertEqual(lyrics('lol', None), 'Nothing playing at the moment.')
     self.assertEqual(lyrics(None, None), 'Nothing playing at the moment.')
Пример #26
0
root = None

while i < 100000:
    # gets the current song being played
    current = spotify.song()
    while current is not None and previous != current:

        print('previous song: ', previous)
        print('current song: ', current)
        previous = current
        currentSongTitle = spotify.song()
        # gets the current artist
        currentArtist = spotify.artist()

        # gets the current lyrics of the song
        currentLyrics = lyrics(currentSongTitle, currentArtist)

        root = tk.Tk()
        root.title("Spotify Lyrics")
        root.configure(width=10, height=5)

        txt = tk.Text(root)
        txt.configure(font=("Century Gothic", 12), wrap='word')

        scrollbar = tk.Scrollbar(root, orient="vertical")
        scrollbar.config(command=txt.yview)
        scrollbar.pack(side="right", fill="y")
        txt.insert(tk.END, currentSongTitle + "\n")
        txt.insert(tk.END, currentArtist + "\n")
        # currentLyrics = currentLyrics.split('\n')
        txt.insert(tk.END, currentLyrics)
Пример #27
0
                    action='store_true',
                    help='Display lyrics in a browser tab.')
parser.add_argument('-c',
                    '--cli',
                    action='store_true',
                    help='Display lyrics in the command-line.')

args = parser.parse_args()

if args.tab:
    app.run()

elif args.cli:
    song = spotify.song()  # get currently playing song
    artist = spotify.artist()  # get currently playing artist
    print(lyrics(song, artist))
    print('\n(Press Ctrl+C to quit)')
    while True:
        # refresh every 5s to check whether song changed
        # if changed, display the new lyrics
        try:
            if song == spotify.song() and artist == spotify.artist():
                time.sleep(5)
            else:
                song = spotify.song()
                artist = spotify.artist()
                if song and artist is not None:
                    clear()
                    print(lyrics(song, artist))
                    print('\n(Press Ctrl+C to quit)')
        except KeyboardInterrupt:
Пример #28
0
def main():
    # 	print(r"""
    #  ____                     _               _
    # / ___|_      ____ _  __ _| |   _   _ _ __(_) ___ ___
    # \___ \ \ /\ / / _` |/ _` | |  | | | | '__| |/ __/ __|
    #  ___) \ V  V / (_| | (_| | |__| |_| | |  | | (__\__ \
    # |____/ \_/\_/ \__,_|\__, |_____\__, |_|  |_|\___|___/
    #                     |___/      |___/
    # 	""")
    print('Updating unsupported.txt from server.')

    appDataDir = AppDirs('swaglyrics', os.getlogin()).user_config_dir

    if platform.system() == "Windows":
        if not os.path.exists("C:\\Users\\" + os.getlogin() +
                              "\\AppData\\Local\\swaglyrics\\"):
            os.makedirs("C:\\Users\\" + os.getlogin() +
                        "\\AppData\\Local\\swaglyrics\\")

        appDataDir = "C:\\Users\\" + os.getlogin(
        ) + "\\AppData\\Local\\swaglyrics\\"
        print(appDataDir)
    else:
        appDataDir = appDataDir + "/"

    with open(appDataDir + "unsupported.txt", 'w', encoding='utf-8') as f:
        response = requests.get(
            'http://aadibajpai.pythonanywhere.com/master_unsupported')
        f.write(response.text)
    print("Updated unsupported.txt successfully.")

    parser = argparse.ArgumentParser(
        description=
        "Get lyrics for the currently playing song on Spotify. Either --tab or --cli is required."
    )

    parser.add_argument('-t',
                        '--tab',
                        action='store_true',
                        help='Display lyrics in a browser tab.')
    parser.add_argument('-c',
                        '--cli',
                        action='store_true',
                        help='Display lyrics in the command-line.')

    args = parser.parse_args()

    if args.tab:
        print('Firing up a browser tab!')
        app.template_folder = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'templates')
        app.static_folder = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'static')
        port = 5042  # random
        url = "http://127.0.0.1:{port}".format(port=port)
        threading.Timer(1.25, lambda: webbrowser.open(url)).start()
        app.run(port=port)

    elif args.cli:
        song = spotify.song()  # get currently playing song
        artist = spotify.artist()  # get currently playing artist
        print(lyrics(song, artist))
        print('\n(Press Ctrl+C to quit)')
        while True:
            # refresh every 5s to check whether song changed
            # if changed, display the new lyrics
            try:
                if song == spotify.song() and artist == spotify.artist():
                    time.sleep(5)
                else:
                    song = spotify.song()
                    artist = spotify.artist()
                    if song and artist is not None:
                        clear()
                        print(lyrics(song, artist))
                        print('\n(Press Ctrl+C to quit)')
            except KeyboardInterrupt:
                exit()
            if os.environ.get("TESTING", "False") != "False":
                break

    else:
        parser.print_help()
Пример #29
0
 def getLyrics(self, song_name, artist):
     song_lyrics = lyrics(song_name, artist)
     return song_lyrics.split("\n")