diff --git a/docker-compose.yml b/docker-compose.yml index e16d62e..afb2d3e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,4 +8,5 @@ services: - ./conf:/bot/conf environment: - CONF_FOLDER=/bot/conf/ + - XDG_CACHE_HOME=/bot/out/.cache user: 1000:1000 \ No newline at end of file diff --git a/src/vid_utils.py b/src/vid_utils.py index 0f42758..0a86fe7 100644 --- a/src/vid_utils.py +++ b/src/vid_utils.py @@ -75,7 +75,7 @@ class Video: def download(self): logger.info("Downloading {}".format(self.link)) - p = Popen(["youtube-dl", "-f", self.code, self.link], stdout=PIPE, stderr=PIPE).communicate() + p = Popen(["youtube-dl", "-o", "/bot/out/%(title)s-%(id)s.%(ext)s", "-f", self.code, self.link], stdout=PIPE, stderr=PIPE).communicate() for line in str(p[0], 'utf-8').split('\n'): logger.info(line) @@ -83,10 +83,14 @@ class Video: self.file_name = line[24:] # name of the file def check_dimension(self): - if os.path.getsize(self.file_name) > 50 * 1024 * 1023: - Popen(["split", "-b", "49M", self.file_name, self.file_name]) - os.remove(self.file_name) - return glob(escape(self.file_name) + '*') + try: + if os.path.getsize(self.file_name) > 50 * 1024 * 1023: + Popen(["split", "-b", "49M", self.file_name, self.file_name]) + os.remove(self.file_name) + return glob(escape(self.file_name) + '*') + except AttributeError as e: + logger.error(e) + return None @contextmanager def send(self):