Skip to content

Instantly share code, notes, and snippets.

@Touexe
Created January 17, 2021 07:03
Show Gist options
  • Save Touexe/61cf9cd7be448249b30b832b6c046dde to your computer and use it in GitHub Desktop.
Save Touexe/61cf9cd7be448249b30b832b6c046dde to your computer and use it in GitHub Desktop.
Youtube-dl with idm

Youtube-dl-with-IDM

Download any video from supported sites by youtube-dl with IDM as downloader

Requirements

  • Python 3.x
  • Internet Download Manager
  • youtube_dl
  • idm

Installation

Install youtube_dl

pip install youtube_dl

install idm

pip install idm

Getting download url using youtube-dl

import youtube_dl

url = "" # The youtube video you want to download 
ydl_opts = {'format':'best'}  # Choose the video format you want or using the best format available by default
            
def extractor(url):
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
            info_dict = ydl.extract_info(url, download=False)
    return info_dict

info = extractor(url)
title = info['title']
width = info['width']
height = info['height']
ext = info['ext']
download_url = info['url']

Downloading file Using IDM

from idm import IDMan

downloader = IDMan()
url = ""
destination_path = r"" # The folder path you want your downloading video to be saved

downloader.download(url,path_to_save = destination_path, output=None, referrer=None, cookie=None, postData=None, user=None, password=None, confirm = False, lflag = None, clip=False)

Using Youtube-dl with IDM

import youtube_dl
from idm import IDMan

url = "" # The youtube video you want to download 
downloader = IDMan()
destination_path = r"" # The folder path you want your downloading video to be saved

ydl_opts = {'format':'best'} # Choose the video format you want or using the best format available by default
            
def extractor(url):
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
            info_dict = ydl.extract_info(url, download=False)
    return info_dict

info = extractor(url)
title = info['title'] 
width = info['width']
height = info['height']
ext = info['ext']
download_url = info['url']

downloader.download(download_url,path_to_save = destination_path, output=f"{title}.{ext}", referrer= url, cookie=None, postData=None, user=None, password=None, confirm = False, lflag = None, clip=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment