-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
71 lines (58 loc) · 2.07 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import asyncio, time, variables, requests
from flask import Flask
from glagol import ys_sock, init
from yandex_music import Client
client = Client(variables.YM_TOKEN)
web = Flask(__name__)
@web.route('/')
def main():
return asyncio.run(ys_sock({"command":"ping"}))
@web.route('/volume/<vol>')
def volume(vol):
asyncio.run(ys_sock({"command":"setVolume", "volume":float(vol)}))
time.sleep(1.5)
return asyncio.run(ys_sock({"command":"ping"}))
@web.route('/next')
def next():
asyncio.run(ys_sock({"command":"next"}))
time.sleep(1.5)
return asyncio.run(ys_sock({"command":"ping"}))
@web.route('/prev')
def previous():
asyncio.run(ys_sock({"command":"prev"}))
time.sleep(1.5)
return asyncio.run(ys_sock({"command":"ping"}))
@web.route('/play')
def play():
asyncio.run(ys_sock({"command":"play"}))
time.sleep(1.5)
return asyncio.run(ys_sock({"command":"ping"}))
@web.route('/stop')
def stop():
asyncio.run(ys_sock({"command":"stop"}))
time.sleep(1.5)
return asyncio.run(ys_sock({"command":"ping"}))
@web.route('/rewind/<rew>')
def rewind(rew):
asyncio.run(ys_sock({"command":"rewind", "position":int(rew)}))
time.sleep(1.5)
return asyncio.run(ys_sock({"command":"ping"}))
@web.route('/like')
def like():
asyncio.run(ys_sock({"command":"sendText", "text":"Поставь лайк"}))
time.sleep(1.5)
return asyncio.run(ys_sock({"command":"ping"}))
@web.route('/dislike')
def dislike():
asyncio.run(ys_sock({"command":"sendText", "text":"Поставь дизлайк"}))
time.sleep(1.5)
return asyncio.run(ys_sock({"command":"ping"}))
# Yanify module
@web.route('/yanify/<query>')
def yanify(query):
r = requests.get(f"https://api.spotify.com/v1/tracks/{query}?market=RU", headers={"Authorization": f"Bearer {variables.SPOTIFY_TOKEN}"}).json()
asyncio.run(ys_sock({"command":"playMusic", "id": str(client.search(f"{r['artists'][0]['name']} - {r['name']}").tracks.results[0].id), "type": "track"}))
time.sleep(1.5)
return asyncio.run(ys_sock({"command":"ping"}))
init()
web.run("0.0.0.0", debug=True)