From 363942e0e0d395889582a667a617289e685057e1 Mon Sep 17 00:00:00 2001 From: Hodza Alban Date: Sat, 19 Aug 2017 18:44:56 +0200 Subject: [PATCH] code improvement --- vid_utils.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/vid_utils.py b/vid_utils.py index 643dabe..111fc7a 100644 --- a/vid_utils.py +++ b/vid_utils.py @@ -11,20 +11,16 @@ class BadLink(Exception): pass -class VideoQueue(list): # I want just the "lock" attribute - def __init__(self): - self.lock = False - - class Video: - def __init__(self, link, chat_id): + def __init__(self, link, init_keyboard=False): self.link = link - self.chat_id = chat_id - self.formats = self.get_formats() - self.keyboard = self.generate_keyboard() self.file_name = None + + if init_keyboard: + self.formats = self.get_formats() + self.keyboard = self.generate_keyboard() - def get_formats(self, link=None): + def get_formats(self): formats = [] cmd = "youtube-dl -F {}".format(self.link) @@ -56,7 +52,7 @@ class Video: for code, extension, resolution in self.formats: kb.append([InlineKeyboardButton("{0}, {1}".format(extension, resolution), - callback_data=code)]) + callback_data="{} {}".format(code, self.link))]) # maybe callback_data can support a list or tuple? return kb def download(self, resolution_code):