|
@@ -1,4 +1,5 @@
|
|
|
import os
|
|
|
+import logging
|
|
|
from glob import glob, escape
|
|
|
from subprocess import Popen, PIPE
|
|
|
from contextlib import contextmanager
|
|
@@ -7,6 +8,9 @@ from telegram import InlineKeyboardButton
|
|
|
|
|
|
from db import VidDatabase
|
|
|
|
|
|
+logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
|
|
|
+logger = logging.getLogger(__name__)
|
|
|
+
|
|
|
class BadLink(Exception):
|
|
|
pass
|
|
|
|
|
@@ -57,6 +61,7 @@ class Video:
|
|
|
key = '{},{}'.format(extension, resolution)
|
|
|
index = self.db.insert_vid(self.link, format_code)
|
|
|
formats[key] = index
|
|
|
+ logger.info("Fromats: {}".format(formats))
|
|
|
return formats
|
|
|
|
|
|
def generate_keyboard(self):
|
|
@@ -69,9 +74,11 @@ class Video:
|
|
|
return kb
|
|
|
|
|
|
def download(self):
|
|
|
+ logger.info("Downloading {}".format(self.link))
|
|
|
p = Popen(["youtube-dl", "-f", self.code, self.link], stdout=PIPE, stderr=PIPE).communicate()
|
|
|
|
|
|
for line in str(p[0], 'utf-8').split('\n'):
|
|
|
+ logger.info(line)
|
|
|
if "[download] Destination:" in line:
|
|
|
self.file_name = line[24:] # name of the file
|
|
|
|