code improvement

This commit is contained in:
Hodza Alban 2017-08-19 18:44:56 +02:00 committed by GitHub
parent d384efb138
commit 363942e0e0

View File

@ -11,20 +11,16 @@ class BadLink(Exception):
pass pass
class VideoQueue(list): # I want just the "lock" attribute
def __init__(self):
self.lock = False
class Video: class Video:
def __init__(self, link, chat_id): def __init__(self, link, init_keyboard=False):
self.link = link self.link = link
self.chat_id = chat_id
self.formats = self.get_formats()
self.keyboard = self.generate_keyboard()
self.file_name = None self.file_name = None
def get_formats(self, link=None): if init_keyboard:
self.formats = self.get_formats()
self.keyboard = self.generate_keyboard()
def get_formats(self):
formats = [] formats = []
cmd = "youtube-dl -F {}".format(self.link) cmd = "youtube-dl -F {}".format(self.link)
@ -56,7 +52,7 @@ class Video:
for code, extension, resolution in self.formats: for code, extension, resolution in self.formats:
kb.append([InlineKeyboardButton("{0}, {1}".format(extension, resolution), 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 return kb
def download(self, resolution_code): def download(self, resolution_code):