don't download if file is already there
This commit is contained in:
parent
0f77e6a69a
commit
e45f0129c3
Binary file not shown.
|
@ -15,7 +15,7 @@ options.headless = True
|
||||||
|
|
||||||
base_url = "https://www.partnersinrhyme.com/royaltyfreemusic"
|
base_url = "https://www.partnersinrhyme.com/royaltyfreemusic"
|
||||||
base_files_url = "https://www.partnersinrhyme.com/files/"
|
base_files_url = "https://www.partnersinrhyme.com/files/"
|
||||||
base_out_url = "files/"
|
base_out_url = "files/PartnersInRhyme/"
|
||||||
|
|
||||||
def getCollection(collection_url):
|
def getCollection(collection_url):
|
||||||
r = requests.get(collection_url)
|
r = requests.get(collection_url)
|
||||||
|
@ -28,11 +28,11 @@ def getCollection(collection_url):
|
||||||
driver.get("http:" + player)
|
driver.get("http:" + player)
|
||||||
el = WebDriverWait(driver, 60).until(f)
|
el = WebDriverWait(driver, 60).until(f)
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(2)
|
||||||
psoup = BeautifulSoup(driver.page_source, 'html.parser')
|
psoup = BeautifulSoup(driver.page_source, 'html.parser')
|
||||||
|
|
||||||
driver.quit()
|
driver.quit()
|
||||||
|
|
||||||
for li in psoup.find_all("li"):
|
for li in psoup.find_all("li"):
|
||||||
print("downloading...", li.attrs['data-mp3'])
|
print("downloading...", li.attrs['data-mp3'])
|
||||||
downloadSong(base_files_url + li.attrs['data-mp3'])
|
downloadSong(base_files_url + li.attrs['data-mp3'])
|
||||||
|
@ -44,14 +44,16 @@ def downloadSong(song_url):
|
||||||
if not os.path.exists(outDir):
|
if not os.path.exists(outDir):
|
||||||
os.makedirs(outDir)
|
os.makedirs(outDir)
|
||||||
|
|
||||||
i = requests.get(song_url)
|
if not os.path.isfile(os.path.join(outDir, outFile)):
|
||||||
|
i = requests.get(song_url)
|
||||||
|
|
||||||
with open(os.path.join(outDir, outFile), 'wb') as tempFile:
|
with open(os.path.join(outDir, outFile), 'wb') as tempFile:
|
||||||
tempFile.write(i.content)
|
tempFile.write(i.content)
|
||||||
|
else:
|
||||||
|
print("File", outFile, "already exists... skipping")
|
||||||
|
|
||||||
def getSongFromURL(song_url):
|
def getSongFromURL(song_url):
|
||||||
list = song_url.split("/")
|
list = song_url.split("/")
|
||||||
print(list)
|
|
||||||
return (list[4], list[-1])
|
return (list[4], list[-1])
|
||||||
|
|
||||||
def f(d):
|
def f(d):
|
||||||
|
|
Loading…
Reference in New Issue