Skip to content

Commit

Permalink
Merge pull request #1010 from MoojMidge/v7.1.1
Browse files Browse the repository at this point in the history
v7.1.1.4
  • Loading branch information
MoojMidge authored Dec 4, 2024
2 parents 0206865 + 75f875f commit 7ce201c
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 108 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.youtube" name="YouTube" version="7.1.1.3" provider-name="anxdpanic, bromix, MoojMidge">
<addon id="plugin.video.youtube" name="YouTube" version="7.1.1.4" provider-name="anxdpanic, bromix, MoojMidge">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.requests" version="2.27.1"/>
Expand Down
4 changes: 3 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## v7.1.1.3
## v7.1.1.4
### Fixed
- Fix http server not listening on any interface if listen IP is 0.0.0.0 #927
- Standardise return type of LoginClient.refresh_token #932
Expand Down Expand Up @@ -40,6 +40,8 @@
- Fix missing "Ask" translation string
- Fix incorrect parameter name breaking auto-remove from Watch Later #993
- Fix processing of "q" and "channelId" search query params #1004
- Fix errors with progress dialogs in Kodi 18 #1000
- Fix remote watch history not updating #1008

### Changed
- Improve display and update of bookmarks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,9 @@ def update(self, steps=1, position=None, message=None, **template_params):
message = self._message_template.format(**self._template_params)
self._message = message

self._dialog.update(
percent=position,
message=message,
)
# Kodi 18 renamed XbmcProgressDialog.update argument line1 to message.
# Only use positional arguments to maintain compatibility
self._dialog.update(position, self._message)

def is_aborted(self):
raise NotImplementedError()
45 changes: 34 additions & 11 deletions resources/lib/youtube_plugin/youtube/client/request_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class YouTubeRequestClient(BaseRequestsClass):
},
'ios': {
'_id': 5,
'_auth_type': False,
'_os': {
'major': '17',
'minor': '5',
Expand Down Expand Up @@ -261,6 +262,7 @@ class YouTubeRequestClient(BaseRequestsClass):
},
'_common': {
'_access_token': None,
'_access_token_tv': None,
'json': {
'contentCheckOk': True,
'context': {
Expand All @@ -286,13 +288,11 @@ class YouTubeRequestClient(BaseRequestsClass):
'videoId': None,
},
'headers': {
'Origin': 'https://www.youtube.com',
'Referer': 'https://www.youtube.com/watch?v={json[videoId]}',
'Accept-Encoding': 'gzip, deflate',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.5',
'Authorization': 'Bearer {_access_token}',
'Authorization': None,
},
'params': {
'key': ValueError,
Expand Down Expand Up @@ -369,31 +369,53 @@ def json_traverse(cls, json_data, path, default=None):
def build_client(cls, client_name=None, data=None):
templates = {}

client = None
base_client = None
if client_name:
client = cls.CLIENTS.get(client_name)
if client and client.get('_disabled'):
base_client = cls.CLIENTS.get(client_name)
if base_client and base_client.get('_disabled'):
return None
if not client:
client = YouTubeRequestClient.CLIENTS['web']
client = client.copy()
if not base_client:
base_client = YouTubeRequestClient.CLIENTS['web']
base_client = base_client.copy()

if data:
client = merge_dicts(client, data)
client = merge_dicts(base_client, data)
client = merge_dicts(cls.CLIENTS['_common'], client, templates)
client['_name'] = client_name
if base_client.get('_auth_required'):
client['_auth_required'] = True

for values, template_id, template in templates.values():
if template_id in values:
values[template_id] = template.format(**client)

has_auth = False
try:
params = client['params']
if client.get('_access_token'):
auth_required = client.get('_auth_required')
auth_requested = client.get('_auth_requested')
auth_type = client.get('_auth_type')
if auth_type == 'tv' and auth_requested != 'personal':
auth_token = client.get('_access_token_tv')
elif auth_type is not False:
auth_token = client.get('_access_token')
else:
auth_token = None

if auth_token and (auth_required or auth_requested):
headers = client['headers']
if 'Authorization' in headers:
headers = headers.copy()
headers['Authorization'] = 'Bearer {0}'.format(auth_token)
client['headers'] = headers
has_auth = True

if 'key' in params:
params = params.copy()
del params['key']
client['params'] = params
elif auth_required:
return None
else:
headers = client['headers']
if 'Authorization' in headers:
Expand All @@ -407,5 +429,6 @@ def build_client(cls, client_name=None, data=None):
client['params'] = params
except KeyError:
pass
client['_has_auth'] = has_auth

return client
Loading

0 comments on commit 7ce201c

Please sign in to comment.