diff options
author | Matt Broadway <mattdbway@gmail.com> | 2021-07-23 15:26:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-23 19:56:19 +0530 |
commit | 767b02a99bf206cfa0c90fe6e18b9ee15f5dc984 (patch) | |
tree | d865d798e49a8c73d9826c4150c8498a080c7720 | |
parent | f45e6c11264434ef7bace0b6badfd45df8dd874a (diff) | |
download | hypervideo-pre-767b02a99bf206cfa0c90fe6e18b9ee15f5dc984.tar.lz hypervideo-pre-767b02a99bf206cfa0c90fe6e18b9ee15f5dc984.tar.xz hypervideo-pre-767b02a99bf206cfa0c90fe6e18b9ee15f5dc984.zip |
[cookies] Handle `sqlite` `ImportError` gracefully (#554)
Closes #544
Authored by: mbway
-rw-r--r-- | yt_dlp/cookies.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/yt_dlp/cookies.py b/yt_dlp/cookies.py index 0349c9692..f3b513f29 100644 --- a/yt_dlp/cookies.py +++ b/yt_dlp/cookies.py @@ -2,7 +2,6 @@ import ctypes import json import os import shutil -import sqlite3 import struct import subprocess import sys @@ -24,6 +23,15 @@ from yt_dlp.utils import ( ) try: + import sqlite3 + SQLITE_AVAILABLE = True +except ImportError: + # although sqlite3 is part of the standard library, it is possible to compile python without + # sqlite support. See: https://github.com/yt-dlp/yt-dlp/issues/544 + SQLITE_AVAILABLE = False + + +try: from Crypto.Cipher import AES CRYPTO_AVAILABLE = True except ImportError: @@ -90,6 +98,10 @@ def extract_cookies_from_browser(browser_name, profile=None, logger=YDLLogger()) def _extract_firefox_cookies(profile, logger): logger.info('Extracting cookies from firefox') + if not SQLITE_AVAILABLE: + logger.warning('Cannot extract cookies from firefox without sqlite3 support. ' + 'Please use a python interpreter compiled with sqlite3 support') + return YoutubeDLCookieJar() if profile is None: search_root = _firefox_browser_dir() @@ -195,6 +207,12 @@ def _get_chromium_based_browser_settings(browser_name): def _extract_chrome_cookies(browser_name, profile, logger): logger.info('Extracting cookies from {}'.format(browser_name)) + + if not SQLITE_AVAILABLE: + logger.warning(('Cannot extract cookies from {} without sqlite3 support. ' + 'Please use a python interpreter compiled with sqlite3 support').format(browser_name)) + return YoutubeDLCookieJar() + config = _get_chromium_based_browser_settings(browser_name) if profile is None: |