Skip to content

Commit 53be72a

Browse files
committed
Add support for accepting cookiefile in dw method
1 parent de7aa0d commit 53be72a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

ytmdl/yt.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,16 @@ def progress_handler(d):
7676
stdout.flush()
7777

7878

79-
def dw_using_yt(link, proxy, song_name, datatype, no_progress=False, ytdl_config: str = None, dont_convert: bool = False):
79+
def dw_using_yt(
80+
link,
81+
proxy,
82+
song_name,
83+
datatype,
84+
no_progress=False,
85+
ytdl_config: str = None,
86+
dont_convert: bool = False,
87+
cookiefile=None
88+
):
8089
"""
8190
Download the song using YTDL downloader and use downloader CLI's
8291
functions to be used to display a progressbar.
@@ -121,6 +130,9 @@ def dw_using_yt(link, proxy, song_name, datatype, no_progress=False, ytdl_config
121130
if proxy is not None:
122131
ydl_opts['proxy'] = proxy
123132

133+
if cookiefile is not None:
134+
ydl_opts['cookiefile'] = cookiefile
135+
124136
logger.debug("args passed: ", str(ydl_opts))
125137
ydl = yt_dlp.YoutubeDL(ydl_opts)
126138

@@ -139,7 +151,8 @@ def dw(
139151
datatype='mp3',
140152
no_progress=False,
141153
ytdl_config: str = None,
142-
dont_convert: bool = False
154+
dont_convert: bool = False,
155+
cookiefile: str = None
143156
):
144157
"""
145158
Download the song.
@@ -173,7 +186,8 @@ def dw(
173186

174187
# Start downloading the song
175188
status = dw_using_yt(value, proxy, name, datatype,
176-
no_progress, ytdl_config, dont_convert)
189+
no_progress, ytdl_config, dont_convert,
190+
cookiefile)
177191

178192
if status == 0:
179193
return name

0 commit comments

Comments
 (0)