Skip to content

Commit 1ba370f

Browse files
committed
added option to skip explicit songs
1 parent 2ad38aa commit 1ba370f

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

spotdl/download/downloader.py

+4
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,10 @@ def search_and_download(self, song: Song) -> Tuple[Song, Optional[Path]]:
452452

453453
reinitialized = True
454454

455+
if song.explicit is True and self.settings["skip_explicit"] is True:
456+
logger.info("Skipping explicit song: %s", song.display_name)
457+
return song, None
458+
455459
# Initalize the progress tracker
456460
display_progress_tracker = self.progress_handler.get_new_tracker(song)
457461

spotdl/types/options.py

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class DownloaderOptions(TypedDict):
7878
detect_formats: Optional[List[str]]
7979
save_errors: Optional[str]
8080
proxy: Optional[str]
81+
skip_explicit: Optional[bool]
8182

8283

8384
class WebOptions(TypedDict):
@@ -156,6 +157,8 @@ class DownloaderOptionalOptions(TypedDict, total=False):
156157
yt_dlp_args: Optional[str]
157158
detect_formats: Optional[List[str]]
158159
save_errors: Optional[str]
160+
proxy: Optional[str]
161+
skip_explicit: Optional[bool]
159162

160163

161164
class WebOptionalOptions(TypedDict, total=False):

spotdl/utils/arguments.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,16 @@ def parse_output_options(parser: _ArgumentGroup):
542542
choices=FFMPEG_FORMATS.keys(),
543543
)
544544

545+
# Skip explicit songs options
546+
parser.add_argument(
547+
"--skip-explicit", action="store_const", const=True, help="Skip explicit songs"
548+
)
549+
550+
parser.add_argument(
551+
"--proxy",
552+
help="Http(s) proxy server for download song. Example: http://host:port",
553+
)
554+
545555

546556
def parse_web_options(parser: _ArgumentGroup):
547557
"""
@@ -654,11 +664,6 @@ def parse_other_options(parser: _ArgumentGroup):
654664
help="Run in profile mode. Useful for debugging.",
655665
)
656666

657-
parser.add_argument(
658-
"--proxy",
659-
help="Http(s) proxy server for download song. Example: http://host:port",
660-
)
661-
662667
parser.add_argument(
663668
"--version",
664669
"-v",

spotdl/utils/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ def modernize_settings(options: DownloaderOptions):
298298
"detect_formats": None,
299299
"save_errors": None,
300300
"proxy": None,
301+
"skip_explicit": False,
301302
}
302303

303304
WEB_OPTIONS: WebOptions = {

spotdl/utils/search.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ def get_all_user_playlists(user_url: str = "") -> List[Playlist]:
320320
Get all user playlists.
321321
322322
### Args (optional)
323-
- user_url: Spotify user profile url. If a url is mentioned, get all public playlists of that specific user.
323+
- user_url: Spotify user profile url.
324+
If a url is mentioned, get all public playlists of that specific user.
324325
325326
### Returns
326327
- List of all user playlists
@@ -522,6 +523,7 @@ def create_ytm_album(url: str, fetch_songs: bool = True) -> Album:
522523
songs = []
523524
for track in album["tracks"]:
524525
artists = [artist["name"] for artist in track["artists"]]
526+
525527
song = Song.from_missing_data(
526528
name=track["title"],
527529
artists=artists,

0 commit comments

Comments
 (0)