def test_session(): """ Test if the [Session][deethon.session.Session] class raises a [DeezerLoginError][deethon.types.DeezerLoginError] when an invalid arl token is passed. """ with pytest.raises(deethon.errors.DeezerLoginError): session = deethon.Session('wrongarltoken') session._refresh_session()
def test_download(): """Test if the download method returns a Path object.""" deezer = deethon.Session( 'a77016e49be3ec2a03200a73d773a62dcd0eb5605c037b8194965aafe2c41d2276204368aa266407ba774dc54bde701ed4f8248eeac235fde26edea1af77dfaa0caac259b8e16ad01bee9514d79e234966714177f490b3d6e848686feea8840e') assert isinstance( deezer.download('https://www.deezer.com/track/2104162', 'MP3_320'), Path) assert isinstance( deezer.download('https://www.deezer.com/track/2104162'), Path) with pytest.raises(deethon.errors.InvalidUrlError): deezer.download('https://www.google.com') with pytest.raises(deethon.errors.ActionNotSupported): deezer.download('https://www.deezer.com/unsuppoted/123456') with pytest.raises(deethon.errors.DownloadError): deezer.download('https://www.deezer.com/track/101399924')
def test_download(): """Test if the download method returns a Path object.""" deezer = deethon.Session( '25e67e8e8100407765315a67e0d132fb88a436ffe244813b62ce7086c2efe01b3152041e4308dae45b14f22161adf525ede64cfa18eb9db01b02ec4ccac8869a7e726f372db54c313d4f5705637989ea1e20953a3ea60b5c0179ca95ddfe0516') assert isinstance( deezer.download('https://www.deezer.com/track/2104162', 'MP3_320'), Path) assert isinstance( deezer.download('https://www.deezer.com/track/2104162'), Path) with pytest.raises(deethon.errors.InvalidUrlError): deezer.download('https://www.google.com') with pytest.raises(deethon.errors.ActionNotSupported): deezer.download('https://www.deezer.com/unsuppoted/123456') with pytest.raises(deethon.errors.DownloadError): deezer.download('https://www.deezer.com/track/101399924')
botStartTime = time.time() load_dotenv() try: API_ID = int(os.environ["API_ID"]) API_HASH = os.environ["API_HASH"] BOT_TOKEN = os.environ["BOT_TOKEN"] DEEZER_TOKEN = os.environ["DEEZER_TOKEN"] OWNER_ID = int(os.environ["OWNER_ID"]) except KeyError: logger.error("One or more environment variables are missing! Exiting now…") sys.exit(1) deezer = deethon.Session(DEEZER_TOKEN) logger.debug(f'Using deethon v{deethon.__version__}') bot = TelegramClient(__name__, API_ID, API_HASH, base_logger=telethon_logger).start(bot_token=BOT_TOKEN) logger.info("Bot started") # Saving user preferences locally users = {} loop = asyncio.get_event_loop() #uvloop.install() loop.run_until_complete( bot( functions.bots.SetBotCommandsRequest(commands=[ types.BotCommand(command='start',