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()
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()
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)
def tab(): # format lyrics for the browser tab template global song, artist 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)
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)
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()
def test_that_artist_function_returns_None_when_error(self, mock): """ test that test artist function returns None when the get_info_windows function will return an error """ x = artist() self.assertEqual(x, None)
def test_that_artist_function_calls_get_info(self, mock): """ test that test artist function calls get_info_windows function """ x = artist() self.assertTrue(mock.called)
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 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()
'--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: 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)')