Repository: yt-dlp/yt-dlp

Issue:
`DeprecationWarning` when using `-v` and having `sqlite3` on py >=3.12
### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting a bug unrelated to a specific site
- [X] I've verified that I'm running yt-dlp version **2023.07.06** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)

### Provide a description that is worded well enough to be understood

This only happens if `sqlite3` is available, so doesnt get triggered in regular tests (add `-r requirements.txt`?).

Ref: https://github.com/python/cpython/issues/93370

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [ ] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
[debug] Command-line config: ['-v']
[debug] User config "C:\Users\grub4k\yt-dlp.conf": ['--alias', 'login', '--cookies-from-browser firefox', '--alias', 'plugins', '--plugin-dir E:\\Projekte\\yt-dlp-plugins', '--alias', 'plugin', '--plugin-dir E:\\Projekte\\yt-dlp-plugins\\{0}', '--alias', 'subs', '--write-subs --sub-langs all,-live_chat', '--alias', 'aliensrock', '--config-location "d:/Videos/Youtube/Aliensrock/Patreon/yt-dlp.conf"', '--alias', 'game-changer', '--config-location "d:/Videos/Youtube/CollegeHumor/Game Changer/yt-dlp.conf"']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2023.07.06 [b532a3481] (source)
[debug] Lazy loading extractors is disabled
[debug] Git HEAD: 5cac6cea0
[debug] Python 3.12.0rc2 (CPython AMD64 64bit) - Windows-11-10.0.22000-SP0 (OpenSSL 3.0.10 1 Aug 2023)
[debug] exe versions: ffmpeg n6.0-34-g3d5edb89e7-20230819 (setts), ffprobe n6.0-34-g3d5edb89e7-20230819
Traceback (most recent call last):
  File "D:\Documents\GitHub\Grub4K\yt-dlp\yt_dlp\__main__.py", line 17, in <module>
    yt_dlp.main()
  File "D:\Documents\GitHub\Grub4K\yt-dlp\yt_dlp\__init__.py", line 1008, in main
    _exit(*variadic(_real_main(argv)))
                    ^^^^^^^^^^^^^^^^
  File "D:\Documents\GitHub\Grub4K\yt-dlp\yt_dlp\__init__.py", line 962, in _real_main
    with YoutubeDL(ydl_opts) as ydl:
         ^^^^^^^^^^^^^^^^^^^
  File "D:\Documents\GitHub\Grub4K\yt-dlp\yt_dlp\YoutubeDL.py", line 689, in __init__
    self.print_debug_header()
  File "D:\Documents\GitHub\Grub4K\yt-dlp\yt_dlp\YoutubeDL.py", line 3975, in print_debug_header
    join_nonempty(*get_package_info(m)) for m in available_dependencies.values()
                   ^^^^^^^^^^^^^^^^^^^
  File "D:\Documents\GitHub\Grub4K\yt-dlp\yt_dlp\compat\compat_utils.py", line 16, in get_package_info
    version=str(next(filter(None, (
                ^^^^^^^^^^^^^^^^^^^
  File "D:\Documents\GitHub\Grub4K\yt-dlp\yt_dlp\compat\compat_utils.py", line 17, in <genexpr>
    getattr(module, attr, None)
  File "C:\Users\grub4k\AppData\Local\Programs\Python\Python312\Lib\sqlite3\__init__.py", line 67, in __getattr__
    warn(f"{name} is deprecated and will be removed in Python 3.14",
DeprecationWarning: version is deprecated and will be removed in Python 3.14
```



Discussion:
We could do this

```diff
diff --git a/yt_dlp/compat/compat_utils.py b/yt_dlp/compat/compat_utils.py
index 3ca46d270..d62b7d048 100644
--- a/yt_dlp/compat/compat_utils.py
+++ b/yt_dlp/compat/compat_utils.py
@@ -15,7 +15,7 @@ def get_package_info(module):
         name=getattr(module, '_yt_dlp__identifier', module.__name__),
         version=str(next(filter(None, (
             getattr(module, attr, None)
-            for attr in ('__version__', 'version_string', 'version')
+            for attr in ('_yt_dlp__version', '__version__', 'version_string', 'version')
         )), None)))
 
 
diff --git a/yt_dlp/dependencies/__init__.py b/yt_dlp/dependencies/__init__.py
index 6e7d29c5c..2fa4959f0 100644
--- a/yt_dlp/dependencies/__init__.py
+++ b/yt_dlp/dependencies/__init__.py
@@ -43,6 +43,10 @@
 
 try:
     import sqlite3
+    import warnings as _warnings
+    with _warnings.catch_warnings():
+        _warnings.simplefilter('ignore', DeprecationWarning)
+        sqlite3._yt_dlp__version = getattr(sqlite3, 'version', '2.6.0+')
 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
```

Resolving patch:
diff --git a/yt_dlp/compat/compat_utils.py b/yt_dlp/compat/compat_utils.py
--- a/yt_dlp/compat/compat_utils.py
+++ b/yt_dlp/compat/compat_utils.py
@@ -15,7 +15,7 @@ def get_package_info(module):
         name=getattr(module, '_yt_dlp__identifier', module.__name__),
         version=str(next(filter(None, (
             getattr(module, attr, None)
-            for attr in ('__version__', 'version_string', 'version')
+            for attr in ('_yt_dlp__version', '__version__', 'version_string', 'version')
         )), None)))
 
 
diff --git a/yt_dlp/dependencies/__init__.py b/yt_dlp/dependencies/__init__.py
--- a/yt_dlp/dependencies/__init__.py
+++ b/yt_dlp/dependencies/__init__.py
@@ -43,6 +43,8 @@
 
 try:
     import sqlite3
+    # We need to get the underlying `sqlite` version, see https://github.com/yt-dlp/yt-dlp/issues/8152
+    sqlite3._yt_dlp__version = sqlite3.sqlite_version
 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


Test patch: