Skip to content

Commit

Permalink
Merge pull request #974 from MoojMidge/master
Browse files Browse the repository at this point in the history
v7.1.1+beta.7
  • Loading branch information
MoojMidge authored Nov 14, 2024
2 parents 4cee6a1 + 31d0424 commit 3112b11
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 59 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+beta.6" provider-name="anxdpanic, bromix, MoojMidge">
<addon id="plugin.video.youtube" name="YouTube" version="7.1.1+beta.7" 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
8 changes: 8 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v7.1.1+beta.7
### Fixed
- Fix loading of Watch Later playlist #971
- Also fix other incorrect/missing parameter names

### Changed
- Don't retry server wakeup on error unless settings change

## v7.1.1+beta.6
### Fixed
- Ensure http server is started prior to creating MPD for playback #961
Expand Down
14 changes: 4 additions & 10 deletions resources/lib/youtube_plugin/kodion/abstract_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,8 @@ def run_wizard(self, context):
# ui local variable used for ui.get_view_manager() in unofficial version
ui = context.get_ui()

context.wakeup(
CHECK_SETTINGS,
timeout=5,
payload={'state': 'defer'},
)
settings_state = {'state': 'defer'}
context.wakeup(CHECK_SETTINGS, timeout=5, payload=settings_state)

wizard_steps = self.get_wizard_steps()

Expand All @@ -150,11 +147,8 @@ def run_wizard(self, context):
finally:
settings = context.get_settings(refresh=True)
settings.setup_wizard_enabled(False)
context.wakeup(
CHECK_SETTINGS,
timeout=5,
payload={'state': 'process'},
)
settings_state['state'] = 'process'
context.wakeup(CHECK_SETTINGS, timeout=5, payload=settings_state)

@staticmethod
def get_wizard_steps():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ class XbmcContext(AbstractContext):
'api.personal.disabled': 30637,
'api.personal.failed': 30599,
'api.secret': 30203,
'archive': 30105,
'are_you_sure': 750,
'ask': 863,
'auto_remove_watch_later': 30515,
'bookmark': 30101,
'bookmark.channel': 30803,
'bookmark.created': 21362,
Expand Down Expand Up @@ -125,8 +123,6 @@ class XbmcContext(AbstractContext):
'inputstreamhelper.is_installed': 30625,
'isa.enable.check': 30579,
'key.requirement': 30731,
'latest_videos': 30109,
'library': 30103,
'liked.video': 30716,
'live': 839,
'live.completed': 30647,
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/youtube_plugin/kodion/items/base_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def parse_item_ids_from_uri(self):
def set_name(self, name):
try:
name = unescape(name)
except:
except Exception:
pass
self._name = name
return name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def get_category_label(self):
def set_plot(self, plot):
try:
plot = unescape(plot)
except:
except Exception:
pass
self._plot = plot

Expand Down
42 changes: 31 additions & 11 deletions resources/lib/youtube_plugin/kodion/items/media_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ def __init__(self,
image='DefaultFile.png',
fanart=None,
plot=None,
video_id=None,):
video_id=None,
channel_id=None,
playlist_id=None,
playlist_item_id=None,
subscription_id=None):
super(MediaItem, self).__init__(name, uri, image, fanart)
self._aired = None
self._premiered = None
Expand Down Expand Up @@ -64,10 +68,10 @@ def __init__(self,
self._vod = False

self._video_id = video_id
self._channel_id = None
self._subscription_id = None
self._playlist_id = None
self._playlist_item_id = None
self._channel_id = channel_id
self._subscription_id = subscription_id
self._playlist_id = playlist_id
self._playlist_item_id = playlist_item_id

def set_aired(self, year, month, day):
self._aired = date(year, month, day)
Expand Down Expand Up @@ -181,7 +185,7 @@ def get_mediatype(self):
def set_plot(self, plot):
try:
plot = unescape(plot)
except:
except Exception:
pass
self._plot = plot

Expand All @@ -202,7 +206,7 @@ def get_rating(self):
def set_title(self, title):
try:
title = unescape(title)
except:
except Exception:
pass
self._name = self._title = title

Expand Down Expand Up @@ -342,13 +346,21 @@ def __init__(self,
image='DefaultAudio.png',
fanart=None,
plot=None,
video_id=None):
video_id=None,
channel_id=None,
playlist_id=None,
playlist_item_id=None,
subscription_id=None):
super(AudioItem, self).__init__(name,
uri,
image,
fanart,
plot,
video_id)
video_id,
channel_id,
playlist_id,
playlist_item_id,
subscription_id)
self._album = None

def set_album_name(self, album_name):
Expand All @@ -374,13 +386,21 @@ def __init__(self,
image='DefaultVideo.png',
fanart=None,
plot=None,
video_id=None):
video_id=None,
channel_id=None,
playlist_id=None,
playlist_item_id=None,
subscription_id=None):
super(VideoItem, self).__init__(name,
uri,
image,
fanart,
plot,
video_id)
video_id,
channel_id,
playlist_id,
playlist_item_id,
subscription_id)
self._directors = None
self._episode = None
self._imdb_id = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ def update_access_token(self,
refresh_token=None):
"""
Updates the old access token with the new one.
:param addon_id:
:param access_token:
:param expiry:
:param refresh_token:
Expand Down
32 changes: 22 additions & 10 deletions resources/lib/youtube_plugin/kodion/monitors/service_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, context):
self._old_httpd_address = None
self._old_httpd_port = None
self._use_httpd = None
self._httpd_error = False

self.httpd = None
self.httpd_thread = None
Expand Down Expand Up @@ -137,7 +138,7 @@ def onNotification(self, sender, method, data):
if not self.httpd and self.httpd_required():
response = self.start_httpd()
else:
response = True
response = bool(self.httpd)
if self.httpd_sleep_allowed:
self.httpd_sleep_allowed = None

Expand Down Expand Up @@ -244,7 +245,8 @@ def httpd_address_sync(self):

def start_httpd(self):
if self.httpd:
return
self._httpd_error = False
return True

context = self._context
context.log_debug('HTTPServer: Starting |{ip}:{port}|'
Expand All @@ -255,6 +257,7 @@ def start_httpd(self):
port=self._httpd_port,
context=context)
if not self.httpd:
self._httpd_error = True
return False

self.httpd_thread = threading.Thread(target=self.httpd.serve_forever)
Expand All @@ -264,6 +267,7 @@ def start_httpd(self):
context.log_debug('HTTPServer: Listening on |{ip}:{port}|'
.format(ip=address[0],
port=address[1]))
self._httpd_error = False
return True

def shutdown_httpd(self):
Expand Down Expand Up @@ -296,13 +300,21 @@ def ping_httpd(self):
return self.httpd and httpd_status(self._context)

def httpd_required(self, settings=None, while_idle=False):
if while_idle:
if settings:
required = (settings.use_isa()
or settings.api_config_page()
or settings.support_alternative_player())
self._use_httpd = required

elif self._httpd_error:
required = False

elif while_idle:
settings = self._context.get_settings()
return (settings.api_config_page()
or settings.support_alternative_player())
required = (settings.api_config_page()
or settings.support_alternative_player())

if settings:
self._use_httpd = (settings.use_isa()
or settings.api_config_page()
or settings.support_alternative_player())
return self._use_httpd
else:
required = self._use_httpd

return required
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def update_total(self, new_total, **kwargs):
self._total = int(new_total)
self.update(steps=0, **kwargs)

def grow_total(self, new_total, **kwargs):
def grow_total(self, new_total):
total = int(new_total)
if total > self._total:
self._total = total
Expand Down
15 changes: 8 additions & 7 deletions resources/lib/youtube_plugin/kodion/utils/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,17 @@ def find_video_id(plugin_path):
return ''


def friendly_number(input, precision=3, scale=('', 'K', 'M', 'B'), as_str=True):
_input = float('{input:.{precision}g}'.format(
input=float(input), precision=precision
def friendly_number(value, precision=3, scale=('', 'K', 'M', 'B'), as_str=True):
value = float('{value:.{precision}g}'.format(
value=float(value),
precision=precision,
))
_abs_input = abs(_input)
magnitude = 0 if _abs_input < 1000 else int(log(floor(_abs_input), 1000))
abs_value = abs(value)
magnitude = 0 if abs_value < 1000 else int(log(floor(abs_value), 1000))
output = '{output:f}'.format(
output=_input / 1000 ** magnitude
output=value / 1000 ** magnitude
).rstrip('0').rstrip('.') + scale[magnitude]
return output if as_str else (output, _input)
return output if as_str else (output, value)


_RE_PERIODS = re.compile(r'([\d.]+)(d|h|m|s|$)')
Expand Down
9 changes: 6 additions & 3 deletions resources/lib/youtube_plugin/youtube/client/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,12 @@ def update_watch_history(self, context, video_id, url, status=None):
' current time={cmt},'
' segment start={st},'
' segment end={et},'
' state={state}'.format(
video_id=video_id, cmt=cmt, st=st, et=et, state=state
))
' state={state}'
.format(video_id=video_id,
cmt=cmt,
st=st,
et=et,
state=state))

headers = {
'Host': 's.youtube.com',
Expand Down
8 changes: 4 additions & 4 deletions resources/lib/youtube_plugin/youtube/helper/stream_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1669,10 +1669,10 @@ def load_stream_info(self, video_id):

subtitles = Subtitles(context, video_id)
query_subtitles = client.get('_query_subtitles')
if (not is_live or live_dvr) and (
query_subtitles is True
or (query_subtitles
and subtitles.sub_selection == subtitles.LANG_ALL)):
if ((not is_live or live_dvr)
and (query_subtitles is True
or (query_subtitles
and subtitles.sub_selection == subtitles.LANG_ALL))):
for client_name in ('smart_tv_embedded', 'web', 'android'):
caption_client = self.build_client(client_name, client_data)
if not caption_client:
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/youtube_plugin/youtube/helper/subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def load(self, captions, headers=None):
def _unescape(self, text):
try:
text = unescape(text)
except:
except Exception:
self._context.log_error('Subtitles._unescape - failed: |{text}|'
.format(text=text))
return text
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/youtube_plugin/youtube/helper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ def update_video_infos(provider, context, video_id_dict,
context,
playlist_id=playlist_id,
video_id=playlist_item_id,
item_name=media_item.get_name(),
video_name=media_item.get_name(),
)
)

Expand Down Expand Up @@ -1212,7 +1212,7 @@ def add_related_video_to_playlist(provider, context, client, v3, video_id):
json_data,
process_next_page=False)
page_token = json_data.get('nextPageToken', '')
except:
except Exception:
context.get_ui().show_notification('Failed to add a suggested video.', time_ms=5000)

if result_items:
Expand Down
7 changes: 4 additions & 3 deletions resources/lib/youtube_plugin/youtube/helper/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ def _process_list_response(provider,
playlist_id_dict[item_id] = item

elif kind_type == 'playlistitem':
playlistitem_id = item_id
playlist_item_id = item_id
item_id = snippet['resourceId']['videoId']
# store the id of the playlistItem - needed for deleting item
playlist_item_id_dict[item_id] = playlistitem_id
playlist_item_id_dict[item_id] = playlist_item_id

item_params['video_id'] = item_id
item_uri = context.create_uri(
Expand All @@ -240,7 +240,8 @@ def _process_list_response(provider,
image=image,
fanart=fanart,
plot=description,
video_id=item_id)
video_id=item_id,
playlist_item_id=playlist_item_id)
video_id_dict[item_id] = item

elif kind_type == 'activity':
Expand Down

0 comments on commit 3112b11

Please sign in to comment.