From b0cfefec8a21e2e7f72bd2dc735d87c92a0b4eef Mon Sep 17 00:00:00 2001 From: akhi07rx <89210430+akhi07rx@users.noreply.github.com> Date: Mon, 5 Jun 2023 03:17:22 +0530 Subject: [PATCH] updated --- CoLab_torrent_downloader.ipynb | 11 ++++++----- README.md | 8 +++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CoLab_torrent_downloader.ipynb b/CoLab_torrent_downloader.ipynb index 5ad007f..eb01790 100644 --- a/CoLab_torrent_downloader.ipynb +++ b/CoLab_torrent_downloader.ipynb @@ -46,7 +46,6 @@ "import time\n", "from google.colab import drive\n", "from tqdm import tqdm\n", - "import re\n", "\n", "drive.mount('/content/drive')\n", "\n", @@ -60,9 +59,8 @@ " 'storage_mode': lt.storage_mode_t.storage_mode_sparse,\n", "}\n", "\n", - "magnet_link_pattern = r'^magnet:\\?xt=urn:btih:[a-zA-Z0-9]{32,40}.*'\n", - "\n", "while True:\n", + " print()\n", " link = input(\"Enter the magnet link (or 'exit' to quit): \")\n", " if link.lower() == 'exit':\n", " break\n", @@ -73,7 +71,7 @@ "\n", " handle = lt.add_magnet_uri(ses, link, params)\n", "\n", - " print(\"Downloading Metadata...\")\n", + " print(\"\\nDownloading Metadata...\")\n", " while not handle.has_metadata():\n", " time.sleep(1)\n", " print(\"Got Metadata, Starting Torrent Download...\")\n", @@ -102,9 +100,12 @@ " total_time_seconds = end_time - start_time\n", " total_time_minutes = total_time_seconds / 60\n", "\n", - " print(f\"File name: {torrent_info.name()}\")\n", + " num_files = torrent_info.num_files()\n", + "\n", + " print(f\"\\nFile name: {torrent_info.name()}\")\n", " print(f\"File size: {file_size_str}\")\n", " print(f\"Total Time: {total_time_seconds:.2f} seconds / {total_time_minutes:.2f} minutes\")\n", + " print(f\"Number of files: {num_files}\")\n", " print(f\"Saved location: {save_path}\")\n" ] } diff --git a/README.md b/README.md index 6f6a245..ca15cca 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ This code allows you to download torrents directly to your Google Drive using Go - Download torrents from magnet links - Save downloaded files to a specified location on Google Drive - Display a progress bar and information about the downloaded file +- Prompt the user to enter the magnet link or exit +- Handle incorrect inputs and display error messages ## Prerequisites @@ -17,9 +19,9 @@ This code allows you to download torrents directly to your Google Drive using Go 1. Open the code in Google Colab. 2. Run the first cell to install the `libtorrent` library and mount your Google Drive. -3. Change the `link` variable to the magnet link of the torrent you want to download. -4. Change the `save_path` parameter to the location on your Google Drive where you want to save the downloaded file. -5. Run the rest of the code to start the torrent download. +3. When prompted, enter the magnet link of the torrent you want to download or 'exit' to quit. +4. If you enter an invalid magnet link, the code will display an error message and prompt you to try again. +5. The code will download the torrent and display a progress bar and information about the downloaded file. ## Code Components