add set_super_seed after added to qBittorrent
This commit is contained in:
@@ -182,8 +182,8 @@ 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.DEVNULL, stderr=subprocess.DEVNULL)
|
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
|
||||||
self.console.debug("result : ",result)
|
# self.console.debug("result : ",result.stdout)
|
||||||
# print(" ".join(cmd))
|
# print(" ".join(cmd))
|
||||||
# print(result)
|
# print(result)
|
||||||
# Draw timestamp with Pillow
|
# Draw timestamp with Pillow
|
||||||
|
|||||||
@@ -133,23 +133,31 @@ class qBittorrent:
|
|||||||
result.append(False)
|
result.append(False)
|
||||||
# return
|
# return
|
||||||
return all(result)
|
return all(result)
|
||||||
async def set_super_seed(self,rename):
|
async def set_super_seed(self, rename):
|
||||||
async with self.session.get(f"{self.url}/api/v2/torrents/info") as torrents:
|
for _ in range(5):
|
||||||
torrents = await torrents.json()
|
async with self.session.get(f"{self.url}/api/v2/torrents/info") as resp:
|
||||||
result=[]
|
torrents = await resp.json()
|
||||||
for torrent in torrents:
|
|
||||||
if rename not in torrent['name']:
|
|
||||||
continue
|
|
||||||
# print(torrent["hash"])
|
|
||||||
|
|
||||||
async with self.session.post(f"{self.url}/api/v2/torrents/setSuperSeeding", data={"hashes": torrent["hash"],"value":True}) as response:
|
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
|
||||||
|
|
||||||
|
async with self.session.post(
|
||||||
|
f"{self.url}/api/v2/torrents/setSuperSeeding",
|
||||||
|
data={"hashes": torrent["hash"], "value": True},
|
||||||
|
) as response:
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
self.console.log("✅ Successfully stop torrent :", torrent['name'])
|
self.console.log("✅ Successfully set super seed torrent:", torrent["name"])
|
||||||
result.append(True)
|
return True
|
||||||
else:
|
else:
|
||||||
self.console.error("❌ Failed to stop torrent :" , torrent['name'])
|
self.console.error("❌ Failed to set super seed torrent:", torrent["name"])
|
||||||
result.append(False)
|
return False
|
||||||
return all(result)
|
|
||||||
|
self.console.warn(f"Not found {rename} in qBittorrent. Super seed will not set")
|
||||||
|
return False
|
||||||
|
|
||||||
class BearBit:
|
class BearBit:
|
||||||
"""Class to interact with BearBit API"""
|
"""Class to interact with BearBit API"""
|
||||||
@@ -220,13 +228,12 @@ class BearBit:
|
|||||||
if not await self.check_login():
|
if not await self.check_login():
|
||||||
await self.login()
|
await self.login()
|
||||||
|
|
||||||
|
# response = await self.retry(self.session.get, url, headers=headers, verify=False)
|
||||||
url = f"{self.baseurl}/toserv.php"
|
url = f"{self.baseurl}/toserv.php"
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'User-Agent': self.user_agent
|
'User-Agent': self.user_agent
|
||||||
}
|
}
|
||||||
|
|
||||||
# response = await self.retry(self.session.get, url, headers=headers, verify=False)
|
|
||||||
async with self.session.get(url, headers=headers, verify_ssl=False) as response:
|
async with self.session.get(url, headers=headers, verify_ssl=False) as response:
|
||||||
# await response.text()
|
# await response.text()
|
||||||
|
|
||||||
@@ -237,6 +244,8 @@ class BearBit:
|
|||||||
soup = BeautifulSoup(text, 'html.parser')
|
soup = BeautifulSoup(text, 'html.parser')
|
||||||
passkey_field = soup.find('input', {'name': 'passk'})
|
passkey_field = soup.find('input', {'name': 'passk'})
|
||||||
self.TRACKER_BEARBIT = passkey_field.get('value')
|
self.TRACKER_BEARBIT = passkey_field.get('value')
|
||||||
|
# return TRACKER_BEARBIT
|
||||||
|
# self.TRACKER_BEARBIT = await self.retry(get_tracker_bb)
|
||||||
|
|
||||||
async def upload_torrent(self,name:str,sdescr:str,poster_url:str,category:str,imdburl:str,source_type:str,codec:str,standard:str,country:str,source:str,original_platform:int,tracktype:str,torrent_file_path,description:str):
|
async def upload_torrent(self,name:str,sdescr:str,poster_url:str,category:str,imdburl:str,source_type:str,codec:str,standard:str,country:str,source:str,original_platform:int,tracktype:str,torrent_file_path,description:str):
|
||||||
"""Upload a torrent file to BearBit"""
|
"""Upload a torrent file to BearBit"""
|
||||||
@@ -440,6 +449,7 @@ class BearBit:
|
|||||||
self.console.warn(f"Error: {e}. Retrying...")
|
self.console.warn(f"Error: {e}. Retrying...")
|
||||||
attempts += 1
|
attempts += 1
|
||||||
await asyncio.sleep(delay_seconds) # If using asyncio, replace with await asyncio.sleep(delay_seconds)
|
await asyncio.sleep(delay_seconds) # If using asyncio, replace with await asyncio.sleep(delay_seconds)
|
||||||
|
self.console.error("Max retry attempts reached.")
|
||||||
raise Exception("Max retry attempts reached.")
|
raise Exception("Max retry attempts reached.")
|
||||||
|
|
||||||
class TorrentDD:
|
class TorrentDD:
|
||||||
@@ -1096,8 +1106,9 @@ class TorrentUpload(TorrentCreator):
|
|||||||
# for torrent_all in torrent.torrent_path["all"]:
|
# for torrent_all in torrent.torrent_path["all"]:
|
||||||
name = await rename(torrent.metadata[0], torrent.torrent_path["all"], is_movie,pack=pack,tmdb_response=tmdb_response_eng)
|
name = await rename(torrent.metadata[0], torrent.torrent_path["all"], is_movie,pack=pack,tmdb_response=tmdb_response_eng)
|
||||||
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(1)
|
# await asyncio.sleep(5)
|
||||||
await self.qbit.set_super_seed(name)
|
self.console.debug(f"qBittorrent name : {name}")
|
||||||
|
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
|
||||||
# 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']}")
|
||||||
|
|||||||
Reference in New Issue
Block a user