- add limit ratio
- add limit ratio and super seed parameter to upload
This commit is contained in:
@@ -182,7 +182,7 @@ class ScreenShot:
|
|||||||
f"scale={self.WIDTH}:{self.HEIGHT}",
|
f"scale={self.WIDTH}:{self.HEIGHT}",
|
||||||
output_file, "-y"
|
output_file, "-y"
|
||||||
]
|
]
|
||||||
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
|
subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
|
||||||
# self.console.debug("result : ",result.stdout)
|
# self.console.debug("result : ",result.stdout)
|
||||||
# print(" ".join(cmd))
|
# print(" ".join(cmd))
|
||||||
# print(result)
|
# print(result)
|
||||||
|
|||||||
@@ -159,6 +159,36 @@ class qBittorrent:
|
|||||||
self.console.warn(f"Not found {rename} in qBittorrent. Super seed will not set")
|
self.console.warn(f"Not found {rename} in qBittorrent. Super seed will not set")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
async def set_limit_ratio(self,rename,ratioLimit=-1,seedingTimeLimit=-1,inactiveSeedingTimeLimit=-1):
|
||||||
|
for _ in range(5):
|
||||||
|
async with self.session.get(f"{self.url}/api/v2/torrents/info") as resp:
|
||||||
|
torrents = await resp.json()
|
||||||
|
|
||||||
|
torrent = next((t for t in torrents if rename in t["name"]), None)
|
||||||
|
if torrent is None:
|
||||||
|
self.console.warn(f"Not found {rename} in qBittorrent. Wait for 5 seconds")
|
||||||
|
await asyncio.sleep(5)
|
||||||
|
continue
|
||||||
|
data = {
|
||||||
|
'hashes': torrent["hash"],
|
||||||
|
'ratioLimit': ratioLimit,
|
||||||
|
'seedingTimeLimit': seedingTimeLimit,
|
||||||
|
'inactiveSeedingTimeLimit': inactiveSeedingTimeLimit,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async with self.session.post(
|
||||||
|
f"{self.url}/api/v2/torrents/setShareLimits",
|
||||||
|
data=data,
|
||||||
|
) as response:
|
||||||
|
if response.status == 200:
|
||||||
|
self.console.log("✅ Successfully set limit ratio torrent:", torrent["name"])
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
self.console.error("❌ Failed to set limit ratio torrent:", torrent["name"])
|
||||||
|
return False
|
||||||
|
self.console.warn(f"Not found {rename} in qBittorrent. limit ratio will not set")
|
||||||
|
return False
|
||||||
class BearBit:
|
class BearBit:
|
||||||
"""Class to interact with BearBit API"""
|
"""Class to interact with BearBit API"""
|
||||||
|
|
||||||
@@ -983,7 +1013,7 @@ class TorrentUpload(TorrentCreator):
|
|||||||
self.dd = dd or TorrentDD(console=console)
|
self.dd = dd or TorrentDD(console=console)
|
||||||
# self.console = console or logger(app_name="torrent_uploader",log_dir="./log")
|
# self.console = console or logger(app_name="torrent_uploader",log_dir="./log")
|
||||||
|
|
||||||
async def upload_torrent(self,entry:dict,qbit_category="SeFree"):
|
async def upload_torrent(self,entry:dict,qbit_category="SeFree",super_seed=False,ratioLimit=-1,seedingTimeLimit=-1,inactiveSeedingTimeLimit=-1):
|
||||||
|
|
||||||
file_path = entry['file_path']
|
file_path = entry['file_path']
|
||||||
imdb_id = entry['imdb_id']
|
imdb_id = entry['imdb_id']
|
||||||
@@ -1108,8 +1138,10 @@ class TorrentUpload(TorrentCreator):
|
|||||||
await self.qbit.add_torrent(torrent.torrent_path["all"], save_path=os.path.dirname(torrent.metadata[0]['path']),category=qbit_category, rename=name)
|
await self.qbit.add_torrent(torrent.torrent_path["all"], save_path=os.path.dirname(torrent.metadata[0]['path']),category=qbit_category, rename=name)
|
||||||
# await asyncio.sleep(5)
|
# await asyncio.sleep(5)
|
||||||
self.console.debug(f"qBittorrent name : {name}")
|
self.console.debug(f"qBittorrent name : {name}")
|
||||||
|
if super_seed:
|
||||||
await self.qbit.set_super_seed(name.strip())
|
await self.qbit.set_super_seed(name.strip())
|
||||||
await asyncio.sleep(1) # Sleep to avoid overwhelming the qBittorrent API
|
# await asyncio.sleep(1) # Sleep to avoid overwhelming the qBittorrent API
|
||||||
|
await self.qbit.set_limit_ratio(name.strip(),ratioLimit=ratioLimit,seedingTimeLimit=seedingTimeLimit,inactiveSeedingTimeLimit=inactiveSeedingTimeLimit)
|
||||||
# for i,torrent in enumerate(sorted(torrent_files['all'])):
|
# for i,torrent in enumerate(sorted(torrent_files['all'])):
|
||||||
# print(f"Adding torrent for: {torrent_files['metadata'][i]['path']}")
|
# print(f"Adding torrent for: {torrent_files['metadata'][i]['path']}")
|
||||||
# qbit.add_torrent(torrent, save_path=os.path.dirname(torrent_files['metadata'][i]['path']))
|
# qbit.add_torrent(torrent, save_path=os.path.dirname(torrent_files['metadata'][i]['path']))
|
||||||
|
|||||||
@@ -737,7 +737,7 @@ class USK(ScheduleBot):
|
|||||||
# await torrentupload.qbit.stop_torrent(search_string=torrent_detail["qbit_name"])
|
# await torrentupload.qbit.stop_torrent(search_string=torrent_detail["qbit_name"])
|
||||||
################################################
|
################################################
|
||||||
|
|
||||||
upload_status: dict[str,list] = await torrentupload.upload_torrent(upload_entry,qbit_category="SeFree-Automate")
|
upload_status: dict[str,list] = await torrentupload.upload_torrent(upload_entry,qbit_category="SeFree-Automate",super_seed=False,seedingTimeLimit=10080)
|
||||||
self.console.debug("Upload status:", upload_status)
|
self.console.debug("Upload status:", upload_status)
|
||||||
if not (any(item['status'] is False for item in upload_status['bearbit']) or any(item['status'] is False for item in upload_status['torrentdd'])) and \
|
if not (any(item['status'] is False for item in upload_status['bearbit']) or any(item['status'] is False for item in upload_status['torrentdd'])) and \
|
||||||
len(upload_status['bearbit'] ) > 0 and len(upload_status['torrentdd']) >0:
|
len(upload_status['bearbit'] ) > 0 and len(upload_status['torrentdd']) >0:
|
||||||
@@ -765,7 +765,7 @@ class USK(ScheduleBot):
|
|||||||
embed.add_field(name="TorrentDD", value=dd_text, inline=False)
|
embed.add_field(name="TorrentDD", value=dd_text, inline=False)
|
||||||
embed.set_footer(text="Thank you for visiting!")
|
embed.set_footer(text="Thank you for visiting!")
|
||||||
# self.console.debug("Upload status:", upload_status)
|
# self.console.debug("Upload status:", upload_status)
|
||||||
self.console.log(status.message,is_discord={"channel": self.channel,"embed": embed,"web_hook_urls":os.getenv['torrent_update_webhook'].split(",")})
|
self.console.log(status.message,is_discord={"channel": self.channel,"embed": embed,"web_hook_urls":os.getenv('torrent_update_webhook').split(",")})
|
||||||
|
|
||||||
qbit_name=next(
|
qbit_name=next(
|
||||||
(item["name"]
|
(item["name"]
|
||||||
|
|||||||
Reference in New Issue
Block a user