Skip to main content

Google Drive Link Fixer

Project description

GitHub PyPI PyPI - Status GitHub last commit GitHub issues PyPI - Downloads GitHub repo size PyPI - Python Version


glinkfix


glinkfix logo

Google Drive Link Fixer

Notes (please read)

  1. Google periodically changes how Drive links are handled, which can affect tools like glinkfix. Direct downloading and embedding Google Drive links is unsupported behavior as far as Google is concerned. As of January 2024, Google made a significant change that broke some links created with this tool. glinkfix now accepts current Drive file link formats such as usp=drive_link, but future Google changes may break link handling again.

  2. Viewing links that point to animated GIFs may appear as static images.

  3. In the v2 update, in addition to displaying the fixed link on the screen, glinkfix will also attempt to copy the fixed link to the clipboard. Copying to the clipboard only works for desktop operating systems, not server environments. Even without automatic copying, link fixing will still work and the results will be displayed on the screen, regardless of where you run it. glinkfix uses the pyperclip library, and automatic copying to the clipboard should work seamlessly on Windows and macOS. If you're running Linux and links are not automatically copied to the clipboard, refer to this note from the pyperclip documentation.

  4. glinkfix is tested on Linux, macOS, and Windows in continuous integration. Clipboard behavior still depends on the local desktop or server environment.

Installation

The preferred way to install glinkfix is with pipx:

pipx install glinkfix

You can also install glinkfix as a tool with uv:

uv tool install glinkfix

Alternatively, you can create a separate virtual environment and install it the traditional way:

pip3 install glinkfix

If you just need a quick one-time link fix and don't want to commit to a full installation, use:

pipx run glinkfix -h

and follow the directions to run it again with the option you want.

Purpose and Usage

When you share files with Google Drive, the sharing link you get is intended primarily for accessing the content through a web browser. glinkfix supports Google Drive file links such as https://drive.google.com/file/d/<file-id>/view?usp=drive_link, .../preview, and bare /file/d/<file-id> links. If you want to use a Google Drive file sharing link to embed an image in a document (e.g. in a Markdown or HTML file), or you want to directly download a file pointed to by a Google Drive sharing link using something like curl or wget in Linux, the link needs to be adjusted ("fixed") for these purposes.

It's not especially hard to repackage the link, but it can be tedious. You have to copy the link to a text editor, carve it up manually, and reassemble it. If you've got a lot of links to deal with, the process gets repetitive. This tool is designed to remove that tedium.

Note: The images below demonstrate Google Drive sharing links and their "fixed" equivalents.


Start by getting a sharing link to a file on Google Drive. Make sure it's set up for public access (Anyone with the link):

Getting Link


Copying Link

Now run glinkfix with the sharing link:

glinkfix "https://drive.google.com/file/d/<file-id>/view?usp=drive_link"

By default, glinkfix creates an embeddable link, prints the result, and attempts to copy the fixed link to the clipboard. To create a direct-download link instead, use:

glinkfix --download "https://drive.google.com/file/d/<file-id>/view?usp=drive_link"

For shell scripts, use --quiet to print only the converted URL:

glinkfix --quiet "https://drive.google.com/file/d/<file-id>/view?usp=drive_link"

To print the normal output without copying to the clipboard, use:

glinkfix --no-copy "https://drive.google.com/file/d/<file-id>/view?usp=drive_link"

If you run glinkfix without a URL, it prompts for one interactively. Press Ctrl-C at the prompt to exit cleanly.


To display the help menu, run: glinkfix -h

usage: glinkfix [-h] [-d] [--no-copy] [--quiet] [-v] [url]

Convert a Google Drive file sharing link into a link suitable for
embedding in a document, such as an image in Markdown or HTML, or for
direct download, such as with curl. glinkfix accepts current Drive file
link formats such as usp=drive_link and uses Python's standard-library
URL parser for lightweight, dependency-minimal processing. Google Drive
links used this way have a single-file size limit of 40 MB.

positional arguments:
  url             Google Drive file sharing link to convert. If omitted,
                  prompt for one.

options:
  -h, --help      show this help message and exit
  -d, --download  Create a direct-download link instead of the default
                  embeddable link.
  --no-copy       Do not copy the converted link to the clipboard.
  --quiet         Print only the converted link and skip clipboard copying.
  -v, --version   show program's version number and exit

Usage Notes

  • There is a 40 MB size limit for a single file when using Google Drive sharing links directly for viewing or downloading. Individual files larger than 40 MB will not render or download properly. This limit is a function of how Google Drive works and is not related to glinkfix.
  • When creating a download link for use with curl, make sure to use curl's -L option to allow for redirects.
  • glinkfix supports current Google Drive file sharing links, including usp=drive_link, usp=drivesdk, usp=sharing, and usp=share_link.
  • glinkfix supports links that use Google's resource key security feature and preserves the resource key in fixed links.
  • glinkfix supports Drive file links only. It does not convert Google Drive folder links or native Google Docs, Sheets, or Slides editor links.
  • The link parser uses Python's standard-library URL parsing tools for lightweight, dependency-minimal processing. New dependencies are acceptable when they provide a clear correctness, performance, or maintainability benefit.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

This project uses the pyperclip library, an external dependency licensed under the BSD 3-Clause License. See the pyperclip project for license details.

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

glinkfix-2.2.1.tar.gz (701.3 kB view details)

Uploaded Source

Built Distribution

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

glinkfix-2.2.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file glinkfix-2.2.1.tar.gz.

File metadata

  • Download URL: glinkfix-2.2.1.tar.gz
  • Upload date:
  • Size: 701.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for glinkfix-2.2.1.tar.gz
Algorithm Hash digest
SHA256 d59751fcab94c83ba2252fe221c90eadda7eeff113ab71e14e55f6f7daa26670
MD5 0d96c33e1b471260b58247a1b3444974
BLAKE2b-256 d09bb2d3954da1a77651234cc2bce533556100649b94d47ed32f76e0b2a87cb8

See more details on using hashes here.

File details

Details for the file glinkfix-2.2.1-py3-none-any.whl.

File metadata

  • Download URL: glinkfix-2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for glinkfix-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 86e93b129af8d7b644e21ea9a4bdce23407bb51abbd7487a49c8b23edcf4e48b
MD5 426145991257cd6b6fd7c145ee7ad640
BLAKE2b-256 fbd92f117f04851a07120884ea156c742caada0fa21205d8cedc968dc03859a6

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