mirror of
https://github.com/rwinkhart/reflexify.git
synced 2026-09-01 22:57:19 -04:00
Add track name to file name
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
from os import name
|
from os import name
|
||||||
from os.path import expanduser
|
from os.path import expanduser
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
# external dependencies
|
||||||
from requests import get
|
from requests import get
|
||||||
|
|
||||||
download_dir = input('download location (full path): ').rstrip('\\').rstrip('/')
|
download_dir = input('download location (full path): ').rstrip('\\').rstrip('/')
|
||||||
@@ -34,11 +36,17 @@ Path(download_dir).mkdir(mode=0o700, parents=True, exist_ok=True)
|
|||||||
# track download loop
|
# track download loop
|
||||||
download_id = start
|
download_id = start
|
||||||
while download_id < stop + 1:
|
while download_id < stop + 1:
|
||||||
|
skip = False
|
||||||
print(f"\rprogress: {str('{:04d}'.format(download_id))}/{str('{:04d}'.format(stop))}", end='')
|
print(f"\rprogress: {str('{:04d}'.format(download_id))}/{str('{:04d}'.format(stop))}", end='')
|
||||||
if not Path(download_dir + divider + str('{:04d}'.format(download_id))).is_file():
|
if not Path(download_dir + divider + str('{:04d}'.format(download_id))).is_file():
|
||||||
response = get(f"https://reflex-central.com/download.php?track_id={str(download_id)}", cookies=cookies)
|
response = get(f"https://reflex-central.com/download.php?track_id={str(download_id)}", cookies=cookies)
|
||||||
with open(download_dir + divider + str('{:04d}'.format(download_id)), "wb") as f:
|
try:
|
||||||
f.write(response.content)
|
track_name = get(f"https://reflex-central.com/track_profile.php?track_id={str(download_id)}").text.split('\n')[71].split('b>')[1][:-3]
|
||||||
|
except IndexError:
|
||||||
|
track_name, skip = '', True
|
||||||
|
if not skip:
|
||||||
|
with open(f"{download_dir}{divider}{str('{:04d}'.format(download_id))} - {track_name}", "wb") as f:
|
||||||
|
f.write(response.content)
|
||||||
download_id += 1
|
download_id += 1
|
||||||
|
|
||||||
print('\ntrack download complete')
|
print('\ntrack download complete')
|
||||||
|
|||||||
Reference in New Issue
Block a user