Add proxy support
This commit is contained in:
parent
4d7234b809
commit
6680cc2a6d
3 changed files with 8 additions and 4 deletions
|
@ -77,7 +77,7 @@ async def start(e: events.NewMessage.Event):
|
|||
Button.url('Link Yandex music', get_ymusic_link(enc_user_id)),
|
||||
]
|
||||
await e.respond("""Hi! I can help you share music you listen on Spotify or Yandex music.
|
||||
To use just type @now_listening_bot and select track.
|
||||
To use just type @listensharebot and select track.
|
||||
|
||||
Press button below to authorize your account first
|
||||
|
||||
|
@ -103,7 +103,7 @@ async def change_default(e: events.NewMessage.Event):
|
|||
async def set_default(e: events.CallbackQuery.Event):
|
||||
async with get_session_context() as session:
|
||||
await session.execute(
|
||||
update(User).where(User.id == e.sender_id).values(default=str(e.data).split('_')[1])
|
||||
update(User).where(User.id == e.sender_id).values(default=str(e.data).split('_')[1][:-1])
|
||||
)
|
||||
await session.commit()
|
||||
await e.respond('Default service updated')
|
||||
|
|
|
@ -30,7 +30,7 @@ class Config(BaseSettings):
|
|||
yt: GoogleApiCreds
|
||||
ymusic: OauthCreds
|
||||
|
||||
proxy: str = ''
|
||||
proxy: str | None
|
||||
jwt_secret: str
|
||||
|
||||
|
||||
|
|
|
@ -8,11 +8,15 @@ from yt_dlp import YoutubeDL
|
|||
|
||||
from app.config import config
|
||||
|
||||
ytmusic = YTMusic('oauth.json', oauth_credentials=OAuthCredentials(client_id=config.yt.client_id, client_secret=config.yt.client_secret))
|
||||
ytmusic = YTMusic('oauth.json',
|
||||
oauth_credentials=OAuthCredentials(client_id=config.yt.client_id, client_secret=config.yt.client_secret))
|
||||
if config.proxy:
|
||||
ytmusic.proxies = {'http': config.proxy, 'https': config.proxy}
|
||||
|
||||
|
||||
def name_to_youtube(name: str):
|
||||
results = ytmusic.search(name, 'songs', limit=5)
|
||||
print(results[0])
|
||||
return results[0]['videoId']
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue