diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po
index 8a0a688df..f2fdaf981 100644
--- a/resources/language/resource.language.en_gb/strings.po
+++ b/resources/language/resource.language.en_gb/strings.po
@@ -778,11 +778,11 @@ msgid "InputStream.Adaptive"
msgstr ""
msgctxt "#30618"
-msgid ""
+msgid "Stream redirect"
msgstr ""
msgctxt "#30619"
-msgid ""
+msgid "Enable to reduce resource usage on less powerful devices, but could lead to IP bans. Use at own risk."
msgstr ""
msgctxt "#30620"
diff --git a/resources/lib/youtube_plugin/kodion/constants/const_settings.py b/resources/lib/youtube_plugin/kodion/constants/const_settings.py
index e365140a2..90d42a3e0 100644
--- a/resources/lib/youtube_plugin/kodion/constants/const_settings.py
+++ b/resources/lib/youtube_plugin/kodion/constants/const_settings.py
@@ -92,5 +92,6 @@
HTTPD_LISTEN = 'kodion.http.listen' # (str)
HTTPD_WHITELIST = 'kodion.http.ip.whitelist' # (str)
HTTPD_IDLE_SLEEP = 'youtube.http.idle_sleep' # (bool)
+HTTPD_STREAM_REDIRECT = 'youtube.http.stream_redirect' # (bool)
LOGGING_ENABLED = 'kodion.logging.enabled' # (bool)
diff --git a/resources/lib/youtube_plugin/kodion/network/http_server.py b/resources/lib/youtube_plugin/kodion/network/http_server.py
index 7f3770450..13e9e6e18 100644
--- a/resources/lib/youtube_plugin/kodion/network/http_server.py
+++ b/resources/lib/youtube_plugin/kodion/network/http_server.py
@@ -392,6 +392,8 @@ def do_GET(self):
original_query_str = urlencode(params, doseq=True)
+ stream_redirect = settings.httpd_stream_redirect()
+
response = None
for server in servers:
if not server:
@@ -405,6 +407,13 @@ def do_GET(self):
'',
))
+ if stream_redirect and server in _server_list:
+ self.send_response(301)
+ self.send_header('Location', stream_url)
+ self.send_header('Connection', 'close')
+ self.end_headers()
+ break
+
headers['Host'] = server
with self.requests.request(stream_url,
method='GET',
diff --git a/resources/lib/youtube_plugin/kodion/settings/abstract_settings.py b/resources/lib/youtube_plugin/kodion/settings/abstract_settings.py
index 4ffd45130..4289b11b1 100644
--- a/resources/lib/youtube_plugin/kodion/settings/abstract_settings.py
+++ b/resources/lib/youtube_plugin/kodion/settings/abstract_settings.py
@@ -458,6 +458,11 @@ def httpd_sleep_allowed(self, value=None):
return self.set_bool(SETTINGS.HTTPD_IDLE_SLEEP, value)
return self.get_bool(SETTINGS.HTTPD_IDLE_SLEEP, True)
+ def httpd_stream_redirect(self, value=None):
+ if value is not None:
+ return self.set_bool(SETTINGS.HTTPD_STREAM_REDIRECT, value)
+ return self.get_bool(SETTINGS.HTTPD_STREAM_REDIRECT, False)
+
def api_config_page(self):
return self.get_bool(SETTINGS.API_CONFIG_PAGE, False)
diff --git a/resources/lib/youtube_plugin/youtube/helper/stream_info.py b/resources/lib/youtube_plugin/youtube/helper/stream_info.py
index 8dbab5f34..efd7ea452 100644
--- a/resources/lib/youtube_plugin/youtube/helper/stream_info.py
+++ b/resources/lib/youtube_plugin/youtube/helper/stream_info.py
@@ -1925,6 +1925,9 @@ def load_stream_info(self, video_id):
title='',
url=manifest_url,
meta=meta_info,
+ headers={
+ 'User-Agent': 'youtube/0.1 ({0})'.format(self.video_id),
+ },
playback_stats=playback_stats,
)
diff --git a/resources/settings.xml b/resources/settings.xml
index 9e4d71279..b6880c58f 100644
--- a/resources/settings.xml
+++ b/resources/settings.xml
@@ -1133,6 +1133,11 @@
true
+
+ 0
+ False
+
+