-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzing.py
68 lines (54 loc) · 1.91 KB
/
zing.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
import telebot
import requests
from bs4 import BeautifulSoup
TOKEN = ""
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(commands=['start'])
def start_command(message):
keyboard = telebot.types.InlineKeyboardMarkup()
bot.send_chat_action(message.chat.id, 'typing')
category(message)
@bot.message_handler(func=lambda message: True)
def message_handler(message):
if not (message.content_type == 'text'):
bot.send_message(
message.chat.id, f"please enter your name for search dear {message.chat.username}!")
else:
print(message.text)
def category(message):
keyboard = telebot.types.InlineKeyboardMarkup()
bot.send_chat_action(message.chat.id, 'typing')
keyboard.row(
telebot.types.InlineKeyboardButton(
'Tracks', callback_data='get-Tracks'
),
telebot.types.InlineKeyboardButton(
'People', callback_data='get-People'
),
telebot.types.InlineKeyboardButton(
'Albums', callback_data='get-Albums'
),
telebot.types.InlineKeyboardButton(
'Playlists', callback_data='get-Playlists'
)
)
bot.send_message(message.chat.id, 'chose your category',
reply_markup=keyboard)
@bot.callback_query_handler(func=lambda call: True)
def callback(query):
if query.data.startswith('get-'):
# search_music(query.message, query.data[4::])
print(query.data)
# TODO: create related urls
url = f'https://soundcloud.com/search?q='
bot.send_message(id, 'enter your search keyword')
def search_music(id, link):
bot.send_chat_action(id, 'typing')
page = requests.get(link)
soup = BeautifulSoup(page.content, 'html.parser')
results = soup.find_all('div', class_='trackList__item')
sound = []
for res in results:
sound += res.find(class_='sc-button-share')
bot.send_message(id, sound)
bot.polling()