Skip to content

Commit

Permalink
Add support for accepting cookiefile in dw method
Browse files Browse the repository at this point in the history
  • Loading branch information
deepjyoti30 committed Aug 15, 2024
1 parent de7aa0d commit 53be72a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions ytmdl/yt.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,16 @@ def progress_handler(d):
stdout.flush()


def dw_using_yt(link, proxy, song_name, datatype, no_progress=False, ytdl_config: str = None, dont_convert: bool = False):
def dw_using_yt(
link,
proxy,
song_name,
datatype,
no_progress=False,
ytdl_config: str = None,
dont_convert: bool = False,
cookiefile=None
):
"""
Download the song using YTDL downloader and use downloader CLI's
functions to be used to display a progressbar.
Expand Down Expand Up @@ -121,6 +130,9 @@ def dw_using_yt(link, proxy, song_name, datatype, no_progress=False, ytdl_config
if proxy is not None:
ydl_opts['proxy'] = proxy

if cookiefile is not None:
ydl_opts['cookiefile'] = cookiefile

logger.debug("args passed: ", str(ydl_opts))
ydl = yt_dlp.YoutubeDL(ydl_opts)

Expand All @@ -139,7 +151,8 @@ def dw(
datatype='mp3',
no_progress=False,
ytdl_config: str = None,
dont_convert: bool = False
dont_convert: bool = False,
cookiefile: str = None
):
"""
Download the song.
Expand Down Expand Up @@ -173,7 +186,8 @@ def dw(

# Start downloading the song
status = dw_using_yt(value, proxy, name, datatype,
no_progress, ytdl_config, dont_convert)
no_progress, ytdl_config, dont_convert,
cookiefile)

if status == 0:
return name
Expand Down

0 comments on commit 53be72a

Please sign in to comment.