Last active
April 23, 2018 15:33
-
-
Save shakram02/01107afacddde40a519b6e3f4463d1dc to your computer and use it in GitHub Desktop.
Downloads quraan for a specified reciter from althkr.com (the script isn't by any means optimized, but it just works)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
import sys | |
counter = 0 | |
def main(start, end): | |
""" | |
To get the list of reciters, visit this link http://althkr.com/Reciters.php | |
Note that the folder will be downloaded in the current directory. Make sure you have space | |
and that you can handle the clutter. I suggest running the script in an empty folder | |
""" | |
global counter | |
mod_start = max(start, end) | |
mod_end = min(start, end) | |
reciter_name = "Mohamed_Ayoub" | |
# The range is reversed to download shorter surahs first | |
for i in reversed(range(mod_start, mod_end + 1)): | |
number = str(i).zfill(3) | |
url = "http://www.archive.org/download/{}}/{}.mp3".format( | |
reciter_name, number) | |
print("Downloading #", number) | |
urllib.request.urlretrieve(url, "{}.mp3".format(number)) | |
print("Done...") | |
counter = i | |
if __name__ == '__main__': | |
try: | |
main(110,114) # Start and end surah index (1-indexed) | |
except KeyboardInterrupt: | |
print('Interrupted') | |
# In case the program is stopped, save where it stopped | |
f = open('terminated_at.txt', 'w') | |
f.write(counter) | |
f.close() | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment