Skip to content

Commit c0e583e

Browse files
committed
feat: Add title customization for download lists
Introduces the ability to specify a custom title for downloaded files in the list file by adding a special comment. Enhances user experience by allowing a default title of "Episode" when using numbering without a custom name. Also refines exception handling for aborting downloads, improving robustness.
1 parent 3a42456 commit c0e583e

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ Run:
8787
voe-dl -l links.txt
8888
```
8989

90+
### Setting Title in List File
91+
You can specify a custom title for all files by adding a special comment at the start of your list file:
92+
```
93+
#: My Series Title
94+
https://voe.sx/xxxxxxx
95+
https://voe.sx/yyyyyyy
96+
```
97+
This title will be used when combined with `--numbering` instead of the `--name` argument.
98+
9099
### Custom File Naming
91100
Set a custom name for downloaded files:
92101
```bash
@@ -99,6 +108,12 @@ voe-dl -l links.txt --name "ShowName" --numbering
99108
```
100109
This creates files like: `ShowName_S01E01.mp4`, `ShowName_S01E02.mp4`, etc.
101110

111+
If you use `--numbering` without `--name`, it defaults to "Episode":
112+
```bash
113+
voe-dl -l links.txt --numbering
114+
```
115+
Creates: `Episode_S01E01.mp4`, `Episode_S01E02.mp4`, etc.
116+
102117
### Parallel Downloads
103118
Set the number of parallel workers (default is 4):
104119
```bash

dl.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
# Global stop event for handling Ctrl+C across all threads
2929
_global_stop_event = threading.Event()
3030

31+
class DownloadAbortedException(Exception):
32+
"""Raised when a download is aborted by user (Ctrl+C)"""
33+
pass
34+
3135
def signal_handler(signum, frame):
3236
"""Handle Ctrl+C signal"""
3337
print("\n[!] Ctrl+C detected - Aborting all downloads...")
@@ -232,6 +236,10 @@ def list_dl(doc, args):
232236
if not line or line.startswith('#'):
233237
continue
234238
lines.append(line)
239+
240+
# If --numbering is used without --name, use "Episode" as default
241+
if args.numbering and not title:
242+
title = "Episode"
235243

236244
print(f"Downloading {len(lines)} files in parallel with {args.workers} threads...")
237245
print("[*] Press Ctrl+C to abort all downloads")
@@ -249,7 +257,7 @@ def list_dl(doc, args):
249257

250258
episode = extract_episode_tag(link, i) if args.numbering else None
251259
filename = generate_custom_filename(title, episode) if title and episode else None
252-
thread_args = copy.deepcopy(args)
260+
thread_args = copy.copy(args)
253261
thread_args.name = filename if filename else args.name
254262
future = executor.submit(download, link, thread_args, _global_stop_event)
255263
futures.append(future)
@@ -811,7 +819,7 @@ def shift_characters(s: str, offset: int) -> str:
811819
# Progress hook to check for abort
812820
def progress_hook(d):
813821
if stop_event and stop_event.is_set():
814-
raise Exception("Download aborted by user")
822+
raise DownloadAbortedException("Download aborted by user")
815823

816824
ydl_opts = {
817825
'outtmpl': name,
@@ -823,6 +831,9 @@ def progress_hook(d):
823831
with YoutubeDL(ydl_opts) as ydl:
824832
try:
825833
ydl.download([link])
834+
except DownloadAbortedException:
835+
# Re-raise abort exception to be handled by caller
836+
raise
826837
except Exception as e:
827838
# Check if it was aborted
828839
if stop_event and stop_event.is_set():
@@ -860,7 +871,7 @@ def progress_hook(d):
860871
# Progress hook to check for abort
861872
def progress_hook(d):
862873
if stop_event and stop_event.is_set():
863-
raise Exception("Download aborted by user")
874+
raise DownloadAbortedException("Download aborted by user")
864875

865876
ydl_opts = {
866877
'outtmpl': name,
@@ -872,6 +883,9 @@ def progress_hook(d):
872883
with YoutubeDL(ydl_opts) as ydl:
873884
try:
874885
ydl.download([link])
886+
except DownloadAbortedException:
887+
# Re-raise abort exception to be handled by caller
888+
raise
875889
except Exception as e:
876890
# Check if it was aborted
877891
if stop_event and stop_event.is_set():

0 commit comments

Comments
 (0)