Skip to content

Commit

Permalink
Merge pull request #798 from MoojMidge/master
Browse files Browse the repository at this point in the history
v7.0.8+beta.2
  • Loading branch information
MoojMidge authored Jun 17, 2024
2 parents 54b0233 + bf75de8 commit 995b95f
Show file tree
Hide file tree
Showing 38 changed files with 558 additions and 336 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.8+beta.1" provider-name="anxdpanic, bromix, MoojMidge">
<addon id="plugin.video.youtube" name="YouTube" version="7.0.8+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
12 changes: 12 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## v7.0.8+beta.2
### Fixed
- Fix various caching issues #786 #797
- Fix including un-redacted IP address in debug logs

### Changed
- Test not starting/checking for http server until required for playback #746
- Invalidate portion of playlist cache if item added to playlist #797

### New
- Use placeholder in empty listings to provide info and allow refreshing #797

## v7.0.8+beta.1
### Fixed
- Update selection and sorting of streams to fix missing live streams
Expand Down
8 changes: 8 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -1564,3 +1564,11 @@ msgstr ""
msgctxt "#30814"
msgid "feed history"
msgstr ""

msgctxt "#30815"
msgid "Go back..."
msgstr ""

msgctxt "#30816"
msgid "List is empty.[CR][CR]Refresh from context menu or try again later."
msgstr ""
12 changes: 11 additions & 1 deletion resources/lib/youtube_plugin/kodion/abstract_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
NewSearchItem,
NextPageItem,
SearchHistoryItem,
UriItem,
)
from .utils import to_unicode

Expand Down Expand Up @@ -51,6 +52,12 @@ def __init__(self):
'(?P<path>/[^?]+?)(?:/*[?].+|/*)$'
)), self._internal_goto_page)

self.register_path(r''.join((
'^',
paths.COMMAND,
'/(?P<command>[^?]+?)(?:/*[?].+|/*)$'
)), self._on_command)

self.register_path(r''.join((
'^',
paths.WATCH_LATER,
Expand Down Expand Up @@ -223,7 +230,6 @@ def reroute(self, context, re_match=None, path=None, params=None):
try:
result, options = function_cache.run(
self.navigate,
seconds=None,
_refresh=True,
_scope=function_cache.SCOPE_NONE,
context=context.clone(path, params),
Expand Down Expand Up @@ -333,6 +339,10 @@ def _internal_search(self, context, re_match):

return result, {self.RESULT_CACHE_TO_DISC: False}

def _on_command(self, _context, re_match):
command = re_match.group('command')
return UriItem('command://{0}'.format(command))

def handle_exception(self, context, exception_to_handle):
return True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


BOOKMARKS = '/kodion/bookmarks'
COMMAND = '/kodion/command'
EXTERNAL_SEARCH = '/search'
GOTO_PAGE = '/kodion/goto_page'
ROUTE = '/kodion/route'
Expand Down
98 changes: 53 additions & 45 deletions resources/lib/youtube_plugin/kodion/context/abstract_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class AbstractContext(object):

def __init__(self, path='/', params=None, plugin_id=''):
self._access_manager = None
self._uuid = None

self._bookmarks_list = None
self._data_cache = None
Expand Down Expand Up @@ -151,76 +152,83 @@ def get_region(self):
raise NotImplementedError()

def get_playback_history(self):
if not self._playback_history:
uuid = self.get_access_manager().get_current_user_id()
filename = 'history.sqlite'
filepath = os.path.join(self.get_data_path(), uuid, filename)
uuid = self.get_uuid()
if not self._playback_history or self._playback_history.uuid != uuid:
filepath = (self.get_data_path(), uuid, 'history.sqlite')
self._playback_history = PlaybackHistory(filepath)
return self._playback_history

def get_feed_history(self):
if not self._feed_history:
uuid = self.get_access_manager().get_current_user_id()
filename = 'feeds.sqlite'
filepath = os.path.join(self.get_data_path(), uuid, filename)
uuid = self.get_uuid()
if not self._feed_history or self._feed_history.uuid != uuid:
filepath = (self.get_data_path(), uuid, 'feeds.sqlite')
self._feed_history = FeedHistory(filepath)
return self._feed_history

def get_data_cache(self):
if not self._data_cache:
settings = self.get_settings()
cache_size = settings.cache_size() / 2
uuid = self.get_access_manager().get_current_user_id()
filename = 'data_cache.sqlite'
filepath = os.path.join(self.get_data_path(), uuid, filename)
self._data_cache = DataCache(filepath, max_file_size_mb=cache_size)
uuid = self.get_uuid()
if not self._data_cache or self._data_cache.uuid != uuid:
filepath = (self.get_data_path(), uuid, 'data_cache.sqlite')
self._data_cache = DataCache(
filepath,
max_file_size_mb=self.get_settings().cache_size() / 2,
)
return self._data_cache

def get_function_cache(self):
if not self._function_cache:
settings = self.get_settings()
cache_size = settings.cache_size() / 2
uuid = self.get_access_manager().get_current_user_id()
filename = 'cache.sqlite'
filepath = os.path.join(self.get_data_path(), uuid, filename)
self._function_cache = FunctionCache(filepath,
max_file_size_mb=cache_size)
uuid = self.get_uuid()
if not self._function_cache or self._function_cache.uuid != uuid:
filepath = (self.get_data_path(), uuid, 'cache.sqlite')
self._function_cache = FunctionCache(
filepath,
max_file_size_mb=self.get_settings().cache_size() / 2,
)
return self._function_cache

def get_search_history(self):
if not self._search_history:
settings = self.get_settings()
search_size = settings.get_search_history_size()
uuid = self.get_access_manager().get_current_user_id()
filename = 'search.sqlite'
filepath = os.path.join(self.get_data_path(), uuid, filename)
self._search_history = SearchHistory(filepath,
max_item_count=search_size)
uuid = self.get_uuid()
if not self._search_history or self._search_history.uuid != uuid:
filepath = (self.get_data_path(), uuid, 'search.sqlite')
self._search_history = SearchHistory(
filepath,
max_item_count=self.get_settings().get_search_history_size(),
)
return self._search_history

def get_bookmarks_list(self):
if not self._bookmarks_list:
uuid = self.get_access_manager().get_current_user_id()
filename = 'bookmarks.sqlite'
filepath = os.path.join(self.get_data_path(), uuid, filename)
uuid = self.get_uuid()
if not self._bookmarks_list or self._bookmarks_list.uuid != uuid:
filepath = (self.get_data_path(), uuid, 'bookmarks.sqlite')
self._bookmarks_list = BookmarksList(filepath)
return self._bookmarks_list

def get_watch_later_list(self):
if not self._watch_later_list:
uuid = self.get_access_manager().get_current_user_id()
filename = 'watch_later.sqlite'
filepath = os.path.join(self.get_data_path(), uuid, filename)
uuid = self.get_uuid()
if not self._watch_later_list or self._watch_later_list.uuid != uuid:
filepath = (self.get_data_path(), uuid, 'watch_later.sqlite')
self._watch_later_list = WatchLaterList(filepath)
return self._watch_later_list

def get_access_manager(self):
if not self._access_manager:
self._access_manager = AccessManager(self)
return self._access_manager
def get_uuid(self):
uuid = self._uuid
if uuid:
return uuid
return self.reload_access_manager(get_uuid=True)

def reload_access_manager(self):
self._access_manager = AccessManager(self)
def get_access_manager(self):
access_manager = self._access_manager
if access_manager:
return access_manager
return self.reload_access_manager()

def reload_access_manager(self, get_uuid=False):
access_manager = AccessManager(self)
self._access_manager = access_manager
uuid = access_manager.get_current_user_id()
self._uuid = uuid
if get_uuid:
return uuid
return access_manager

def get_video_playlist(self):
raise NotImplementedError()
Expand Down
17 changes: 14 additions & 3 deletions resources/lib/youtube_plugin/kodion/context/xbmc/xbmc_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ class XbmcContext(AbstractContext):
'my_subscriptions.filter.removed': 30590,
'my_subscriptions.filtered': 30584,
'none': 30561,
'page.next': 30106,
'page.back': 30815,
'page.choose': 30806,
'page.empty': 30816,
'page.next': 30106,
'playlist.added_to': 30714,
'playlist.create': 30522,
'playlist.play.all': 30531,
Expand Down Expand Up @@ -586,14 +588,23 @@ def clone(self, new_path=None, new_params=None):
new_context = XbmcContext(path=new_path,
params=new_params,
plugin_id=self._plugin_id)

new_context._access_manager = self._access_manager
new_context._uuid = self._uuid

new_context._bookmarks_list = self._bookmarks_list
new_context._data_cache = self._data_cache
new_context._feed_history = self._feed_history
new_context._function_cache = self._function_cache
new_context._playback_history = self._playback_history
new_context._search_history = self._search_history
new_context._bookmarks_list = self._bookmarks_list
new_context._watch_later_list = self._watch_later_list
new_context._access_manager = self._access_manager

new_context._ui = self._ui
new_context._video_playlist = self._video_playlist
new_context._audio_playlist = self._audio_playlist
new_context._video_player = self._video_player
new_context._audio_player = self._audio_player

return new_context

Expand Down
2 changes: 2 additions & 0 deletions resources/lib/youtube_plugin/kodion/items/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from . import menu_items
from .audio_item import AudioItem
from .base_item import BaseItem
from .command_item import CommandItem
from .directory_item import DirectoryItem
from .image_item import ImageItem
from .new_search_item import NewSearchItem
Expand All @@ -36,6 +37,7 @@
__all__ = (
'AudioItem',
'BaseItem',
'CommandItem',
'DirectoryItem',
'ImageItem',
'NewSearchItem',
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/youtube_plugin/kodion/items/audio_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class AudioItem(BaseItem):
_playable = True

def __init__(self, name, uri, image='', fanart=''):
def __init__(self, name, uri, image='DefaultAudio.png', fanart=None):
super(AudioItem, self).__init__(name, uri, image, fanart)
self._start_time = None
self._duration = -1
Expand Down
20 changes: 11 additions & 9 deletions resources/lib/youtube_plugin/kodion/items/base_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ class BaseItem(object):

_playable = False

def __init__(self, name, uri, image='', fanart=''):
def __init__(self, name, uri, image=None, fanart=None):
self._version = BaseItem.VERSION

self._name = None
self.set_name(name)

self._uri = uri

self._image = None
self.set_image(image)
self._fanart = None
self.set_fanart(fanart)
self._image = ''
if image:
self.set_image(image)
self._fanart = ''
if fanart:
self.set_fanart(fanart)

self._bookmark_timestamp = None
self._context_menu = None
Expand Down Expand Up @@ -71,10 +73,11 @@ def get_id(self):

def set_name(self, name):
try:
self._name = unescape(name)
name = unescape(name)
except:
self._name = name
return self._name
pass
self._name = name
return name

def get_name(self):
"""
Expand All @@ -95,7 +98,6 @@ def get_uri(self):

def set_image(self, image):
if not image:
self._image = ''
return

if '{media}/' in image:
Expand Down
42 changes: 42 additions & 0 deletions resources/lib/youtube_plugin/kodion/items/command_item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2014-2016 bromix (plugin.video.youtube)
Copyright (C) 2016-2018 plugin.video.youtube
SPDX-License-Identifier: GPL-2.0-only
See LICENSES/GPL-2.0-only for more information.
"""

from __future__ import absolute_import, division, unicode_literals

from . import menu_items
from .directory_item import DirectoryItem
from ..constants import paths


class CommandItem(DirectoryItem):
def __init__(self,
name,
command,
context,
image=None,
fanart=None,
plot=None):
super(CommandItem, self).__init__(
name,
context.create_uri((paths.COMMAND, command)),
image=image,
fanart=fanart,
plot=plot,
action=True,
category_label='__inherit__',
)

context_menu = [
menu_items.refresh(context),
menu_items.goto_home(context),
menu_items.goto_quick_search(context),
menu_items.separator(),
]
self.add_context_menu(context_menu)
Loading

0 comments on commit 995b95f

Please sign in to comment.