aboutsummaryrefslogtreecommitdiff
path: root/yt_dlp/utils.py
diff options
context:
space:
mode:
authorLesmiscore <nao20010128@gmail.com>2023-01-02 02:16:25 +0900
committerGitHub <noreply@github.com>2023-01-02 02:16:25 +0900
commit8c53322cda75394a8d551dde20b2529ee5ad6e89 (patch)
treeb3a5849a43d7e56b4980a67f1ac5ecc110f8803b /yt_dlp/utils.py
parent193fb150b76c4aaf41fb2c98b073e7e1f8a108f0 (diff)
[downloader/aria2c] Native progress for aria2c via RPC (#3724)
Authored by: Lesmiscore, pukkandan Closes #2038
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r--yt_dlp/utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index 5af176b36..45a7e6eaa 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -5243,6 +5243,15 @@ def random_birthday(year_field, month_field, day_field):
}
+def find_available_port(interface=''):
+ try:
+ with socket.socket() as sock:
+ sock.bind((interface, 0))
+ return sock.getsockname()[1]
+ except OSError:
+ return None
+
+
# Templates for internet shortcut files, which are plain text files.
DOT_URL_LINK_TEMPLATE = '''\
[InternetShortcut]