Skip to content

Commit

Permalink
added option to skip explicit songs
Browse files Browse the repository at this point in the history
  • Loading branch information
xnetcat committed Oct 10, 2023
1 parent 2ad38aa commit 1ba370f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions spotdl/download/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,10 @@ def search_and_download(self, song: Song) -> Tuple[Song, Optional[Path]]:

reinitialized = True

if song.explicit is True and self.settings["skip_explicit"] is True:
logger.info("Skipping explicit song: %s", song.display_name)
return song, None

# Initalize the progress tracker
display_progress_tracker = self.progress_handler.get_new_tracker(song)

Expand Down
3 changes: 3 additions & 0 deletions spotdl/types/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class DownloaderOptions(TypedDict):
detect_formats: Optional[List[str]]
save_errors: Optional[str]
proxy: Optional[str]
skip_explicit: Optional[bool]


class WebOptions(TypedDict):
Expand Down Expand Up @@ -156,6 +157,8 @@ class DownloaderOptionalOptions(TypedDict, total=False):
yt_dlp_args: Optional[str]
detect_formats: Optional[List[str]]
save_errors: Optional[str]
proxy: Optional[str]
skip_explicit: Optional[bool]


class WebOptionalOptions(TypedDict, total=False):
Expand Down
15 changes: 10 additions & 5 deletions spotdl/utils/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,16 @@ def parse_output_options(parser: _ArgumentGroup):
choices=FFMPEG_FORMATS.keys(),
)

# Skip explicit songs options
parser.add_argument(
"--skip-explicit", action="store_const", const=True, help="Skip explicit songs"
)

parser.add_argument(
"--proxy",
help="Http(s) proxy server for download song. Example: http://host:port",
)


def parse_web_options(parser: _ArgumentGroup):
"""
Expand Down Expand Up @@ -654,11 +664,6 @@ def parse_other_options(parser: _ArgumentGroup):
help="Run in profile mode. Useful for debugging.",
)

parser.add_argument(
"--proxy",
help="Http(s) proxy server for download song. Example: http://host:port",
)

parser.add_argument(
"--version",
"-v",
Expand Down
1 change: 1 addition & 0 deletions spotdl/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ def modernize_settings(options: DownloaderOptions):
"detect_formats": None,
"save_errors": None,
"proxy": None,
"skip_explicit": False,
}

WEB_OPTIONS: WebOptions = {
Expand Down
4 changes: 3 additions & 1 deletion spotdl/utils/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ def get_all_user_playlists(user_url: str = "") -> List[Playlist]:
Get all user playlists.
### Args (optional)
- user_url: Spotify user profile url. If a url is mentioned, get all public playlists of that specific user.
- user_url: Spotify user profile url.
If a url is mentioned, get all public playlists of that specific user.
### Returns
- List of all user playlists
Expand Down Expand Up @@ -522,6 +523,7 @@ def create_ytm_album(url: str, fetch_songs: bool = True) -> Album:
songs = []
for track in album["tracks"]:
artists = [artist["name"] for artist in track["artists"]]

song = Song.from_missing_data(
name=track["title"],
artists=artists,
Expand Down

0 comments on commit 1ba370f

Please sign in to comment.