-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmelovaz_album_downloader.py
57 lines (47 loc) · 1.92 KB
/
melovaz_album_downloader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import requests as re
from bs4 import BeautifulSoup as bs
from zipfile import ZipFile
import os
url = input("Enter url of album that u want download:\n")
# url = "https://melovaz.net/this-is-dua-lipa"
inf_album = bs(re.get(url).text, 'html.parser')
print("[*] Please w8!")
print("[*] Getting album title...")
album_title = inf_album.select(".AL-Si")[0].text
album_by = inf_album.select(".AR-Si")[0].text
print("### Album Title: %s"%album_title)
print("### %s\n"%album_by)
print("[*] Getting album musics title...")
album_musics= inf_album.select('[data-title]')
for i in album_musics:
print("### %s"%i['data-title'])
print("")
print("[*] Getting album musics url...")
musics_urls = inf_album.select('.audioplayer-source')
print("[*] Done!\n")
os.mkdir(album_title)
print("[*] Starting download musics...")
for i in range(len(album_musics)):
print("[*] Downloading %s..."%album_musics[i]['data-title'])
music_download = re.get(musics_urls[i]['data-src'])
with open('%s/%s.mp3'%(album_title, album_musics[i]['data-title']), 'wb') as music:
music.write(music_download.content)
print("[*] %s Downloaded successfully!"%album_musics[i]['data-title'])
print("")
print("\n[*] All musics downloaded successfully!")
print("-------------------------------------------------------------------")
print("[*] Creating zip file, as '%s.zip'"%album_title)
with ZipFile("%s.zip"%album_title, "w") as music_zip_file:
for each_music in album_musics:
print("[*] Adding %s.mp3 \t into %s.zip..."%(each_music['data-title'], album_title))
music_zip_file.write('%s/%s.mp3'%(album_title, each_music['data-title']))
print("[*] Done!\n")
print("[*] Deleting music files...")
try:
for m in album_musics:
print("[*] Deleting %s.mp3..."%m['data-title'])
os.remove('%s/%s.mp3'%(album_title, m['data-title']))
os.rmdir(album_title)
print("[*] Done!")
except:
print("[*] Cant Delete music files...")