Use user's download location, resolve mentions of ~ (tilde) and environment vars
This commit is contained in:
parent
34ef348929
commit
296e2ca7e5
@ -360,11 +360,16 @@ def copy_url(
|
|||||||
update_interval = config_obj.getint(section_name, "dl_progress_update_interval")
|
update_interval = config_obj.getint(section_name, "dl_progress_update_interval")
|
||||||
max_quality_url = video_metadata["url"]
|
max_quality_url = video_metadata["url"]
|
||||||
filename = max_quality_url.split("/")[-1]
|
filename = max_quality_url.split("/")[-1]
|
||||||
dest_path = os.path.join("./", filename)
|
dest_dir = config_obj.get(section_name, "dl_dir")
|
||||||
|
dest_path = os.path.join(dest_dir, filename)
|
||||||
|
dest_path = os.path.expanduser(dest_path)
|
||||||
|
dest_path = os.path.expandvars(dest_path)
|
||||||
show_name = f"{show.topic} - {show.title}"
|
show_name = f"{show.topic} - {show.title}"
|
||||||
|
|
||||||
|
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
|
||||||
with open(dest_path, "wb") as dest_file:
|
with open(dest_path, "wb") as dest_file:
|
||||||
log.info(f"""Downloading "{show_name}" ...""")
|
log.info(f"""Downloading "{show_name}" ...""")
|
||||||
|
log.info(f"Download location resolved to {dest_path}")
|
||||||
r = requests.get(max_quality_url, stream=True)
|
r = requests.get(max_quality_url, stream=True)
|
||||||
for chunk in r.iter_content(32768):
|
for chunk in r.iter_content(32768):
|
||||||
size_downloaded += len(chunk)
|
size_downloaded += len(chunk)
|
||||||
@ -424,6 +429,7 @@ def download_media(
|
|||||||
for video in video_metadata:
|
for video in video_metadata:
|
||||||
total_content_length += video_metadata[video]["content_length"]
|
total_content_length += video_metadata[video]["content_length"]
|
||||||
video_metadata["total_content_length"] = total_content_length
|
video_metadata["total_content_length"] = total_content_length
|
||||||
|
log.info(f"""Download location is {config_obj.get(section_name, "dl_dir")}""")
|
||||||
log.info(f"Limiting parallel downloads to {dl_threads} ...")
|
log.info(f"Limiting parallel downloads to {dl_threads} ...")
|
||||||
with ThreadPoolExecutor(max_workers=dl_threads) as pool:
|
with ThreadPoolExecutor(max_workers=dl_threads) as pool:
|
||||||
download_last_update_time = time.time()
|
download_last_update_time = time.time()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user