logging
This commit is contained in:
		
							parent
							
								
									a1b67b4619
								
							
						
					
					
						commit
						5061236b58
					
				| @ -35,7 +35,7 @@ def download_choosen_format(update, context): | ||||
| 
 | ||||
|     with video.send() as files: | ||||
|         for f in files: | ||||
|             logger.log("Sending... {} ".format(f)) | ||||
|             logger.info("Sending... {} ".format(f)) | ||||
|             context.bot.send_document(chat_id=query.message.chat_id, document=open(f, 'rb')) | ||||
| 
 | ||||
|     context.bot.delete_message(chat_id=query.message.chat_id, | ||||
|  | ||||
| @ -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 | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user