From e50057978f06190bb79dfa39ca6573533c73a153 Mon Sep 17 00:00:00 2001 From: Taapat Date: Fri, 15 Sep 2023 20:20:49 +0300 Subject: [PATCH] Specifies the language when getting the video url It allows getting error messages in the user's language. --- .github/workflows/ci.yml | 1 + src/YouTubeVideoUrl.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0821536..a43e48fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,6 +103,7 @@ jobs: sed -i 's/from Components/# from Components/g' src/YouTubeVideoUrl.py sed -i 's/config.plugins.YouTube.maxResolution.value/"22"/g' src/YouTubeVideoUrl.py sed -i 's/config.plugins.YouTube.useDashMP4.value/True/g' src/YouTubeVideoUrl.py + sed -i 's/config.plugins.YouTube.searchLanguage.value/"en"/g' src/YouTubeVideoUrl.py - name: Test code with pytest run: | pytest -rx -v --cov=src --cov-report=xml --cov-report=html diff --git a/src/YouTubeVideoUrl.py b/src/YouTubeVideoUrl.py index 90c20702..7be821ad 100644 --- a/src/YouTubeVideoUrl.py +++ b/src/YouTubeVideoUrl.py @@ -245,7 +245,7 @@ def _extract_player_response(self, video_id, client): data['playbackContext']['contentPlaybackContext']['signatureTimestamp'] = sts data['context'] = { 'client': { - 'hl': 'en', + 'hl': config.plugins.YouTube.searchLanguage.value, 'clientName': 'TVHTML5_SIMPLY_EMBEDDED_PLAYER', 'clientVersion': '2.0', }, @@ -258,7 +258,7 @@ def _extract_player_response(self, video_id, client): else: data['context'] = { 'client': { - 'hl': 'en', + 'hl': config.plugins.YouTube.searchLanguage.value, 'clientVersion': '17.31.35', 'androidSdkVersion': 31, 'clientName': 'ANDROID',