Go to file
Anas Rashid 69db6fa2af
Some checks are pending
Wikisource sync / sync (push) Waiting to run
Divan-owned details (#32): the export prefers divan/<url>.poet (name, pen name, years, intro) and .book (title) published in Divan
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 01:06:35 +02:00
.gitea/workflows Rename export_ganjoor.py -> export_divan.py, ganjoor_ids -> divan_ids; Language ur-PK 2026-10-04 23:51:03 +02:00
divan ای بک: مرزا غالب، دیوان غالب: نئی ای بک (ورژن 1) 2026-10-09 22:19:27 +00:00
export Treat works in poetry sections as poetry even without <poem> markup 2026-10-08 20:51:41 +02:00
index Merge duplicate author pages via resolved Wikipedia article (#7) 2026-10-05 00:32:32 +02:00
poets Ghazal marks: radif, matla, maqta (takhallus sign) and radif letter for divan contents 2026-10-08 21:27:22 +02:00
.gitignore Divan: classical Urdu poetry & prose from Urdu Wikisource 2026-10-04 22:48:40 +02:00
build_index.py Urdu only: drop English Wikipedia intros (intro_ur -> intro) 2026-10-04 22:52:15 +02:00
divan.db Ghazal marks: radif, matla, maqta (takhallus sign) and radif letter for divan contents 2026-10-08 21:27:22 +02:00
export_divan.py Divan-owned details (#32): the export prefers divan/<url>.poet (name, pen name, years, intro) and .book (title) published in Divan 2026-10-10 01:06:35 +02:00
languages.json Ganjoor-compatible export (manifest.json, poets/, index/) 2026-10-04 23:05:14 +02:00
LICENSE Licence: the data is CC BY-SA 4.0 (LICENSE), the scripts MIT (LICENSE-CODE); README lists what each covers 2026-10-09 17:41:09 +02:00
LICENSE-CODE Licence: the data is CC BY-SA 4.0 (LICENSE), the scripts MIT (LICENSE-CODE); README lists what each covers 2026-10-09 17:41:09 +02:00
manifest.json Ghazal marks: radif, matla, maqta (takhallus sign) and radif letter for divan contents 2026-10-08 21:27:22 +02:00
metres.json Ganjoor-compatible export (manifest.json, poets/, index/) 2026-10-04 23:05:14 +02:00
README.md Licence: the data is CC BY-SA 4.0 (LICENSE), the scripts MIT (LICENSE-CODE); README lists what each covers 2026-10-09 17:41:09 +02:00
test_divan_details.py Divan-owned details (#32): the export prefers divan/<url>.poet (name, pen name, years, intro) and .book (title) published in Divan 2026-10-10 01:06:35 +02:00
test_divan_order.py Divan-owned order (#41): the export follows divan/<url>.order arrangements published in Divan 2026-10-09 14:02:24 +02:00
test_ghazal_marks.py Ghazal marks: radif, matla, maqta (takhallus sign) and radif letter for divan contents 2026-10-08 21:27:22 +02:00
update.sh Rename export_ganjoor.py -> export_divan.py, ganjoor_ids -> divan_ids; Language ur-PK 2026-10-04 23:51:03 +02:00
wikisource.py Treat works in poetry sections as poetry even without <poem> markup 2026-10-08 20:51:41 +02:00

دیوان · Divan

A local, searchable SQLite database of classical Urdu literature, both poetry and prose: ghazals, nazms, marsiyas, masnavis, letters, dastans and essays by poets and writers such as Mir, Sauda, Dard, Ghalib, Momin, Zauq, Dagh, Anees, Hali, Akbar Allahabadi, Allama Iqbal, Mir Amman, Sir Syed and Nazir Ahmad. Each author entry includes a short introduction.

Everything is in Urdu script.

Sources

  • Texts: Urdu Wikisource (ویکی ماخذ). The works are in the public domain ({{PD-old}}, {{PD-Pakistan}}, …), and the license tag is kept on every record.
  • Author intros: the lead section of each author's Urdu Wikipedia article.

Everything is fetched through the official MediaWiki API.

Database (divan.db)

table contents
poets page, name, years, birth_year, death_year, description, image, wikipedia, wikidata, intro, url
works title, poet_page, kind (poetry / prose), section (genre or book, e.g. شاعری > بانگ درا (1924)), year, text_ur, license, url
works_fts, poets_fts SQLite FTS5 full-text indexes

In poetry, lines are separated by \n and couplets or stanzas by a blank line.

Usage

python3 wikisource.py    # first build ~30 min; later runs fetch only pages edited since the last run
python3 build_index.py   # full-text index + export/poets.jsonl, export/works.jsonl

Python 3.9+ standard library only. (Search needs FTS5. Python's sqlite3 has it; Apple's built-in sqlite3 command does not, so use Python or brew install sqlite.)

A Gitea Actions workflow (.gitea/workflows/sync.yml) runs update.sh daily. It commits only when the data changed.

-- Iqbal's Bang-e-Dra
SELECT title, text_ur FROM works WHERE poet_page='مصنف:محمد اقبال' AND section LIKE '%بانگ درا%';

-- all prose
SELECT poet_page, title FROM works WHERE kind='prose';

-- full-text search
SELECT title, poet_page FROM works_fts WHERE works_fts MATCH 'خودی';

Site/API format (Ganjoor-compatible)

The repo root also holds the data in the ganjoor-data layout (manifest.json, poets/, index/, built by export_divan.py). It works as a static API over jsDelivr with no server:

https://cdn.jsdelivr.net/gh/anas-rashid/divan-data@main/manifest.json
https://cdn.jsdelivr.net/gh/anas-rashid/divan-data@main/poets/p238/_cat.json        # Iqbal

It also loads directly into GanjoorService through its "public data import" page: give it the base URL above. Poets are /p{id}, categories are a genre slug (ghazal, nazm, …) or c{id}, and poems are sh{id}. Ids stay stable across syncs. Poet years are converted to approximate Hijri, following Ganjoor's convention.

License

  • Data: CC BY-SA 4.0. Everything this repository publishes: divan.db, manifest.json, poets/, index/, export/, and divan/ (Divan's own moderated versions, arrangements, tags and e-book records). The literary works themselves are in the public domain; the compilation comes from Urdu Wikisource, Wikipedia and Divan's moderators. When reusing it, credit "Urdu Wikisource and Wikipedia contributors, and Divan" and share alike. Every record keeps its source url.
  • Code: MIT. The scripts (*.py, *.sh) and the sync workflow.