async def init(self, login: str = '', pwd: str = ''): """ Start point for get music.yandex.ru client :param login: Username or token string :param pwd: Password string :return: yandex_music.Client """ try: if login != '' and pwd != '': # Old authorization method, report_new_fields no need to new auth # self.client = Client.from_credentials(login, pwd, report_new_fields=False) self.client = Client.from_credentials(login, pwd) return True else: if pwd == '' and login != '': # Old authorization method, report_new_fields no need to new auth # self.client = Client.from_token(login, report_new_fields=False) self.client = Client.from_token(login) return True else: # Old authorization method, report_new_fields no need to new auth # self.client = Client.from_credentials(LOGIN, PWD, report_new_fields=False) self.client = Client.from_credentials(LOGIN, PWD) return True except Unauthorized: print("Unauthorized") return False except YandexMusicError: print("YandexMusicError") return False
def __init__(self,log,pas): client = captcha_key = captcha_answer = None while not client: try: client = Client.from_credentials(log,pas,captcha_answer,captcha_key) except Captcha as e: e.captcha.download('captcha.png') captcha_key = e.captcha.x_captcha_key captcha_answer = input('Число с картинки:') self.client = client
def __init__(self, title: str, username: str | None = None, password: str | None = None, token: str | None = None, cache="/tmp/YMStreamer", debug=False): super().__init__(title, debug) if token is not None: self.client = Client.from_token(token) else: self.client = Client.from_credentials(username or '', password or '') global CACHE_FOLDER CACHE_FOLDER = cache
def auth(self): if self.read_auth_token_from_file(): try: self.client = Client(self.auth_token) except Unauthorized as auth_exception: self.show_popup_error('Authorisation error', f'{auth_exception}', 1) else: self.show_auth_dialog() try: self.client = Client.from_credentials(self.auth_email, self.auth_password) self.save_auth_token_in_file() except BadRequest as auth_exception: self.show_popup_error('Auth by credentials error', f'{auth_exception}', 1)
from yandex_music import Client _login = "" _passwd = "" client = Client.from_credentials(username=_login, password=_passwd)
# Picture 'APIC': APIC(encoding=3, text=cover_filename, data=open(cover_filename, 'rb').read()) }) lyrics = client.track_supplement(track.track_id).lyrics if lyrics: # Song lyrics file.tags.add(USLT(encoding=3, text=lyrics.full_lyrics)) file.save() os.chdir(pwd) print("done") if __name__ == "__main__": folder = os.path.normpath(FOLDER) os.makedirs(folder, exist_ok=True) os.chdir(folder) pwd = os.getcwd() client = Client.from_credentials(LOGIN, PASSWORD) liked_by_plist = client.users_playlists(kind=3) if liked_by_plist: download_playlist(liked_by_plist[0]) else: print("`Liked by me` list is empty")
help='Token from music.yandex.com account') parser.add_argument('-i', '--ignore', nargs='+', help='Don\'t import some items', choices=['likes', 'playlists', 'albums', 'artists'], default=[]) arguments = parser.parse_args() auth_manager = SpotifyOAuth( client_id=CLIENT_ID, client_secret=CLIENT_SECRET, redirect_uri=REDIRECT_URI, scope= 'playlist-modify-public, user-library-modify, user-follow-modify, ugc-image-upload', username=arguments.spotify) spotify_client_ = spotipy.Spotify(auth_manager=auth_manager) if arguments.login and arguments.password: yandex_client_ = Client.from_credentials(arguments.login, arguments.password, captcha_callback=proc_captcha) elif arguments.token: yandex_client_ = Client(arguments.token) else: raise RuntimeError('Provide yandex account conditionals or token!') Importer(spotify_client_, yandex_client_, arguments.ignore).import_all()
def __init__(self, method_name: str): super().__init__(method_name) self._client = Client.from_credentials(username=_login, password=_passwd)