From ebf99aaf7002b3178ae3e5e68930d277115e54d3 Mon Sep 17 00:00:00 2001
From: pukkandan <pukkandan.ytdlp@gmail.com>
Date: Wed, 13 Jul 2022 19:42:52 +0530
Subject: [PATCH] [utils] Fix `get_domain`

Bug in ae61d108dd83a951b6e8a27e1fb969682416150d

Closes #4344
---
 yt_dlp/utils.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index a347a50bc..6e0c31c01 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -2405,7 +2405,11 @@ def remove_quotes(s):
 
 
 def get_domain(url):
-    return '.'.join(urllib.parse.urlparse(url).netloc.rsplit('.', 2)[-2:])
+    """
+    This implementation is inconsistent, but is kept for compatibility.
+    Use this only for "webpage_url_domain"
+    """
+    return remove_start(urllib.parse.urlparse(url).netloc, 'www.') or None
 
 
 def url_basename(url):