|
@@ -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):
|