Skip to content

Commit

Permalink
Merge pull request #941 from MoojMidge/master
Browse files Browse the repository at this point in the history
v7.1.1+beta.2
MoojMidge authored Oct 27, 2024
2 parents d873738 + b6f6837 commit 9e1c9c2
Showing 47 changed files with 955 additions and 599 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.1" provider-name="anxdpanic, bromix, MoojMidge">
<addon id="plugin.video.youtube" name="YouTube" version="7.1.1+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"/>
19 changes: 19 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## v7.1.1+beta.2
### Fixed
- Standardise return type of LoginClient.refresh_token #932
- Fix curl headers not being used when set on path of setResolvedUrl listitem
- Fix HEAD requests to MPD manifests
- Fix various Python2 incompatible changes
- Properly distinguish between VP9 and VP9.2 with HDR info
- Fix http server not running when script shows client IP

### Changed
- Improve display and update of bookmarks
- Explicitly set http server protocol version to HTTP/1.1
- Improve logging

### New
- Add View all and Shuffle context menu items for playlists
- New setting to enable debug logging for addon
- Setting > Advanced > Logging > Enable debug logging

## v7.1.1+beta.1
### Fixed
- Fix http server not listening on any interface if listen IP is 0.0.0.0 #927
2 changes: 1 addition & 1 deletion resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
@@ -554,7 +554,7 @@ msgid "None"
msgstr ""

msgctxt "#30562"
msgid ""
msgid "View all"
msgstr ""

msgctxt "#30563"
1 change: 0 additions & 1 deletion resources/lib/youtube_plugin/kodion/__init__.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@

from __future__ import absolute_import, division, unicode_literals

from . import logger
from .abstract_provider import (
# Abstract provider for implementation by the user
AbstractProvider,
28 changes: 28 additions & 0 deletions resources/lib/youtube_plugin/kodion/compatibility/__init__.py
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
'byte_string_type',
'cpu_count',
'datetime_infolabel',
'entity_escape',
'parse_qs',
'parse_qsl',
'quote',
@@ -54,12 +55,25 @@
import xbmcplugin
import xbmcvfs


xbmc.LOGNOTICE = xbmc.LOGINFO
xbmc.LOGSEVERE = xbmc.LOGFATAL

string_type = str
byte_string_type = bytes
to_str = str


def entity_escape(text,
entities=str.maketrans({
'&': '&amp;',
'"': '&quot;',
'<': '&lt;',
'>': '&gt;',
'\'': '&#x27;',
})):
return text.translate(entities)

# Compatibility shims for Kodi v18 and Python v2.7
except ImportError:
from BaseHTTPServer import BaseHTTPRequestHandler
@@ -130,11 +144,25 @@ def _file_closer(*args, **kwargs):
string_type = basestring
byte_string_type = (bytes, str)


def to_str(value):
if isinstance(value, unicode):
return value.encode('utf-8')
return str(value)


def entity_escape(text,
entities={
'&': '&amp;',
'"': '&quot;',
'<': '&lt;',
'>': '&gt;',
'\'': '&#x27;',
}):
for key, value in entities.viewitems():
text = text.replace(key, value)
return text

# Kodi v20+
if hasattr(xbmcgui.ListItem, 'setDateTime'):
def datetime_infolabel(datetime_obj, *_args, **_kwargs):
2 changes: 2 additions & 0 deletions resources/lib/youtube_plugin/kodion/constants/__init__.py
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@
PLAY_FORCE_AUDIO = 'audio_only'
PLAY_PROMPT_QUALITY = 'ask_for_quality'
PLAY_PROMPT_SUBTITLES = 'prompt_for_subtitles'
PLAY_STRM = 'strm'
PLAY_TIMESHIFT = 'timeshift'
PLAY_WITH = 'play_with'

@@ -124,6 +125,7 @@
'PLAY_FORCE_AUDIO',
'PLAY_PROMPT_QUALITY',
'PLAY_PROMPT_SUBTITLES',
'PLAY_STRM',
'PLAY_TIMESHIFT',
'PLAY_WITH',

Original file line number Diff line number Diff line change
@@ -90,3 +90,5 @@
HTTPD_LISTEN = 'kodion.http.listen' # (str)
HTTPD_WHITELIST = 'kodion.http.ip.whitelist' # (str)
HTTPD_IDLE_SLEEP = 'youtube.http.idle_sleep' # (bool)

LOGGING_ENABLED = 'kodion.logging.enabled' # (bool)
26 changes: 4 additions & 22 deletions resources/lib/youtube_plugin/kodion/context/abstract_context.py
Original file line number Diff line number Diff line change
@@ -12,13 +12,14 @@

import os

from .. import logger
from ..logger import Logger
from ..compatibility import parse_qsl, quote, to_str, urlencode, urlsplit
from ..constants import (
PATHS,
PLAY_FORCE_AUDIO,
PLAY_PROMPT_QUALITY,
PLAY_PROMPT_SUBTITLES,
PLAY_STRM,
PLAY_TIMESHIFT,
PLAY_WITH,
VALUE_FROM_STR,
@@ -36,7 +37,7 @@
from ..utils import current_system_version


class AbstractContext(object):
class AbstractContext(Logger):
_initialized = False
_addon = None
_settings = None
@@ -45,6 +46,7 @@ class AbstractContext(object):
PLAY_FORCE_AUDIO,
PLAY_PROMPT_SUBTITLES,
PLAY_PROMPT_QUALITY,
PLAY_STRM,
PLAY_TIMESHIFT,
PLAY_WITH,
'confirmed',
@@ -58,10 +60,8 @@ class AbstractContext(object):
'incognito',
'location',
'logged_in',
'play',
'resume',
'screensaver',
'strm',
'window_return',
}
_INT_PARAMS = {
@@ -430,24 +430,6 @@ def set_content(self, content_type, sub_type=None, category_label=None):
def add_sort_method(self, *sort_methods):
raise NotImplementedError()

def log(self, text, log_level=logger.NOTICE):
logger.log(text, log_level, self.get_id())

def log_warning(self, text):
self.log(text, logger.WARNING)

def log_error(self, text):
self.log(text, logger.ERROR)

def log_notice(self, text):
self.log(text, logger.NOTICE)

def log_debug(self, text):
self.log(text, logger.DEBUG)

def log_info(self, text):
self.log(text, logger.INFO)

def clone(self, new_path=None, new_params=None):
raise NotImplementedError()

Original file line number Diff line number Diff line change
@@ -154,6 +154,7 @@ class XbmcContext(AbstractContext):
'playlist.progress.updating': 30536,
'playlist.removed_from': 30715,
'playlist.select': 30521,
'playlist.view.all': 30562,
'playlists': 30501,
'please_wait': 30119,
'prompt': 30566,
@@ -683,6 +684,7 @@ def use_inputstream_adaptive(self, prompt=False):
'av01': loose_version('20.3.0'),
'vp8': False,
'vp9': loose_version('2.3.14'),
'vp9.2': loose_version('2.4.0'),
}

def inputstream_adaptive_capabilities(self, capability=None):
6 changes: 3 additions & 3 deletions resources/lib/youtube_plugin/kodion/debug.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
import atexit
import os

from .logger import log_debug
from .logger import Logger


def debug_here(host='localhost'):
@@ -145,7 +145,7 @@ def __exit__(self, exc_type=None, exc_val=None, exc_tb=None):
if not self._enabled:
return

log_debug('Profiling stats: {0}'.format(self.get_stats(
Logger.log_debug('Profiling stats: {0}'.format(self.get_stats(
num_lines=self._num_lines,
print_callees=self._print_callees,
reuse=self._reuse,
@@ -270,7 +270,7 @@ def get_stats(self,
return output

def print_stats(self):
log_debug('Profiling stats: {0}'.format(self.get_stats(
Logger.log_debug('Profiling stats: {0}'.format(self.get_stats(
num_lines=self._num_lines,
print_callees=self._print_callees,
reuse=self._reuse,
84 changes: 83 additions & 1 deletion resources/lib/youtube_plugin/kodion/items/base_item.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,14 @@
from datetime import date, datetime
from hashlib import md5

from ..compatibility import datetime_infolabel, string_type, to_str, unescape
from ..compatibility import (
datetime_infolabel,
parse_qsl,
string_type,
to_str,
unescape,
urlsplit,
)
from ..constants import MEDIA_PATH


@@ -27,6 +34,8 @@ def __init__(self, name, uri, image=None, fanart=None):
self.set_name(name)

self._uri = uri
self._available = True
self._callback = None

self._image = ''
if image:
@@ -35,6 +44,7 @@ def __init__(self, name, uri, image=None, fanart=None):
if fanart:
self.set_fanart(fanart)

self._bookmark_id = None
self._bookmark_timestamp = None
self._context_menu = None
self._added_utc = None
@@ -71,6 +81,47 @@ def get_id(self):
"""
return md5(''.join((self._name, self._uri)).encode('utf-8')).hexdigest()

def parse_item_ids_from_uri(self):
if not self._uri:
return None

item_ids = {}

uri = urlsplit(self._uri)
path = uri.path
params = dict(parse_qsl(uri.query))

video_id = params.get('video_id')
if video_id:
item_ids['video_id'] = video_id

channel_id = None
playlist_id = None

while path:
part, _, next_part = path.partition('/')
if not next_part:
break

if part == 'channel':
channel_id = next_part.partition('/')[0]
elif part == 'playlist':
playlist_id = next_part.partition('/')[0]
path = next_part

if channel_id:
item_ids['channel_id'] = channel_id
if playlist_id:
item_ids['playlist_id'] = playlist_id

for item_id, value in item_ids.items():
try:
setattr(self, item_id, value)
except AttributeError:
pass

return item_ids

def set_name(self, name):
try:
name = unescape(name)
@@ -96,6 +147,22 @@ def get_uri(self):
"""
return self._uri

@property
def available(self):
return self._available

@available.setter
def available(self, value):
self._available = value

@property
def callback(self):
return self._callback

@callback.setter
def callback(self, value):
self._callback = value

def set_image(self, image):
if not image:
return
@@ -190,6 +257,14 @@ def get_count(self):
def set_count(self, count):
self._count = int(count or 0)

@property
def bookmark_id(self):
return self._bookmark_id

@bookmark_id.setter
def bookmark_id(self, value):
self._bookmark_id = value

def set_bookmark_timestamp(self, timestamp):
self._bookmark_timestamp = timestamp

@@ -200,6 +275,10 @@ def get_bookmark_timestamp(self):
def playable(self):
return self._playable

@playable.setter
def playable(self, value):
self._playable = value

def add_artist(self, artist):
if artist:
if self._artists is None:
@@ -289,3 +368,6 @@ def encode(self, obj, nested=False):
if nested:
return output
return super(_Encoder, self).encode(output)

def default(self, obj):
pass
Loading

0 comments on commit 9e1c9c2

Please sign in to comment.