Skip to content

Instantly share code, notes, and snippets.

@shajidhasan
Last active May 5, 2022 05:06
Show Gist options
  • Save shajidhasan/186b808de6408ecd2b5b314a99f41dd5 to your computer and use it in GitHub Desktop.
Save shajidhasan/186b808de6408ecd2b5b314a99f41dd5 to your computer and use it in GitHub Desktop.

LipiGhor font downloading script

I needed some Bengali fonts for a project and I found it quite tiresome to download multiple fonts quickly from LipiGhor. One of the reasons being the buttons on the preview cards are not actually anchor tags so you can't open the fonts in multiple tabs.

So I wrote a PYTHON script. It should download all of the fonts available in the website pretty quickly. You may need to run pip install requests before executing the script.

There's also a FontBD downloader script I wrote.

# LipiGhor font downloader

import re
import requests
import pathlib

OUTPUT_FOLDER = "lipighor_fonts"
URL = "https://lipighor.com/freefont.html?page=1"
DOWNLOAD_URL = "https://lipighor.com/download/"
REGEX = ".href=\'(.*).html\'"

html = requests.get(URL).text

for font in re.findall(REGEX, html):
    res = requests.get(DOWNLOAD_URL + font + ".zip", stream=True)
    folder = pathlib.Path(OUTPUT_FOLDER)
    folder.mkdir(exist_ok=True)
    with open((folder / font).with_suffix(".zip"), "wb") as file:
        for chunk in res.iter_content(chunk_size=512):
            if chunk:
                file.write(chunk)

        print("Downloaded:" + font.rjust(40))
    
print("Done!")

The script is this much simple because, for some reason, a single HTML page actually holds all the font names. Only a portion of them(according to the page number) is displayed.

IMPORTANT: There are copyright rules and some conditions of these fonts. Please read here. I am not responsible for anything you do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment