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=sharinghttps://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:
-
Direct file URLs:
Example:
https://drive.google.com/file/d/1A2B3C4D5E6F7G8H9I0J/view?usp=sharing -
Embedded URLs:
Example:
https://drive.google.com/embeddedfolderview?id=1A2B3C4D5E6F7G8H9I0J -
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, orNoneif 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file google_drive_id_extractor-1.2.0.tar.gz.
File metadata
- Download URL: google_drive_id_extractor-1.2.0.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7157246d73fd537215d8639063c7a3897adb3a2a37178fc0a682826a1ee232e4
|
|
| MD5 |
bb66249f87379ce1269a5e91f8b80e30
|
|
| BLAKE2b-256 |
86482395979a293934b7f0e9426e1d433acf416fea77db5a1e3b3e619fb7be88
|
File details
Details for the file google_drive_id_extractor-1.2.0-py3-none-any.whl.
File metadata
- Download URL: google_drive_id_extractor-1.2.0-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d639ad6d4f78131679bc53c199793085f989c259f1c96f6e9d938ee6543bd4c4
|
|
| MD5 |
ceb2a5db1362729a33e9c1d253f96561
|
|
| BLAKE2b-256 |
2ddcff661df08bb2816410cde49556c52b584dfe425f8e2fd68fa6f1d6915050
|