Skip to main content

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.

Development and releases

Pull-request titles use Conventional Commits. User-visible types are feat, change, deprecate, remove, fix, security, perf, deploy, docs, revert, and dependency-scoped build(deps...) or chore(deps...). Routine build, chore, ci, refactor, style, and test changes are hidden from release notes unless marked as breaking with !.

Preview pending user-visible entries with:

just changelog

Prepare a release from a clean branch with a canonical version such as 2.2.3, 2.2.3b1, or 2.2.3rc1:

just bump 2.2.3
just check
just build
git add CHANGELOG.md changelogs pyproject.toml uv.lock
git commit -m "chore(release): prepare for 2.2.3"

just bump requires at least one user-visible change. A release-preparation chore(release) commit is hidden and does not satisfy that requirement.

After merging the release-preparation commit, update local main and run just tag-release. It pushes one annotated v<version> tag. Prereleases publish to TestPyPI and create GitHub prereleases; stable releases publish to PyPI and create stable GitHub Releases. Only successful stable releases move the mutable latest tag.

The release workflow uses PyPI Trusted Publishing. Before the first release, configure pending publishers for this repository in TestPyPI and PyPI using the release.yml workflow and the testpypi and pypi GitHub environments. Allow the workflow to force-update the mutable latest tag; do not attach a GitHub Release to that tag.

Dependabot checks direct Python and GitHub Actions dependencies weekly. It groups eligible Python minor and patch updates, and automatically enables squash auto-merge only for Dependabot-authored direct minor or patch updates without maintainer changes. Major and otherwise ineligible updates require manual review.

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.

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.3.tar.gz (707.5 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.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: glinkfix-2.2.3.tar.gz
  • Upload date:
  • Size: 707.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for glinkfix-2.2.3.tar.gz
Algorithm Hash digest
SHA256 1d2301359a3e4ded080252da264d8330985bb38544b0564e3910dce28b7b1780
MD5 8541e8fe43143348ce4d4e2a1af7b9d5
BLAKE2b-256 f88dbeb988f8b8ae8ac6041e363b9145164295a679ab053da8311cd4cf405aad

See more details on using hashes here.

Provenance

The following attestation bundles were made for glinkfix-2.2.3.tar.gz:

Publisher: release.yml on geozeke/glinkfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: glinkfix-2.2.3-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for glinkfix-2.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 64e49bcd3483f09693fde2231e53735c919e6c3fc2f1b72df414fa1d9cff257a
MD5 92cff61fd9eb1e2aeca58a319431d906
BLAKE2b-256 9260525c46a20fe40a6260b4805acdb714a7739678347a15b217917d956baf2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for glinkfix-2.2.3-py3-none-any.whl:

Publisher: release.yml on geozeke/glinkfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.2.3 This release

2 files

2.2.2

2 files

2.2.1

2 files

2.2.0

2 files

2.1.0

2 files

2.0.11

2 files

2.0.10

2 files

2.0.9

2 files

2.0.8

2 files

2.0.7

2 files

2.0.6

2 files

2.0.5

2 files

2.0.4

2 files

2.0.3

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.2.1

2 files

1.2.0

2 files

1.0.16

2 files

1.0.15

2 files

1.0.14

2 files

1.0.13

2 files

1.0.12

2 files

1.0.11

2 files

1.0.9

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

Supported by

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