ytdl cache
This commit is contained in:
parent
5061236b58
commit
ce01266238
@ -8,4 +8,5 @@ services:
|
||||
- ./conf:/bot/conf
|
||||
environment:
|
||||
- CONF_FOLDER=/bot/conf/
|
||||
- XDG_CACHE_HOME=/bot/out/.cache
|
||||
user: 1000:1000
|
@ -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):
|
||||
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):
|
||||
|
Loading…
Reference in New Issue
Block a user