fix: resume progress because my friend has too many favorites and got api rate limited

This commit is contained in:
6arelyFuture 2024-09-05 13:47:20 +02:00
parent 9409295f39
commit 7c25a2d364
Signed by: Future
GPG Key ID: F2000F181A4F7C85

View File

@ -135,19 +135,24 @@ def get_torrents():
print("Please edit set.yaml") print("Please edit set.yaml")
exit() exit()
output_dir = "torrents"
os.makedirs(output_dir, exist_ok=True) # Create the directory if it doesn't exist
for url in url_list: for url in url_list:
torrent_url = url torrent_url = url
# Call wtfcloudflare to download the torrent file torrent_id = url.split('/')[4] # The ID is in the 4th segment of the URL
response = wtfcloudflare_t(torrent_url, useragent=useragent, cookie=cookie) torrent_path = os.path.join(output_dir, f"{torrent_id}.torrent")
# Extract the ID from the URL for naming the file # Extract the ID from the URL for naming the file
torrent_id = url.split('/')[4] # The ID is in the 4th segment of the URL torrent_id = url.split('/')[4] # The ID is in the 4th segment of the URL
# Define the output directory and file name # Skip downloading if the torrent file already exists
output_dir = "torrents" if os.path.exists(torrent_path):
os.makedirs(output_dir, exist_ok=True) # Create the directory if it doesn't exist print(f"Torrent file already exists: {torrent_path}")
torrent_path = os.path.join(output_dir, f"{torrent_id}.torrent") continue
response = wtfcloudflare_t(torrent_url, useragent=useragent, cookie=cookie)
# Save the torrent file to disk # Save the torrent file to disk
with open(torrent_path, 'wb') as torrent_file: with open(torrent_path, 'wb') as torrent_file: