Skip to content

Instantly share code, notes, and snippets.

@suhailvs
Created March 11, 2020 04:47
Show Gist options
  • Save suhailvs/6ca882c7a3677713a0f6ee66978bebb7 to your computer and use it in GitHub Desktop.
Save suhailvs/6ca882c7a3677713a0f6ee66978bebb7 to your computer and use it in GitHub Desktop.
Download quran audio
import urllib.request
import os
from xml.dom.minidom import parse, parseString
def download(sura, ayas):
print(sura)
for aya in range(1, ayas+1):
fname = f'{sura:03}{aya:03}.mp3'
if not os.path.isfile(fname):
url = f'http://www.everyayah.com/data/Hudhaify_128kbps/{sura:03}{aya:03}.mp3'
urllib.request.urlretrieve(url, fname)
if __name__=='__main__':
d = parse('quran-data.xml')
suras = d.getElementsByTagName('sura')
for s in suras:
sura = int(s.getAttribute('index'))
ayas = int(s.getAttribute('ayas'))
download(sura, ayas)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment