Skip to content

Commit

Permalink
Merge pull request #723 from MoojMidge/v7.0.6
Browse files Browse the repository at this point in the history
v7.0.6+beta.3
  • Loading branch information
MoojMidge authored Apr 26, 2024
2 parents e15c5fa + d5826e5 commit bdb9880
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 43 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.0.6+beta.2" provider-name="anxdpanic, bromix, MoojMidge">
<addon id="plugin.video.youtube" name="YouTube" version="7.0.6+beta.3" 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: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v7.0.6+beta.3
### Fixed
- Fix adding and viewing items to internal bookmarks and watchlater list #720

## v7.0.6+beta.2
### Fixed
- Further fixes for multiple busy dialog crash workaround
Expand Down
23 changes: 12 additions & 11 deletions resources/lib/youtube_plugin/kodion/items/base_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,10 @@ def playable(self):

class _Encoder(json.JSONEncoder):
def encode(self, obj, nested=False):
if isinstance(obj, string_type):
output = to_str(obj)
elif isinstance(obj, dict):
output = {to_str(key): self.encode(value, nested=True)
for key, value in obj.items()}
elif isinstance(obj, (list, tuple)):
output = [self.encode(item, nested=True) for item in obj]
elif isinstance(obj, (date, datetime)):
if isinstance(obj, (date, datetime)):
class_name = obj.__class__.__name__
if 'fromisoformat' in dir(obj):
output = {
obj = {
'__class__': class_name,
'__isoformat__': obj.isoformat(),
}
Expand All @@ -232,14 +225,22 @@ def encode(self, obj, nested=False):
format_string = '%Y-%m-%dT%H:%M:%S'
else:
format_string = '%Y-%m-%d'
output = {
obj = {
'__class__': class_name,
'__format_string__': format_string,
'__value__': obj.strftime(format_string)
}

if isinstance(obj, string_type):
output = to_str(obj)
elif isinstance(obj, dict):
output = {to_str(key): self.encode(value, nested=True)
for key, value in obj.items()}
elif isinstance(obj, (list, tuple)):
output = [self.encode(item, nested=True) for item in obj]
else:
output = obj

if nested:
return to_str(output)
return output
return super(_Encoder, self).encode(output)
3 changes: 3 additions & 0 deletions resources/lib/youtube_plugin/kodion/items/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def from_json(json_data, *args):

item = _ITEM_TYPES[item_type](name='', uri='')

if 'data' in json_data and isinstance(json_data['data'], string_type):
return TypeError

for key, value in json_data.get('data', {}).items():
if hasattr(item, key):
setattr(item, key, value)
Expand Down
4 changes: 4 additions & 0 deletions resources/lib/youtube_plugin/kodion/sql_store/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ def _get_by_ids(self, item_ids=None, oldest_first=True, limit=-1,
item[0]: self._decode(item[2], process, item)
for item in result if not cut_off or item[1] >= cut_off
}
for item_id, value in list(result.items()):
if value == TypeError:
self._remove(item_id)
del result[item_id]
elif values_only:
result = [
self._decode(item[2], process, item)
Expand Down
65 changes: 34 additions & 31 deletions resources/lib/youtube_plugin/kodion/utils/datetime_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,37 +240,40 @@ def strptime(datetime_str, fmt=None):
if fmt is None:
fmt = '%Y-%m-%d%H%M%S'

if ' ' in datetime_str:
date_part, time_part = datetime_str.split(' ')
elif 'T' in datetime_str:
date_part, time_part = datetime_str.split('T')
else:
date_part = None
time_part = datetime_str

if ':' in time_part:
time_part = time_part.replace(':', '')

if '+' in time_part:
time_part, offset, timezone_part = time_part.partition('+')
elif '-' in time_part:
time_part, offset, timezone_part = time_part.partition('+')
else:
offset = timezone_part = ''

if timezone and timezone_part and offset:
fmt = fmt.replace('%S', '%S%z')
else:
fmt = fmt.replace('%S%z', '%S')

if '.' in time_part:
fmt = fmt.replace('%S', '%S.%f')
else:
fmt = fmt.replace('%S.%f', '%S')

if timezone and timezone_part and offset:
time_part = offset.join((time_part, timezone_part))
datetime_str = ''.join((date_part, time_part)) if date_part else time_part
if ' ' in datetime_str:
date_part, time_part = datetime_str.split(' ')
elif 'T' in datetime_str:
date_part, time_part = datetime_str.split('T')
else:
date_part = None
time_part = datetime_str

if ':' in time_part:
time_part = time_part.replace(':', '')

if '+' in time_part:
time_part, offset, timezone_part = time_part.partition('+')
elif '-' in time_part:
time_part, offset, timezone_part = time_part.partition('+')
else:
offset = timezone_part = ''

if timezone and timezone_part and offset:
fmt = fmt.replace('%S', '%S%z')
else:
fmt = fmt.replace('%S%z', '%S')

if '.' in time_part:
fmt = fmt.replace('%S', '%S.%f')
else:
fmt = fmt.replace('%S.%f', '%S')

if timezone and timezone_part and offset:
time_part = offset.join((time_part, timezone_part))
if date_part:
datetime_str = ''.join((date_part, time_part))
else:
datetime_str = time_part

try:
return datetime.strptime(datetime_str, fmt)
Expand Down

0 comments on commit bdb9880

Please sign in to comment.