- handle season,episode overwrite for song,movie

- Make folder for each type of title
- Fix bug for discord downloader
This commit is contained in:
2026-03-30 11:46:33 +07:00
parent c2fafcd406
commit e9ca391575
7 changed files with 32 additions and 25 deletions

View File

@@ -202,7 +202,7 @@ async def download_command(
url: str,
keys: Optional[str] = 'False',
quality: Optional[str] = '1080',
codec: Optional[str] = "h265",
codec: Optional[str] = "h.265",
range_: Optional[str] = "SDR",
bitrate: Optional[str] = "Max",
start_season: Optional[int] = None,
@@ -344,7 +344,7 @@ async def process_download(entry):
bot.save_data()
channel = bot.get_channel(entry['channel_id'])
cmd=['/root/unshackle/.venv/bin/unshackle','dl']
cmd=['/root/unshackle-SeFree/.venv/bin/unshackle','dl']
if entry['proxy'] and entry['service'] not in ['HIDI']:
cmd += ['--proxy', entry['proxy']]
@@ -468,8 +468,8 @@ async def process_download(entry):
if entry['original_language']:
cmd += ['--original_lang', entry['original_language']]
if entry['android'] and entry['android'].lower() == 'true':
cmd += ['--android']
# if entry['android'] and entry['android'].lower() == 'true':
# cmd += ['--android']
if entry['service'] == 'TVN':
if entry['original_language']:
@@ -485,10 +485,9 @@ async def process_download(entry):
await channel.send(embed=embed)
result = await asyncio.to_thread(subprocess.run, cmd, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
result = await asyncio.to_thread(subprocess.run, cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
if '[E]' in result.stderr.decode() or "Processed all titles" not in result.stderr.decode():
if '[E]' in result.stdout.decode() or "Processed all titles" not in result.stdout.decode():
embed = discord.Embed(
title="❌ Download Failed",
description="Download request has been failed.",
@@ -509,9 +508,9 @@ async def process_download(entry):
embed.add_field(name="📅 Timestamp", value=entry['timestamp'], inline=False)
embed.set_footer(text=f"Requested by {entry['user']}")
print(result.stderr.decode())
print(result.stdout.decode())
print(f"Error downloading {entry['url']}: ")
entry['error'] = result.stderr.decode()
entry['error'] = result.stdout.decode()
entry['status'] = 'failed'
await channel.send(embed=embed)
@@ -583,8 +582,8 @@ async def process_download(entry):
app_commands.Choice(name="BiliBili", value="BLBL"),
])
@app_commands.choices(codec=[
app_commands.Choice(name="H264", value="H264"),
app_commands.Choice(name="H265", value="H265"),
app_commands.Choice(name="H264", value="H.264"),
app_commands.Choice(name="H265", value="H.265"),
app_commands.Choice(name="AV1", value="AV1"),
app_commands.Choice(name="VP9", value="VP9"),
])
@@ -642,7 +641,7 @@ async def clear_temp_command(
await interaction.response.send_message(embed=embed)
# Check if H265 codec is available for the given URL
os.removedirs("/root/unshackle/Temp")
os.removedirs("/root/unshackle-SeFree/Temp")
embed = discord.Embed(
title="🛠 Temporary Files Cleared",
description="Temporary files have been successfully cleared.",
@@ -661,7 +660,7 @@ def check_codec_support(url: str, codec: str, service: str, range_: str):
vp9_alias=['vp9', 'VP9', 'VP9.0', 'vp9.0']
cmd = ['/root/unshackle/.venv/bin/unshackle','dl', '--list',
cmd = ['/root/unshackle-SeFree/.venv/bin/unshackle','dl', '--list',
'--wanted','s01e01',
'--vcodec', codec, '--range', range_]
@@ -675,26 +674,26 @@ def check_codec_support(url: str, codec: str, service: str, range_: str):
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if ("Processed all titles" not in result.stderr.decode() or any(alias in result.stderr.decode() for alias in error_alias)):
print(f"Error checking codec support for {url}: {result.stderr.decode()}")
if ("Processed all titles" not in result.stdout.decode() or any(alias in result.stdout.decode() for alias in error_alias)):
print(f"Error checking codec support for {url}: {result.stdout.decode()}")
return ' '.join(cmd),'error','error'
# codec check
codec_available = False
if codec.lower() in h264_alias:
if any(alias in result.stderr.decode() for alias in h264_alias):
if any(alias in result.stdout.decode() for alias in h264_alias):
codec_available = True
elif codec.lower() in h265_alias:
if any(alias in result.stderr.decode() for alias in h265_alias):
if any(alias in result.stdout.decode() for alias in h265_alias):
codec_available = True
elif codec.lower() in av1_alias:
if any(alias in result.stderr.decode() for alias in av1_alias):
if any(alias in result.stdout.decode() for alias in av1_alias):
codec_available = True
elif codec.lower() in vp9_alias:
if any(alias in result.stderr.decode() for alias in vp9_alias):
if any(alias in result.stdout.decode() for alias in vp9_alias):
codec_available = True
if not codec_available:
@@ -707,7 +706,7 @@ def check_codec_support(url: str, codec: str, service: str, range_: str):
range_available = False
print(f"Checking {range_} support for {url}")
if range_ not in result.stderr.decode():
if range_ not in result.stdout.decode():
print(f"HDR support not available for {url}")
else:
print(f"{range_} support available for {url}")