def test_setup(self): headers = YTMusic.setup(config['auth']['headers_file'], config['auth']['headers_raw']) self.assertGreaterEqual(len(headers), 2) headers_raw = config['auth']['headers_raw'].split('\n') with unittest.mock.patch('builtins.input', side_effect=(headers_raw + [EOFError()])): headers = YTMusic.setup(config['auth']['headers_file']) self.assertGreaterEqual(len(headers), 2)
def test_setup(self): headers = YTMusic.setup(config['auth']['headers_file'], config['auth']['headers_raw']) self.assertGreaterEqual(len(headers), 2) with unittest.mock.patch('builtins.input', return_value=config['auth']['headers_raw']): self.assertGreaterEqual(len(headers), 2)
def run(self, args, config): from ytmusicapi.ytmusic import YTMusic filepath = input( "Enter the path where you want to save auth.json [default=current dir]: " ) if not filepath: filepath = os.getcwd() path = Path(filepath + '/auth.json') print('Using "' + str(path) + '"') if (path.exists()): print("File already exists!") return 1 print( "Open Youtube Music, open developer tools (F12), go to Network tab," ) print( "right click on a POST request and choose \"Copy request headers\"." ) print("Then paste (CTRL+SHIFT+V) them here and press CTRL+D.") try: print(YTMusic.setup(filepath=str(path))) except Exception: logger.exception("YoutubeMusic setup failed") return 1 print("Authentication JSON data saved to {}".format(str(path))) print('') print('Update your mopidy.conf to reflect the new auth file:') print(' [youtubemusic]') print(' enabled=true') print(' auth_json=' + str(path)) return 0
def run(self, args, config): from ytmusicapi.ytmusic import YTMusic path = config["ytmusic"]["auth_json"] if not path: logger.error("auth_json path not defined in config") return 1 print('Updating credentials in "' + str(path) + '"') print( "Open Youtube Music, open developer tools (F12), go to Network tab," ) print( 'right click on a POST request and choose "Copy request headers".') print("Then paste (CTRL+SHIFT+V) them here and press CTRL+D.") try: print(YTMusic.setup(filepath=str(path))) except Exception: logger.exception("YTMusic setup failed") return 1 print("Authentication JSON data saved to {}".format(str(path))) return 0
def run(self, args, config): from ytmusicapi.ytmusic import YTMusic filepath = input("Enter the path where you want to save auth.json:") path = Path(filepath) if (path.exists()): print("File already exists!") return 1 print( "Open Youtube Music, open developer tools (F12), go to Network tab," ) print( "right click on a POST request and choose \"Copy request headers\"." ) print("Then paste (CTRL+SHIFT+V) them here and press CTRL+D.") try: print(YTMusic.setup(filepath=str(path))) except Exception: logger.exception("YTMusic setup failed") return 1 print("auth.json saved to {}".format(str(path))) return 0
def test_setup(self): YTMusic.setup(config['auth']['headers_file'], config['auth']['headers_raw'])
def test_setup(self): YTMusic.setup()