Skip to main content

This will extract the Google Drive file ID from any provided Google Drive link, making it easy to retrieve the ID programmatically. It's lightweight, simple to use, and supports various Google Drive link formats.

Project description

google-drive-id-extractor

google-drive-id-extractor is a simple Python package that allows users to easily extract the Google Drive ID from any Google Drive file URL. This package uses regular expressions to find and extract the file ID from various formats of Google Drive links.

Features

  • Extract Google Drive file ID from multiple link formats
  • Lightweight and simple to use
  • Works with various types of Google Drive links, such as shareable links and embedded links

Installation

To install the google-drive-id-extractor package, use the following command:

pip install google-drive-id-extractor

Usage

After installing the package, you can start using it by importing the extract_google_drive_id function. Here's a simple example of how to extract a Google Drive file ID from a link:

from google_drive_id_extractor import extract_google_drive_id

# Example Google Drive URL
drive_link = "https://drive.google.com/file/d/1A2B3C4D5E6F7G8H9I0J/view?usp=sharing"

# Extract the Google Drive file ID
file_id = extract_google_drive_id(drive_link)

# Output the result
print(f"The Google Drive ID is: {file_id}")

This will extract the file ID from a Google Drive link and print it. The function handles different link formats, including:

  • https://drive.google.com/file/d/[fileID]/view?usp=sharing
  • https://drive.google.com/open?id=[fileID]
  • https://drive.google.com/uc?id=[fileID]

Supported Link Formats

The package is capable of extracting the Google Drive file ID from the following types of URLs:

  1. Direct file URLs:
    Example:
    https://drive.google.com/file/d/1A2B3C4D5E6F7G8H9I0J/view?usp=sharing

  2. Embedded URLs:
    Example:
    https://drive.google.com/embeddedfolderview?id=1A2B3C4D5E6F7G8H9I0J

  3. Open links with the file ID as a parameter:
    Example:
    https://drive.google.com/open?id=1A2B3C4D5E6F7G8H9I0J

Function

extract_google_drive_id(drive_link)

  • Description: This function extracts and returns the Google Drive file ID from a provided Google Drive URL.
  • Parameters:
    • drive_link (str): The Google Drive URL from which to extract the file ID.
  • Returns:
    • str: The extracted Google Drive file ID, or None if no valid ID is found.

Example

# Example with different formats
links = [
    "https://drive.google.com/file/d/1A2B3C4D5E6F7G8H9I0J/view?usp=sharing",
    "https://drive.google.com/open?id=1A2B3C4D5E6F7G8H9I0J",
    "https://drive.google.com/embeddedfolderview?id=1A2B3C4D5E6F7G8H9I0J"
]

for link in links:
    file_id = extract_google_drive_id(link)
    print(f"Extracted File ID: {file_id}")

License

This package is licensed under the MIT License.

About

This package is provided by ToolsForFree.com. ToolsForFree.com provides a variety of helpful utilities to make working with Google Drive and other services more convenient.

If you're looking to convert Google Drive shareable links into direct download links, be sure to check out our Google Drive Direct Link Generator.


Author

  • ToolsForFree.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

google_drive_id_extractor-1.2.0.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

google_drive_id_extractor-1.2.0-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file google_drive_id_extractor-1.2.0.tar.gz.

File metadata

File hashes

Hashes for google_drive_id_extractor-1.2.0.tar.gz
Algorithm Hash digest
SHA256 7157246d73fd537215d8639063c7a3897adb3a2a37178fc0a682826a1ee232e4
MD5 bb66249f87379ce1269a5e91f8b80e30
BLAKE2b-256 86482395979a293934b7f0e9426e1d433acf416fea77db5a1e3b3e619fb7be88

See more details on using hashes here.

File details

Details for the file google_drive_id_extractor-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for google_drive_id_extractor-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d639ad6d4f78131679bc53c199793085f989c259f1c96f6e9d938ee6543bd4c4
MD5 ceb2a5db1362729a33e9c1d253f96561
BLAKE2b-256 2ddcff661df08bb2816410cde49556c52b584dfe425f8e2fd68fa6f1d6915050

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page