Skip to content

Commit b1a6b66

Browse files
committed
impersonation default for -t and include curl_cffi
1 parent 3821987 commit b1a6b66

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ scdl -l https://soundcloud.com/pandadub/sets/the-lost-ship --sync archive.txt
4444
4545
# Download your likes (with authentification token)
4646
scdl me -f
47+
48+
# Use yt-dlp impersonation (requires curl_cffi)
49+
scdl -l https://soundcloud.com/ihatemyselfbeats/t-1 --impersonate chrome
50+
# See yt-dlp --list-impersonate-targets for a list of targets
4751
```
4852

4953
## Options:
@@ -96,6 +100,7 @@ scdl me -f
96100
--add-description Adds the description to a seperate txt file (can be read by some players)
97101
--no-playlist Skip downloading playlists
98102
--opus Prefer downloading opus streams over mp3 streams
103+
--impersonate [target] Forward yt-dlp's --impersonate (requires curl_cffi)
99104
--yt-dlp-args String with custom args to forward to yt-dlp
100105
```
101106

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ description = "Download Music from Souncloud"
88
readme = "README.md"
99
requires-python = ">=3.9.0"
1010
dependencies = [
11+
"curl_cffi>=0.14.0",
1112
"docopt-ng>=0.9.0",
1213
"mutagen>=1.47.0",
1314
"soundcloud-v2>=1.6.1",

scdl/scdl.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[--original-name][--original-metadata][--no-original][--only-original]
1010
[--name-format <format>][--strict-playlist][--playlist-name-format <format>]
1111
[--client-id <id>][--auth-token <token>][--overwrite][--no-playlist][--opus]
12-
[--add-description][--yt-dlp-args <argstring>]
12+
[--add-description][--impersonate <target>][--yt-dlp-args <argstring>]
1313
1414
scdl -h | --help
1515
scdl --version
@@ -69,6 +69,7 @@
6969
--no-playlist Skip downloading playlists
7070
--add-description Adds the description to a separate txt file
7171
--opus Prefer downloading opus streams over mp3 streams
72+
--impersonate [target] Forward yt-dlp's --impersonate (requires curl_cffi)
7273
--yt-dlp-args [argstring] String with custom args to forward to yt-dlp
7374
"""
7475

@@ -155,6 +156,7 @@ class SCDLArgs(TypedDict):
155156
sync: str | None
156157
s: str | None
157158
t: bool
159+
impersonate: str | None
158160
yt_dlp_args: str
159161

160162

@@ -395,7 +397,7 @@ def _build_ytdl_params(url: str, scdl_args: SCDLArgs) -> tuple[str, dict, list]:
395397
elif scdl_args.get("p"):
396398
url = posixpath.join(url, "sets")
397399
elif scdl_args.get("r"):
398-
url = posixpath.join(url, "reposts")
400+
url = ensure_suffix(base, "reposts")
399401

400402
params: dict = {}
401403

@@ -502,6 +504,11 @@ def _build_ytdl_params(url: str, scdl_args: SCDLArgs) -> tuple[str, dict, list]:
502504
if scdl_args.get("opus"):
503505
params["--extractor-args"] = "soundcloud:formats=*_aac,*_opus,*_mp3"
504506

507+
if scdl_args.get("impersonate"):
508+
params["--impersonate"] = scdl_args.get("impersonate")
509+
elif scdl_args.get("t"):
510+
params["--impersonate"] = "chrome"
511+
505512
argv = []
506513
for param, value in params.items():
507514
if value is False:

0 commit comments

Comments
 (0)