mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 11:50:14 +00:00
make sure youtube_id gets written to cache file
This commit is contained in:
parent
82a91308f5
commit
89c99883c8
@ -428,23 +428,22 @@ class ManualImport:
|
|||||||
""" move identified video file to cache, convert to mp4 """
|
""" move identified video file to cache, convert to mp4 """
|
||||||
file_name = os.path.split(video_path)[-1]
|
file_name = os.path.split(video_path)[-1]
|
||||||
video_file, ext = os.path.splitext(file_name)
|
video_file, ext = os.path.splitext(file_name)
|
||||||
|
|
||||||
|
# make sure youtube_id is in filename
|
||||||
if not youtube_id in video_file:
|
if not youtube_id in video_file:
|
||||||
new_file_name = f'{video_file}_{youtube_id}{ext}'
|
video_file = f'{video_file}_{youtube_id}'
|
||||||
new_path = os.path.join(self.CACHE_DIR, 'download', new_file_name)
|
|
||||||
else:
|
# move, convert if needed
|
||||||
new_path = os.path.join(self.CACHE_DIR, 'download', file_name)
|
|
||||||
if ext == '.mp4':
|
if ext == '.mp4':
|
||||||
# just move
|
new_file = video_file + ext
|
||||||
new_path = os.path.join(self.CACHE_DIR, 'download', file_name)
|
dest_path = os.path.join(self.CACHE_DIR, 'download', new_file)
|
||||||
shutil.move(video_path, new_path)
|
shutil.move(video_path, dest_path)
|
||||||
else:
|
else:
|
||||||
# needs conversion
|
|
||||||
new_path = os.path.join(
|
|
||||||
self.CACHE_DIR, 'download', video_file + '.mp4'
|
|
||||||
)
|
|
||||||
print(f'processing with ffmpeg: {video_file}')
|
print(f'processing with ffmpeg: {video_file}')
|
||||||
|
new_file = video_file + '.mp4'
|
||||||
|
dest_path = os.path.join(self.CACHE_DIR, 'download', new_file)
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["ffmpeg", "-i", video_path, new_path,
|
["ffmpeg", "-i", video_path, dest_path,
|
||||||
"-loglevel", "warning", "-stats"], check=True
|
"-loglevel", "warning", "-stats"], check=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user