Skip to content

Commit

Permalink
Some minor fixes
Browse files Browse the repository at this point in the history
Signed-off-by: anasty17 <[email protected]>
  • Loading branch information
anasty17 committed Jan 3, 2024
1 parent ee60a51 commit d3f5931
Show file tree
Hide file tree
Showing 14 changed files with 165 additions and 431 deletions.
3 changes: 1 addition & 2 deletions bot/helper/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,9 @@ async def generateSampleVideo(self, dl_path, size, gid):
if not checked:
checked = True
LOGGER.info(f"Creating Sample video: {self.name}")
res = await createSampleVideo(
return await createSampleVideo(
self, dl_path, sample_duration, part_duration, True
)
return res
else:
for dirpath, _, files in await sync_to_async(
walk, dl_path, topdown=False
Expand Down
14 changes: 6 additions & 8 deletions bot/helper/ext_utils/jdownloader_booter.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,12 @@ def connectToDevice(self):
return
try:
self.update_devices()
devices = self.list_devices()
if devices:
for device in devices:
if self._device_name == device["name"]:
self.device = self.get_device(f"{self._device_name}")
break
else:
continue
if not (devices := self.list_devices()):
continue
for device in devices:
if self._device_name == device["name"]:
self.device = self.get_device(f"{self._device_name}")
break
else:
continue
except:
Expand Down
17 changes: 8 additions & 9 deletions bot/helper/ext_utils/media_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ async def get_document_type(path):


async def take_ss(video_file, ss_nb) -> list:
if ss_nb > 10:
ss_nb = 10
ss_nb = min(ss_nb, 10)
duration = (await get_media_info(video_file))[0]
if duration != 0:
dirpath, name = video_file.rsplit("/", 1)
Expand Down Expand Up @@ -432,13 +431,7 @@ async def createSampleVideo(
code = listener.suproc.returncode
if code == -9:
return False
elif code != 0:
stderr = stderr.decode().strip()
LOGGER.error(
f"{stderr}. Something went wrong while creating sample video, mostly file is corrupted. Path: {video_file}"
)
return video_file
else:
elif code == 0:
if oneFile:
newDir, _ = ospath.splitext(video_file)
await makedirs(newDir, exist_ok=True)
Expand All @@ -448,3 +441,9 @@ async def createSampleVideo(
)
return newDir
return True
else:
stderr = stderr.decode().strip()
LOGGER.error(
f"{stderr}. Something went wrong while creating sample video, mostly file is corrupted. Path: {video_file}"
)
return video_file
11 changes: 7 additions & 4 deletions bot/helper/listeners/task_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ async def onDownloadComplete(self):

up_path = f"{self.dir}/{self.name}"
size = await get_path_size(up_path)
async with queue_dict_lock:
if self.mid in non_queued_dl:
non_queued_dl.remove(self.mid)
await start_from_queued()
if not config_dict["QUEUE_ALL"]:
async with queue_dict_lock:
if self.mid in non_queued_dl:
non_queued_dl.remove(self.mid)
await start_from_queued()

if self.join and await aiopath.isdir(up_path):
await join_files(up_path)
Expand Down Expand Up @@ -171,6 +172,8 @@ async def onDownloadComplete(self):
all_limit = config_dict["QUEUE_ALL"]
add_to_queue = False
async with queue_dict_lock:
if self.mid in non_queued_dl:
non_queued_dl.remove(self.mid)
dl = len(non_queued_dl)
up = len(non_queued_up)
if (
Expand Down
Loading

0 comments on commit d3f5931

Please sign in to comment.