/
miner.py
36 lines (27 loc) · 840 Bytes
/
miner.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
import os,re,urllib2,sys
from bs4 import BeautifulSoup
# Search by tag
basePage = 'https://bandcamp.com/tag/'
# Prompt for a tag
tag = sys.argv[1]
# URL for albums w/ this tag
albumsByTag = basePage + tag
page = urllib2.urlopen(albumsByTag)
soup = BeautifulSoup(page, 'html.parser')
albumURLs = soup.find_all('a',{'href': re.compile('/album/[a-zA-Z0-9]*')})
for i in range(5):
print albumURLs[i]['href']
command = 'soundscrape ' + albumURLs[i]['href'] + ' -b -f'
os.system(command)
ignoreThis1 = 'mv ./miner.py ../'
ignoreThis2 = 'mv ./Pipfile ../'
makeDir = 'mkdir ~/Music/' + tag
moveEverything = 'mv * ~/Music/' + tag
bringBack1 = 'mv ../miner.py .'
bringBack2 = 'mv ../Pipfile .'
os.system(ignoreThis1)
os.system(ignoreThis2)
os.system(makeDir)
os.system(moveEverything)
os.system(bringBack1)
os.system(bringBack2)