reenabling extension filter for s3

This commit is contained in:
Christoph Stahl 2024-07-11 00:20:40 +02:00
parent 14498110ae
commit f4e15908cc

View file

@ -64,9 +64,13 @@ class S3Source(FileBasedSource):
secure=(config["secure"] if "secure" in config else True), secure=(config["secure"] if "secure" in config else True),
) )
self.bucket: str = config["bucket"] self.bucket: str = config["bucket"]
self.tmp_dir: str = config["tmp_dir"] if "tmp_dir" in config else "/tmp/syng" self.tmp_dir: str = (
config["tmp_dir"] if "tmp_dir" in config else "/tmp/syng"
)
self.index_file: Optional[str] = config["index_file"] if "index_file" in config else None self.index_file: Optional[str] = (
config["index_file"] if "index_file" in config else None
)
self.extra_mpv_arguments = ["--scale=oversample"] self.extra_mpv_arguments = ["--scale=oversample"]
async def get_file_list(self) -> list[str]: async def get_file_list(self) -> list[str]:
@ -90,7 +94,8 @@ class S3Source(FileBasedSource):
obj.object_name obj.object_name
for obj in self.minio.list_objects(self.bucket, recursive=True) for obj in self.minio.list_objects(self.bucket, recursive=True)
if obj.object_name is not None if obj.object_name is not None
] # and self.has_correct_extension(obj.object_name) and self.has_correct_extension(obj.object_name)
]
if self.index_file is not None and not os.path.isfile(self.index_file): if self.index_file is not None and not os.path.isfile(self.index_file):
with open(self.index_file, "w", encoding="utf8") as index_file_handle: with open(self.index_file, "w", encoding="utf8") as index_file_handle:
dump(file_list, index_file_handle) dump(file_list, index_file_handle)
@ -135,7 +140,9 @@ class S3Source(FileBasedSource):
video_dl_path: str = os.path.join(self.tmp_dir, video_path) video_dl_path: str = os.path.join(self.tmp_dir, video_path)
os.makedirs(os.path.dirname(video_dl_path), exist_ok=True) os.makedirs(os.path.dirname(video_dl_path), exist_ok=True)
video_dl_task: asyncio.Task[Any] = asyncio.create_task( video_dl_task: asyncio.Task[Any] = asyncio.create_task(
asyncio.to_thread(self.minio.fget_object, self.bucket, entry.ident, video_dl_path) asyncio.to_thread(
self.minio.fget_object, self.bucket, entry.ident, video_dl_path
)
) )
audio_dl_path: Optional[str] audio_dl_path: Optional[str]
@ -143,7 +150,9 @@ class S3Source(FileBasedSource):
audio_dl_path = os.path.join(self.tmp_dir, audio_path) audio_dl_path = os.path.join(self.tmp_dir, audio_path)
audio_dl_task: asyncio.Task[Any] = asyncio.create_task( audio_dl_task: asyncio.Task[Any] = asyncio.create_task(
asyncio.to_thread(self.minio.fget_object, self.bucket, audio_path, audio_dl_path) asyncio.to_thread(
self.minio.fget_object, self.bucket, audio_path, audio_dl_path
)
) )
else: else:
audio_dl_path = None audio_dl_path = None