def upload_from_dir(self, video_dir: str):
assert os.path.isdir(video_dir), "Not found directory"
files = self._get_files_from_dir(video_dir, 'mp4')
for fname in files:
fpath = os.path.join(video_dir, fname)
if not os.path.exists(fpath):
continue
title = os.path.splitext(os.path.basename(fname))[0]
options = dict(
file=fpath,
title=title,
privacyStatus='unlisted',
)
video_id = self.upload_video(options)
if not video_id:
continue
video_url = 'https://www.youtube.com/watch?v={}'.format(video_id)
print('File uploaded: {}'.format(video_url))
message = '{} - {}'.format(title, video_url)
self.notify(message)
os.remove(fpath)
评论列表
文章目录