Skip to content

Commit

Permalink
Merge pull request #829 from MoojMidge/master
Browse files Browse the repository at this point in the history
Version bump v7.0.9+beta.2
  • Loading branch information
MoojMidge authored Jul 5, 2024
2 parents 8b7e5c3 + 72d7d11 commit c60834a
Show file tree
Hide file tree
Showing 33 changed files with 438 additions and 266 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.9+beta.1" provider-name="anxdpanic, bromix, MoojMidge">
<addon id="plugin.video.youtube" name="YouTube" version="7.0.9+beta.2" 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
21 changes: 20 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
## v7.0.9+beta.2
### Fixed
- Fix ask for video quality setting being inconsistently applied
- Fix http server not sleeping after initial start of service #746 #801
- Fix not reloading WL playlist if open after playback of video in WL

### Changed
- Rename My Subscriptions plugin url
- From:
- plugin://plugin.video.youtube/special/new_uploaded_videos_tv
- plugin://plugin.video.youtube/special/new_uploaded_videos_tv_filtered
- To:
- plugin://plugin.video.youtube/special/my_subscriptions
- plugin://plugin.video.youtube/special/my_subscriptions_filtered
- Old url retained for backwards compatibility, to be removed with Kodi v22

### New
- Add notifications for creating/removing/clearing bookmarks #720

## v7.0.9+beta.1
### Fixed
- Fix renaming playlists
- Improve https server wakeup #746 #801
- Improve http server wakeup #746 #801

### Changed
- Make live query parameter optional when playing channel live stream
Expand Down
2 changes: 1 addition & 1 deletion resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ msgid "Switch to '%s' now?"
msgstr ""

msgctxt "#30666"
msgid "Removed '%s'"
msgid "%s removed"
msgstr ""

msgctxt "#30667"
Expand Down
25 changes: 17 additions & 8 deletions resources/lib/youtube_plugin/kodion/abstract_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ def register_path(self, re_path, method):
:param method: method to be registered
:return:
"""
self._dict_path[re.compile(re_path, re.UNICODE)] = method
self._dict_path[re.compile(re_path, re.UNICODE)] = {
'method': method,
'bound': isinstance(getattr(method, '__self__', None),
self.__class__),
}
return method

def run_wizard(self, context):
settings = context.get_settings()
Expand Down Expand Up @@ -142,7 +147,7 @@ def get_wizard_steps(self, context):

def navigate(self, context):
path = context.get_path()
for re_path, method in self._dict_path.items():
for re_path, handler in self._dict_path.items():
re_match = re_path.search(path)
if not re_match:
continue
Expand All @@ -151,7 +156,10 @@ def navigate(self, context):
self.RESULT_CACHE_TO_DISC: True,
self.RESULT_UPDATE_LISTING: False,
}
result = method(context, re_match)
if handler['bound']:
result = handler['method'](context, re_match)
else:
result = handler['method'](self, context, re_match)
if isinstance(result, tuple):
result, new_options = result
options.update(new_options)
Expand All @@ -162,7 +170,7 @@ def navigate(self, context):

return result, options

raise KodionException("Mapping for path '%s' not found" % path)
raise KodionException('Mapping for path "%s" not found' % path)

# noinspection PyUnusedLocal
@staticmethod
Expand Down Expand Up @@ -266,12 +274,12 @@ def _internal_search(self, context, re_match):
if not command or command == 'query':
query = to_unicode(params.get('q', ''))
if not params.get('incognito') and not params.get('channel_id'):
search_history.update(query)
search_history.add_item(query)
return self.on_search(query, context, re_match)

if command == 'remove':
query = to_unicode(params.get('q', ''))
search_history.remove(query)
search_history.del_item(query)
ui.refresh_container()
return True

Expand All @@ -281,7 +289,8 @@ def _internal_search(self, context, re_match):
context.localize('search.rename'), query
)
if result:
search_history.rename(query, new_query)
search_history.del_item(query)
search_history.add_item(new_query)
ui.refresh_container()
return True

Expand Down Expand Up @@ -317,7 +326,7 @@ def _internal_search(self, context, re_match):
data_cache.set_item('search_query', query)

if not params.get('incognito') and not params.get('channel_id'):
search_history.update(query)
search_history.add_item(query)
context.set_path(PATHS.SEARCH, 'query')
return self.on_search(query, context, re_match)

Expand Down
3 changes: 2 additions & 1 deletion resources/lib/youtube_plugin/kodion/constants/const_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
HOME = '/home'
LIKED_VIDEOS = '/channel/mine/playlist/LL'
MY_PLAYLISTS = '/channel/mine/playlists'
MY_SUBSCRIPTIONS = '/special/new_uploaded_videos'
MY_SUBSCRIPTIONS = '/special/my_subscriptions'
PLAY = '/play'
SUBSCRIPTIONS = '/subscriptions/list'

API = '/youtube/api'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .. import logger
from ..compatibility import quote, to_str, urlencode
from ..constants import (
PATHS,
PLAY_FORCE_AUDIO,
PLAY_PROMPT_QUALITY,
PLAY_PROMPT_SUBTITLES,
Expand Down Expand Up @@ -72,9 +73,9 @@ class AbstractContext(object):
'refresh',
}
_FLOAT_PARAMS = {
'end',
'seek',
'start',
'end'
}
_LIST_PARAMS = {
'channel_ids',
Expand Down Expand Up @@ -262,7 +263,7 @@ def create_uri(self, path=None, params=None):
elif path:
uri = path
else:
uri = '/' if params else '/?'
uri = '/'

uri = self._plugin_id.join(('plugin://', uri))

Expand Down Expand Up @@ -337,7 +338,7 @@ def parse_params(self, params=None):
elif param == 'action':
if parsed_value in {'play_all', 'play_video'}:
to_delete.append(param)
self.set_path('play')
self.set_path(PATHS.PLAY)
continue
elif param == 'videoid':
to_delete.append(param)
Expand Down
18 changes: 8 additions & 10 deletions resources/lib/youtube_plugin/kodion/context/xbmc/xbmc_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ class XbmcContext(AbstractContext):
'archive': 30105,
'are_you_sure': 30703,
'auto_remove_watch_later': 30515,
'bookmark': 30101,
'bookmark.channel': 30803,
'bookmark.created': 21362,
'bookmark.remove': 20404,
'bookmarks': 30100,
'bookmarks.add': 30101,
'bookmarks.add.channel': 30803,
'bookmarks.clear': 30801,
'bookmarks.clear.confirm': 30802,
'bookmarks.remove': 20404,
'browse_channels': 30512,
'cancel': 30615,
'channels': 30500,
Expand Down Expand Up @@ -212,7 +213,7 @@ class XbmcContext(AbstractContext):
'sign.twice.text': 30547,
'sign.twice.title': 30546,
'stats.commentCount': 30732,
# 'stats.favoriteCount': 30100,
# 'stats.favoriteCount': 1036,
'stats.likeCount': 30733,
'stats.viewCount': 30767,
'stream.alternate': 30747,
Expand Down Expand Up @@ -364,23 +365,20 @@ def get_region(self):
pass # implement from abstract

def is_plugin_path(self, uri, uri_path='', partial=False):
plugin = self.get_id()

if isinstance(uri_path, (list, tuple)):
if partial:
paths = ['plugin://{0}/{1}'.format(plugin, path).rstrip('/')
for path in uri_path]
paths = [self.create_uri(path).rstrip('/') for path in uri_path]
else:
paths = []
for path in uri_path:
path = 'plugin://{0}/{1}'.format(plugin, path).rstrip('/')
path = self.create_uri(path).rstrip('/')
paths.extend((
path + '/',
path + '?'
))
return uri.startswith(tuple(paths))

uri_path = 'plugin://{0}/{1}'.format(plugin, uri_path).rstrip('/')
uri_path = self.create_uri(uri_path).rstrip('/')
if not partial:
uri_path = (
uri_path + '/',
Expand Down
24 changes: 12 additions & 12 deletions resources/lib/youtube_plugin/kodion/items/menu_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def play_with(context, video_id):
return (
context.localize('video.play.with'),
'RunPlugin({0})'.format(context.create_uri(
('play',),
(PATHS.PLAY,),
{
'video_id': video_id,
PLAY_WITH: True,
Expand Down Expand Up @@ -107,7 +107,7 @@ def play_all_from_playlist(context, playlist_id, video_id=''):
return (
context.localize('playlist.play.from_here'),
'RunPlugin({0})'.format(context.create_uri(
('play',),
(PATHS.PLAY,),
{
'playlist_id': playlist_id,
'video_id': video_id,
Expand All @@ -118,7 +118,7 @@ def play_all_from_playlist(context, playlist_id, video_id=''):
return (
context.localize('playlist.play.all'),
'RunPlugin({0})'.format(context.create_uri(
('play',),
(PATHS.PLAY,),
{
'playlist_id': playlist_id,
'play': True,
Expand Down Expand Up @@ -366,7 +366,7 @@ def play_with_subtitles(context, video_id):
return (
context.localize('video.play.with_subtitles'),
'RunPlugin({0})'.format(context.create_uri(
('play',),
(PATHS.PLAY,),
{
'video_id': video_id,
PLAY_PROMPT_SUBTITLES: True,
Expand All @@ -379,7 +379,7 @@ def play_audio_only(context, video_id):
return (
context.localize('video.play.audio_only'),
'RunPlugin({0})'.format(context.create_uri(
('play',),
(PATHS.PLAY,),
{
'video_id': video_id,
PLAY_FORCE_AUDIO: True,
Expand All @@ -392,7 +392,7 @@ def play_ask_for_quality(context, video_id):
return (
context.localize('video.play.ask_for_quality'),
'RunPlugin({0})'.format(context.create_uri(
('play',),
(PATHS.PLAY,),
{
'video_id': video_id,
PLAY_PROMPT_QUALITY: True,
Expand Down Expand Up @@ -465,9 +465,9 @@ def history_reset_resume(context, video_id):
)


def bookmarks_add(context, item):
def bookmark_add(context, item):
return (
context.localize('bookmarks.add'),
context.localize('bookmark'),
'RunPlugin({0})'.format(context.create_uri(
(PATHS.BOOKMARKS, 'add',),
{
Expand All @@ -478,9 +478,9 @@ def bookmarks_add(context, item):
)


def bookmarks_add_channel(context, channel_id, channel_name=''):
def bookmark_add_channel(context, channel_id, channel_name=''):
return (
(context.localize('bookmarks.add.channel') % (
(context.localize('bookmark.channel') % (
context.get_ui().bold(channel_name) if channel_name else
context.localize(19029)
)),
Expand All @@ -494,9 +494,9 @@ def bookmarks_add_channel(context, channel_id, channel_name=''):
)


def bookmarks_remove(context, item_id):
def bookmark_remove(context, item_id):
return (
context.localize('bookmarks.remove'),
context.localize('bookmark.remove'),
'RunPlugin({0})'.format(context.create_uri(
(PATHS.BOOKMARKS, 'remove',),
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ def video_listitem(context,
if not set_play_count:
video_id = video_item.video_id
playback_history = context.get_playback_history()
playback_history.update(video_id, dict(
playback_history.set_item(video_id, dict(
playback_history.get_item(video_id) or {},
play_count=int(not video_item.get_play_count()),
played_time=0.0,
Expand Down
11 changes: 7 additions & 4 deletions resources/lib/youtube_plugin/kodion/monitors/player_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from ..compatibility import xbmc
from ..constants import (
BUSY_FLAG,
PATHS,
PLAYBACK_STARTED,
PLAYBACK_STOPPED,
PLAYER_DATA,
Expand Down Expand Up @@ -122,7 +123,7 @@ def run(self):
break

if (not current_file.startswith(playing_file) and not (
self._context.is_plugin_path(current_file, 'play')
self._context.is_plugin_path(current_file, PATHS.PLAY)
and video_id_param in current_file
)) or total_time <= 0:
self.stop()
Expand Down Expand Up @@ -217,8 +218,8 @@ def run(self):
status=(segment_end, segment_end, segment_end, 'stopped'),
)
if use_local_history:
self._context.get_playback_history().update(self.video_id,
play_data)
self._context.get_playback_history().update_item(self.video_id,
play_data)

self._context.send_notification(PLAYBACK_STOPPED, self.playback_data)
self._context.log_debug('Playback stopped [{video_id}]:'
Expand All @@ -237,6 +238,7 @@ def run(self):
)
if playlist_item_id:
self._provider.on_playlist_x(
self._provider,
self._context,
method='remove',
category='video',
Expand All @@ -246,7 +248,7 @@ def run(self):
confirmed=True,
)
else:
self._context.get_watch_later_list().remove(self.video_id)
self._context.get_watch_later_list().del_item(self.video_id)

if logged_in and not refresh_only:
history_id = access_manager.get_watch_history_id()
Expand All @@ -267,6 +269,7 @@ def run(self):
'/{0}/{1}/'.format(self.video_id, rating)
)
self._provider.on_video_x(
self._provider,
self._context,
rating_match,
method='rate',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, context):

self.httpd = None
self.httpd_thread = None
self.httpd_sleep_allowed = True

self.refresh = False
self.interrupt = False
Expand Down Expand Up @@ -103,6 +104,7 @@ def onNotification(self, sender, method, data):
self.interrupt = True
elif target == SERVER_WAKEUP:
if not self.httpd and self.httpd_required():
self.httpd_sleep_allowed = False
self.start_httpd()
if data.get('response_required'):
self.set_property(WAKEUP, target)
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/youtube_plugin/kodion/script_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def switch_to_user(user):
username = access_manager.get_username(user)
if ui.on_remove_content(username):
access_manager.remove_user(user)
ui.show_notification(localize('removed') % username,
ui.show_notification(localize('removed') % '"%s"' % username,
localize('remove'))
if user == 0:
access_manager.add_user(username=localize('user.default'),
Expand Down
Loading

0 comments on commit c60834a

Please sign in to comment.