Skip to content

Commit

Permalink
Fix comments not displaying for recommended videos anxdpanic#878
Browse files Browse the repository at this point in the history
- Remove use of deepcopy
- Copy and manipulate individual sub-dicts instead
  • Loading branch information
MoojMidge committed Aug 14, 2024
1 parent 472e45d commit 7f1945a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
3 changes: 1 addition & 2 deletions resources/lib/youtube_plugin/kodion/plugin_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from __future__ import absolute_import, division, unicode_literals

from copy import deepcopy
from platform import python_version

from .context import XbmcContext
Expand Down Expand Up @@ -44,7 +43,7 @@ def run(context=_context,
context.init()
new_uri = context.get_uri()

params = deepcopy(context.get_params())
params = context.get_params().copy()
for key in ('api_key', 'client_id', 'client_secret'):
if key in params:
params[key] = '<redacted>'
Expand Down
9 changes: 5 additions & 4 deletions resources/lib/youtube_plugin/kodion/utils/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from __future__ import absolute_import, division, unicode_literals

import copy
import json
import os
import re
Expand Down Expand Up @@ -97,13 +96,15 @@ def _stream_sort(_stream):
context.log_debug('Available streams: {0}'.format(num_streams))

for idx, stream in enumerate(stream_list):
log_data = copy.deepcopy(stream)
log_data = stream.copy()

if 'license_info' in log_data:
license_info = log_data['license_info'].copy()
for detail in ('url', 'token'):
original_value = log_data['license_info'].get(detail)
original_value = license_info.get(detail)
if original_value:
log_data['license_info'][detail] = '<redacted>'
license_info[detail] = '<redacted>'
log_data['license_info'] = license_info

original_value = log_data.get('url')
if original_value:
Expand Down
12 changes: 10 additions & 2 deletions resources/lib/youtube_plugin/youtube/client/request_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,20 @@ def build_client(cls, client_name=None, data=None):
params = client['params']
if client.get('_access_token'):
if 'key' in params:
params = params.copy()
del params['key']
client['params'] = params
else:
if 'Authorization' in client['headers']:
del client['headers']['Authorization']
headers = client['headers']
if 'Authorization' in headers:
headers = headers.copy()
del headers['Authorization']
client['headers'] = headers

if 'key' in params and params['key'] is ValueError:
params = params.copy()
del params['key']
client['params'] = params
except KeyError:
pass

Expand Down
15 changes: 8 additions & 7 deletions resources/lib/youtube_plugin/youtube/client/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import threading
import xml.etree.ElementTree as ET
from copy import deepcopy
from functools import partial
from itertools import chain, islice
from random import randint
Expand Down Expand Up @@ -2022,19 +2021,21 @@ def api_request(self,

client = self.build_client(version, client_data)

if 'key' in client['params'] and not client['params']['key']:
params = client.get('params')
if 'key' in params and not params['key']:
params = params.copy()
key = self._config.get('key') or self._config_tv.get('key')
if key:
client['params']['key'] = key
params['key'] = key
else:
del client['params']['key']
del params['key']
client['params'] = params

if clear_data and 'json' in client:
del client['json']

params = client.get('params')
if params:
log_params = deepcopy(params)
log_params = params.copy()
if 'location' in log_params:
log_params['location'] = '|xx.xxxx,xx.xxxx|'
if 'key' in log_params:
Expand All @@ -2045,7 +2046,7 @@ def api_request(self,

headers = client.get('headers')
if headers:
log_headers = deepcopy(headers)
log_headers = headers.copy()
if 'Authorization' in log_headers:
log_headers['Authorization'] = '|logged in|'
else:
Expand Down
3 changes: 1 addition & 2 deletions resources/lib/youtube_plugin/youtube/helper/yt_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from __future__ import absolute_import, division, unicode_literals

import copy
import time

from ..youtube_exceptions import LoginException
Expand Down Expand Up @@ -81,7 +80,7 @@ def _do_login(login_type):
_do_logout()
raise

log_data = copy.deepcopy(json_data)
log_data = json_data.copy()
if 'access_token' in log_data:
log_data['access_token'] = '<redacted>'
if 'refresh_token' in log_data:
Expand Down

0 comments on commit 7f1945a

Please sign in to comment.