mirror of
https://github.com/anxdpanic/plugin.video.youtube.git
synced 2025-12-06 02:30:50 -08:00
Add Python2 and Kodi 18 compatibility tweaks
- Ensure new style classes are used - Use correct inputstream property for listitems - Use correct infolabel date formatting - Use correct setting type getter/setter for str list - Ignore labelmask parameter in sort methods - Use traditional packages rather than namespace packages
This commit is contained in:
parent
ef9ca693c6
commit
f4d41dba2a
11 changed files with 30 additions and 22 deletions
|
|
@ -20,11 +20,11 @@ import xbmcplugin
|
|||
import xbmcvfs
|
||||
|
||||
from ..abstract_context import AbstractContext
|
||||
from ... import utils
|
||||
from ...player.xbmc.xbmc_player import XbmcPlayer
|
||||
from ...player.xbmc.xbmc_playlist import XbmcPlaylist
|
||||
from ...settings.xbmc.xbmc_plugin_settings import XbmcPluginSettings
|
||||
from ...ui.xbmc.xbmc_context_ui import XbmcContextUI
|
||||
from ...utils import current_system_version, loose_version, to_unicode
|
||||
|
||||
|
||||
class XbmcContext(AbstractContext):
|
||||
|
|
@ -403,7 +403,7 @@ class XbmcContext(AbstractContext):
|
|||
"""
|
||||
source = self._addon if 30000 <= text_id < 31000 else xbmc
|
||||
result = source.getLocalizedString(text_id)
|
||||
result = utils.to_unicode(result) if result else default_text
|
||||
result = to_unicode(result) if result else default_text
|
||||
return result
|
||||
|
||||
def set_content_type(self, content_type):
|
||||
|
|
@ -411,8 +411,9 @@ class XbmcContext(AbstractContext):
|
|||
xbmcplugin.setContent(self._plugin_handle, content_type)
|
||||
|
||||
def add_sort_method(self, *sort_methods):
|
||||
args = slice(None if current_system_version.compatible(19, 0) else 2)
|
||||
for sort_method in sort_methods:
|
||||
xbmcplugin.addSortMethod(self._plugin_handle, *sort_method)
|
||||
xbmcplugin.addSortMethod(self._plugin_handle, *sort_method[args])
|
||||
|
||||
def clone(self, new_path=None, new_params=None):
|
||||
if not new_path:
|
||||
|
|
@ -524,16 +525,16 @@ class XbmcContext(AbstractContext):
|
|||
if not self.use_inputstream_adaptive() or not inputstream_version:
|
||||
return frozenset() if capability is None else None
|
||||
|
||||
isa_loose_version = utils.loose_version(inputstream_version)
|
||||
isa_loose_version = loose_version(inputstream_version)
|
||||
if capability is None:
|
||||
capabilities = frozenset(
|
||||
capability for capability, version in self._ISA_CAPABILITIES.items()
|
||||
if version is True
|
||||
or version and isa_loose_version >= utils.loose_version(version)
|
||||
or version and isa_loose_version >= loose_version(version)
|
||||
)
|
||||
return capabilities
|
||||
version = self._ISA_CAPABILITIES.get(capability)
|
||||
return version is True or version and isa_loose_version >= utils.loose_version(version)
|
||||
return version is True or version and isa_loose_version >= loose_version(version)
|
||||
|
||||
@staticmethod
|
||||
def inputstream_adaptive_auto_stream_selection():
|
||||
|
|
|
|||
|
|
@ -10,15 +10,16 @@
|
|||
import json
|
||||
import os
|
||||
import re
|
||||
from socket import error as socket_error
|
||||
from http import server as BaseHTTPServer
|
||||
from io import open
|
||||
from socket import error as socket_error
|
||||
from textwrap import dedent
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
|
||||
from xbmc import getCondVisibility, executebuiltin
|
||||
from xbmc import executebuiltin, getCondVisibility
|
||||
from xbmcaddon import Addon
|
||||
from xbmcgui import Dialog, Window
|
||||
from xbmcvfs import translatePath
|
||||
from xbmcaddon import Addon
|
||||
|
||||
from .requests import BaseRequestsClass
|
||||
from ..logger import log_debug
|
||||
|
|
@ -32,7 +33,7 @@ _i18n = _addon.getLocalizedString
|
|||
_server_requests = BaseRequestsClass()
|
||||
|
||||
|
||||
class YouTubeProxyRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||
class YouTubeProxyRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler, object):
|
||||
base_path = translatePath('special://temp/{0}'.format(_addon_id))
|
||||
chunk_size = 1024 * 64
|
||||
local_ranges = (
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class XbmcPluginSettings(AbstractSettings):
|
|||
|
||||
if self._funcs:
|
||||
return
|
||||
if current_system_version.get_version() >= (20, 0):
|
||||
if current_system_version.compatible(20, 0):
|
||||
_class = xbmcaddon.Settings
|
||||
|
||||
self._funcs.update({
|
||||
|
|
@ -41,11 +41,11 @@ class XbmcPluginSettings(AbstractSettings):
|
|||
_class = xbmcaddon.Addon
|
||||
|
||||
def _get_string_list(store, setting):
|
||||
return _class.getSettingString(store, setting).split(',')
|
||||
return _class.getSetting(store, setting).split(',')
|
||||
|
||||
def _set_string_list(store, setting, value):
|
||||
value = ','.join(value)
|
||||
return _class.setSettingString(store, setting, value)
|
||||
return _class.setSetting(store, setting, value)
|
||||
|
||||
self._funcs.update({
|
||||
'get_bool': _class.getSettingBool,
|
||||
|
|
@ -62,7 +62,7 @@ class XbmcPluginSettings(AbstractSettings):
|
|||
def flush(cls, xbmc_addon):
|
||||
cls._echo = get_kodi_setting('debug.showloginfo')
|
||||
cls._cache = {}
|
||||
if current_system_version.get_version() >= (20, 0):
|
||||
if current_system_version.compatible(20, 0):
|
||||
cls._store = xbmc_addon.getSettings()
|
||||
else:
|
||||
cls._store = xbmc_addon
|
||||
|
|
|
|||
0
resources/lib/youtube_plugin/kodion/ui/xbmc/__init__.py
Normal file
0
resources/lib/youtube_plugin/kodion/ui/xbmc/__init__.py
Normal file
|
|
@ -8,8 +8,8 @@
|
|||
See LICENSES/GPL-2.0-only for more information.
|
||||
"""
|
||||
|
||||
from ... import utils
|
||||
from ...items import AudioItem, DirectoryItem, ImageItem, VideoItem
|
||||
from ...utils import current_system_version, datetime_parser
|
||||
|
||||
|
||||
def _process_date_value(info_labels, name, param):
|
||||
|
|
@ -19,7 +19,9 @@ def _process_date_value(info_labels, name, param):
|
|||
|
||||
def _process_datetime_value(info_labels, name, param):
|
||||
if param:
|
||||
info_labels[name] = param.isoformat('T')
|
||||
info_labels[name] = (param.isoformat('T')
|
||||
if current_system_version.compatible(19, 0) else
|
||||
param.strftime('%d.%d.%Y'))
|
||||
|
||||
|
||||
def _process_int_value(info_labels, name, param):
|
||||
|
|
@ -64,7 +66,7 @@ def _process_video_rating(info_labels, param):
|
|||
|
||||
def _process_date_string(info_labels, name, param):
|
||||
if param:
|
||||
date = utils.datetime_parser.parse(param)
|
||||
date = datetime_parser.parse(param)
|
||||
info_labels[name] = date.isoformat()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from xbmcgui import ListItem
|
|||
|
||||
from . import info_labels
|
||||
from ...items import AudioItem, UriItem, VideoItem
|
||||
from ...utils import datetime_parser
|
||||
from ...utils import current_system_version, datetime_parser
|
||||
|
||||
|
||||
try:
|
||||
|
|
@ -34,10 +34,8 @@ except ImportError:
|
|||
|
||||
def set_resume_point(self,
|
||||
infoproperties,
|
||||
*_args,
|
||||
resume_key='ResumeTime',
|
||||
total_key='TotalTime',
|
||||
**_kwargs):
|
||||
total_key='TotalTime',):
|
||||
if resume_key in infoproperties:
|
||||
infoproperties[resume_key] = str(infoproperties[resume_key])
|
||||
if total_key in infoproperties:
|
||||
|
|
@ -95,7 +93,10 @@ def video_playback_item(context, video_item):
|
|||
manifest_type = 'hls'
|
||||
mime_type = 'application/x-mpegURL'
|
||||
|
||||
props['inputstream'] = 'inputstream.adaptive'
|
||||
inputstream_property = ('inputstream'
|
||||
if current_system_version.compatible(19, 0) else
|
||||
'inputstreamaddon')
|
||||
props[inputstream_property] = 'inputstream.adaptive'
|
||||
props['inputstream.adaptive.manifest_type'] = manifest_type
|
||||
|
||||
if headers:
|
||||
|
|
|
|||
|
|
@ -90,5 +90,8 @@ class SystemVersion(object):
|
|||
def get_app_name(self):
|
||||
return self._appname
|
||||
|
||||
def compatible(self, *version):
|
||||
return self._version >= version
|
||||
|
||||
|
||||
current_system_version = SystemVersion()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue