{"id":25619662,"url":"https://github.com/lazza/bitlyescape","last_synced_at":"2026-02-25T18:38:04.546Z","repository":{"id":277898766,"uuid":"933799512","full_name":"Lazza/BitlyEscape","owner":"Lazza","description":"Easily back up your Bitly data and prepare it for seamless import into YOURLS","archived":false,"fork":false,"pushed_at":"2025-02-16T20:55:57.000Z","size":20,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-19T06:40:45.434Z","etag":null,"topics":["backup","bitly","bitly-api","yourls"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Lazza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"thelazza"}},"created_at":"2025-02-16T18:03:51.000Z","updated_at":"2025-06-10T08:52:08.000Z","dependencies_parsed_at":"2025-02-16T21:39:10.451Z","dependency_job_id":null,"html_url":"https://github.com/Lazza/BitlyEscape","commit_stats":null,"previous_names":["lazza/bitlyescape"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Lazza/BitlyEscape","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lazza%2FBitlyEscape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lazza%2FBitlyEscape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lazza%2FBitlyEscape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lazza%2FBitlyEscape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lazza","download_url":"https://codeload.github.com/Lazza/BitlyEscape/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lazza%2FBitlyEscape/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29834631,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T17:57:15.019Z","status":"ssl_error","status_checked_at":"2026-02-25T17:56:11.472Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","bitly","bitly-api","yourls"],"created_at":"2025-02-22T06:19:21.283Z","updated_at":"2026-02-25T18:38:04.529Z","avatar_url":"https://github.com/Lazza.png","language":"Python","funding_links":["https://ko-fi.com/thelazza"],"categories":[],"sub_categories":[],"readme":"# Bitly Escape (for YOURLS migration)\n\nThis is a collection of Python scripts aimed at helping you escape from Bitly.\n\nStarting from February 2025, Bitly began **inserting unwanted ads** on free\naccounts, by [adding an interstitial page][bitly_ads] to links shared from free\naccounts.\n\nFor those using a custom domain, this is especially bad because users may assume\nthat ads are run by the domain's owner rather than Bitly. Ads are generally a\nnegative experience for users, because they are annoying and they may come with\nmalware or other unwanted content.\n\n[YOURLS][yourls] is a very popular self-hosted option for those wanting to run\ntheir own free URL shortening service. Unfortunately, there is no direct way to\nimport Bitly data into YOURLS, however, its plugin-based architecture allows\nusers to add additional features, including data import.\n\nThis repository includes software mainly aimed at exporting data from Bitly,\nwhile converting it in a format that can be imported via the\n[YOURLS-Import-Export][import_export] plugin.\n\n\n## How to use\n\nFirst of all, make sure you are running an up-to-date version of YOURLS\nconfigured to run on your custom domain name.\n\n**Note:** in order to ensure uninterrupted service, do not migrate your domain's\nDNS away from Bitly yet. Update the DNS record on your PC by editing the `hosts`\nfile for now.\n\n### Get group ID and token\n\nLog in to Bitly and look at the URL: you will see your \"group ID\". Go to the\nsettings page and [generate an access token][access_token].\n\n### Set up the scripts\n\nIf you wish to, activate a _virtualenv_. Then install the requirements:\n\n    pip install -r requirements.txt\n\nCopy the `config.example.py` file to `config.py` and edit it to include your\nBitly access token and your group ID.\n\n### Export links from Bitly\n\nYou are now ready to grab all the links from Bitly and store the data safely in\na SQLite database.\n\nRun the following command:\n\n    python bitly_escape.py\n\nThe script will download links in batches of 50 at a time. If you get rate\nlimited due to excessive API usage, it will sleep for 1 minute and then try\nagain until all the links have been collected.\n\nIt is very important that the computer remains connected to the Internet during\nthe process.\n\nYou will get a SQLite file called `bitly_links.db` as a result.\n\n### Optional: export engagement data\n\nIf you wish to retain the overall number of clicks each link has received,\naccording to Bitly, you need to execute the second script.\n\nSimply run this command:\n\n    python populate_clicks.py\n\nWait until it's done and the SQLite file will be updated accordingly.\n\n### Generate the XML import file\n\nWith all links safely backed up in the SQLite database, you can generate the\n**XML file needed for importing the data into YOURLS.**\n\nRun the following command:\n\n    python generate_xml.py\n\nThe script will output the total number of links and generate a new file called\n`bitly_links.xml`.\n\n\n## Importing data into YOURLS\n\n**Note:** before importing data, it is suggested to check if your Bitly links\nuse aliases compatible with your character settings. If needed, several YOURLS\nplugins allow you to change the allowed character set.\n\nThe XML file generated by the last script can be imported using the\n[YOURLS-Import-Export][import_export] plugin. Please refer to the documentation\nof said plugin for additional information.\n\nVery large collections of links may need to be broken down into several parts.\nPlease read the following remarks for more details.\n\nOnce you are done, you can point the DNS record of your domain to your new\nYOURLS installation and install a valid TLS certificate. Links should work as\nexpected!\n\n\n## Additional remarks\n\nIt is worth noting that the script gathers all links from your account, even if\nthey are _not_ using a custom domain name. You might want to filter the SQLite\ndatabase manually, depending on your needs.\n\nFor custom-assigned Bitly aliases (e.g. `MyFancyName`) Bitly creates a random\nlink alias as well. The script does not create an entry for this, only the\ncustom alias is stored.\n\nIf you have a large number of links, the XML import process may time out and the\nweb page could show a Server Error. In my testing, the process still continued\nto import all data in the background, but this may depend on server settings.\n\nThis was tested with roughly 2200 links.\n\nYou can see the total number of links from the YOURLS interface. If you are in\ndoubt, consider splitting the SQLite database into different files and\ngenerating multiple XML files for separate imports.\n\nThere will be a delay between the time you grab the number of clicks on links\nand when you are done with the migration. If your links are very active, they\nmay get additional clicks recorded on Bitly.\n\nYou can export the engagement data again after your new YOURLS installation has\ngone live, but this topic is beyond the scope of this guide.\n\nFinally, keep in mind that YOURLS does not comply with the GDPR using standard\nsettings, as it keeps full logs of IP addresses, user-agent strings and\nreferers. You may either disable logging, or consider using anonymization\nplugins that may redact some of the data.\n\nVerify the database tables and ensure that the data is properly sanitized.\n\n\n## Acknowledgments\n\nThe development of this project has been significantly accelerated with the\nassistance of [Le Chat][le_chat], an AI tool used to draft large portions of the\ncode.\n\n\n\n  [bitly_ads]: https://support.bitly.com/hc/en-us/articles/32874287800333-Why-are-there-ads-on-my-links\n  [yourls]: https://yourls.org\n  [import_export]: https://github.com/GautamGupta/YOURLS-Import-Export\n  [access_token]: https://app.bitly.com/settings/api/\n  [le_chat]: https://chat.mistral.ai/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flazza%2Fbitlyescape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flazza%2Fbitlyescape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flazza%2Fbitlyescape/lists"}