Skip to content

Commit a976258

Browse files
authored
Merge pull request #1416 from MoojMidge/v7.4
v7.4.2+beta.1
2 parents 934d085 + ecf4228 commit a976258

27 files changed

Lines changed: 444 additions & 291 deletions

addon.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="plugin.video.youtube" name="YouTube" version="7.4.1.1" provider-name="anxdpanic, bromix, MoojMidge">
2+
<addon id="plugin.video.youtube" name="YouTube" version="7.4.2+beta.1" provider-name="anxdpanic, bromix, MoojMidge">
33
<requires>
44
<import addon="xbmc.python" version="3.0.0"/>
55
<import addon="script.module.requests" version="2.27.1"/>

changelog.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
## v7.4.2+beta.1
2+
### Fixed
3+
- Skip unplayable live manifests #1377
4+
- Handle inconsistent error codes and names used in Python 2 #1412
5+
- Simplify byte range to timestamp conversion for compatibility with Python 2 #1412
6+
- Fix unnecessarily reloading listing when adding items to Bookmarks
7+
8+
### Changed
9+
- Rework addon debug log settings (Addon > Settings > Advanced > Debug > Enable debug logging) #1385
10+
- Allowable values:
11+
- Disabled (addon logging output disabled)
12+
- Auto (default, addon logging output enabled if Kodi debug logging enabled)
13+
- Always enabled (addon logging output enabled)
14+
- Verbose (additional addon logging output enabled)
15+
- Various other improvement to addon logging
16+
17+
### New
18+
- Update Setup Wizard to account for user possibly using mismatched watch history settings
19+
120
## v7.4.1.1
221
### Fixed
322
- Address possible race condition resulting in KeyError exception when calling pop() on an empty set

resources/lib/youtube_plugin/kodion/context/abstract_context.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,12 @@ def sleep(timeout=None):
709709
def tear_down(self):
710710
pass
711711

712-
def ipc_exec(self, target, timeout=None, payload=None, raise_exc=False):
712+
def ipc_exec(self,
713+
target,
714+
timeout=None,
715+
payload=None,
716+
raise_exc=False,
717+
stacklevel=2):
713718
raise NotImplementedError()
714719

715720
def is_plugin_folder(self, folder_name=None):

resources/lib/youtube_plugin/kodion/context/xbmc/xbmc_context.py

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
CHANNEL_ID,
3333
CONTENT,
3434
FOLDER_NAME,
35+
FOLDER_URI,
3536
PLAYLIST_ID,
3637
PLAY_FORCE_AUDIO,
3738
SERVICE_IPC,
@@ -1025,13 +1026,18 @@ def tear_down(self):
10251026
except AttributeError:
10261027
pass
10271028

1028-
def ipc_exec(self, target, timeout=None, payload=None, raise_exc=False):
1029+
def ipc_exec(self,
1030+
target,
1031+
timeout=None,
1032+
payload=None,
1033+
raise_exc=False,
1034+
stacklevel=2):
10291035
if not XbmcContextUI.get_property(SERVICE_RUNNING_FLAG, as_bool=True):
10301036
msg = 'Service IPC - Monitor has not started'
10311037
XbmcContextUI.set_property(SERVICE_RUNNING_FLAG, BUSY_FLAG)
10321038
if raise_exc:
10331039
raise RuntimeError(msg)
1034-
self.log.warning_trace(msg)
1040+
self.log.warning_trace(msg, stacklevel=stacklevel)
10351041
return None
10361042

10371043
data = {'target': target, 'response_required': bool(timeout)}
@@ -1047,32 +1053,50 @@ def ipc_exec(self, target, timeout=None, payload=None, raise_exc=False):
10471053
response = IPCMonitor(target, timeout)
10481054
if response.received:
10491055
value = response.value
1050-
if value:
1051-
self.log.debug(('Service IPC - Responded',
1052-
'Procedure: {target!r}',
1053-
'Latency: {latency:.2f}ms'),
1054-
target=target,
1055-
latency=response.latency)
1056-
elif value is False:
1057-
self.log.error_trace(('Service IPC - Failed',
1058-
'Procedure: {target!r}',
1059-
'Latency: {latency:.2f}ms'),
1060-
target=target,
1061-
latency=response.latency)
1056+
if value is False:
1057+
log_level = logging.ERROR
1058+
log_value = 'FAILED'
1059+
stack_info = True
1060+
else:
1061+
log_level = logging.DEBUG
1062+
log_value = value
1063+
stack_info = False
1064+
self.log.log(
1065+
level=log_level,
1066+
msg='Service IPC <{target}({payload})>:'
1067+
' {value} (in {time_ms:.2f}ms)',
1068+
target=target,
1069+
payload=payload,
1070+
value=log_value,
1071+
time_ms=response.latency,
1072+
stack_info=stack_info,
1073+
stacklevel=stacklevel,
1074+
)
10621075
else:
10631076
value = None
1064-
self.log.error_trace(('Service IPC - Timed out',
1065-
'Procedure: {target!r}',
1066-
'Timeout: {timeout:.2f}s'),
1067-
target=target,
1068-
timeout=timeout)
1077+
self.log.error_trace(
1078+
'Service IPC <{target}({payload})>:'
1079+
' TIMED OUT (in {time_s:.2f}s)',
1080+
target=target,
1081+
payload=payload,
1082+
time_s=timeout,
1083+
stacklevel=stacklevel,
1084+
)
10691085
return value
10701086

1071-
def is_plugin_folder(self, folder_name=None):
1072-
if folder_name is None:
1073-
folder_name = XbmcContextUI.get_container_info(FOLDER_NAME,
1074-
container_id=None)
1075-
return folder_name == self._plugin_name
1087+
def is_plugin_folder(self, folder_path='', name=False):
1088+
if name:
1089+
return XbmcContextUI.get_container_info(
1090+
FOLDER_NAME,
1091+
container_id=None,
1092+
) == self._plugin_name
1093+
return self.is_plugin_path(
1094+
XbmcContextUI.get_container_info(
1095+
FOLDER_URI,
1096+
container_id=None,
1097+
),
1098+
folder_path,
1099+
)
10761100

10771101
def refresh_requested(self, force=False, on=False, off=False, params=None):
10781102
if params is None:

resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
VIDEO_ID,
3838
)
3939
from ...utils.datetime import datetime_to_since, utc_to_local
40-
from ...utils.redact import redact_ip_in_uri
4140
from ...utils.system_version import current_system_version
4241

4342

@@ -429,9 +428,9 @@ def set_info(list_item, item, properties, set_play_count=True, resume=True):
429428

430429
def playback_item(context, media_item, show_fanart=None, **_kwargs):
431430
uri = media_item.get_uri()
432-
logging.debug('Converting %s for playback: %r',
433-
media_item.__class__.__name__,
434-
redact_ip_in_uri(uri))
431+
logging.debug('Converting {type} for playback: {uri!u}',
432+
type=media_item.__class__.__name__,
433+
uri=uri)
435434

436435
params = context.get_params()
437436
settings = context.get_settings()
@@ -485,7 +484,8 @@ def playback_item(context, media_item, show_fanart=None, **_kwargs):
485484
props['inputstream.adaptive.stream_selection_type'] = 'manual-osd'
486485
elif 'auto' in stream_select:
487486
props['inputstream.adaptive.stream_selection_type'] = 'adaptive'
488-
props['inputstream.adaptive.chooser_resolution_max'] = 'auto'
487+
if current_system_version.compatible(21):
488+
props['inputstream.adaptive.chooser_resolution_max'] = 'auto'
489489

490490
if current_system_version.compatible(19):
491491
props['inputstream'] = 'inputstream.adaptive'

resources/lib/youtube_plugin/kodion/json_store/json_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def save(self, data, update=False, process=True, ipc=True, stacklevel=2):
106106
self._context.get_ui().set_property(
107107
'-'.join((FILE_WRITE, filepath)),
108108
to_unicode(_data),
109-
log_value='<redacted>',
109+
log_redact='REDACTED',
110110
)
111111
response = self._context.ipc_exec(
112112
FILE_WRITE,
@@ -158,7 +158,7 @@ def load(self, process=True, ipc=True, stacklevel=2):
158158
) is not False:
159159
data = self._context.get_ui().get_property(
160160
'-'.join((FILE_READ, filepath)),
161-
log_value='<redacted>',
161+
log_redact='REDACTED',
162162
)
163163
else:
164164
raise IOError

resources/lib/youtube_plugin/kodion/logging.py

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from .compatibility import StringIO, string_type, to_str, xbmc
2222
from .constants import ADDON_ID
23-
from .utils.convert_format import to_unicode
23+
from .utils.convert_format import to_unicode, urls_in_text
2424
from .utils.redact import (
2525
parse_and_redact_uri,
2626
redact_auth_header,
@@ -74,24 +74,32 @@ def formatStack(self, stack_info):
7474

7575
def format(self, record):
7676
record.message = to_unicode(record.getMessage())
77+
7778
if self.usesTime():
7879
record.asctime = self.formatTime(record, self.datefmt)
80+
7981
s = self.formatMessage(record)
82+
83+
if record.stack_info:
84+
if not record.stack_text:
85+
stack_text = self.formatStack(record.stack_info)
86+
if getattr(record, '__redact_stack__', False):
87+
stack_text = urls_in_text(stack_text, parse_and_redact_uri)
88+
record.stack_text = stack_text
89+
if s[-1:] != '\n':
90+
s += '\n\n'
91+
s += record.stack_text
92+
8093
if record.exc_info:
8194
if not record.exc_text:
82-
record.exc_text = self.formatException(record.exc_info)
83-
if record.exc_text:
84-
if record.stack_info:
85-
if s[-1:] != '\n':
86-
s += '\n\n'
87-
s += self.formatStack(record.stack_info)
95+
exc_text = self.formatException(record.exc_info)
96+
if getattr(record, '__redact_exc__', False):
97+
exc_text = urls_in_text(exc_text, parse_and_redact_uri)
98+
record.exc_text = exc_text
8899
if s[-1:] != '\n':
89100
s += '\n\n'
90101
s += record.exc_text
91-
elif record.stack_info:
92-
if s[-1:] != '\n':
93-
s += '\n\n'
94-
s += self.formatStack(record.stack_info)
102+
95103
return s
96104

97105

@@ -308,8 +316,7 @@ def stack_info(self, value):
308316

309317
class LogRecord(logging.LogRecord):
310318
def __init__(self, name, level, pathname, lineno, msg, args, exc_info,
311-
func=None, **kwargs):
312-
stack_info = kwargs.pop('sinfo', None)
319+
func=None, sinfo=None, extra=None, **kwargs):
313320
super(LogRecord, self).__init__(name,
314321
level,
315322
pathname,
@@ -319,7 +326,21 @@ def __init__(self, name, level, pathname, lineno, msg, args, exc_info,
319326
exc_info,
320327
func=func,
321328
**kwargs)
322-
self.stack_info = stack_info
329+
self.message = None
330+
self.asctime = None
331+
self.stack_info = sinfo
332+
self.stack_text = None
333+
if extra is not None:
334+
attrs = self.__dict__
335+
duplicate_attrs = set(extra).intersection(attrs.keys())
336+
if duplicate_attrs:
337+
raise KeyError(
338+
"Attempt to overwrite LogRecord attributes: ('%s',)" % (
339+
"', '".join(duplicate_attrs)
340+
)
341+
)
342+
else:
343+
attrs.update(extra)
323344

324345
if not current_system_version.compatible(19):
325346
def getMessage(self):
@@ -423,21 +444,18 @@ def findCaller(self, stack_info=False, stacklevel=1):
423444

424445
def makeRecord(self, name, level, fn, lno, msg, args, exc_info,
425446
func=None, extra=None, sinfo=None):
426-
rv = LogRecord(name,
427-
level,
428-
fn,
429-
lno,
430-
msg,
431-
args,
432-
exc_info,
433-
func=func,
434-
sinfo=sinfo)
435-
if extra is not None:
436-
for key in extra:
437-
if (key in ["message", "asctime"]) or (key in rv.__dict__):
438-
raise KeyError("Attempt to overwrite %r in LogRecord" % key)
439-
rv.__dict__[key] = extra[key]
440-
return rv
447+
return LogRecord(
448+
name,
449+
level,
450+
fn,
451+
lno,
452+
msg,
453+
args,
454+
exc_info,
455+
func=func,
456+
sinfo=sinfo,
457+
extra=extra,
458+
)
441459

442460
def exception(self, msg, *args, **kwargs):
443461
if self.isEnabledFor(ERROR):

resources/lib/youtube_plugin/kodion/monitors/player_monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def onAVStarted(self):
439439

440440
player_data = ui.pop_property(PLAYER_DATA,
441441
process=json.loads,
442-
log_process=redact_params)
442+
log_redact=True)
443443
if not player_data:
444444
return
445445
self.cleanup_threads()

resources/lib/youtube_plugin/kodion/monitors/service_monitor.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def onNotification(self, sender, method, data):
213213
self._context.get_ui().set_property(
214214
'-'.join((FILE_READ, filepath)),
215215
file.read(),
216-
log_value='<redacted>',
216+
log_redact='REDACTED',
217217
)
218218
response = True
219219
except (IOError, OSError):
@@ -222,7 +222,7 @@ def onNotification(self, sender, method, data):
222222
with write_access:
223223
content = self._context.get_ui().pop_property(
224224
'-'.join((FILE_WRITE, filepath)),
225-
log_value='<redacted>',
225+
log_redact='REDACTED',
226226
)
227227
response = None
228228
if content:
@@ -338,12 +338,15 @@ def onSettingsChanged(self, force=False):
338338
log_level = settings.log_level()
339339
if log_level:
340340
self.log.debugging = True
341+
# Verbose
341342
if log_level & 2:
342343
self.log.stack_info = True
343344
self.log.verbose_logging = True
345+
# Enabled or Auto on
344346
else:
345347
self.log.stack_info = False
346348
self.log.verbose_logging = False
349+
# Disabled or Auto off
347350
else:
348351
self.log.debugging = False
349352
self.log.stack_info = False

0 commit comments

Comments
 (0)