Skip to content

Commit

Permalink
Move infotagger import to compatibility module
Browse files Browse the repository at this point in the history
  • Loading branch information
MoojMidge committed Jan 8, 2024
1 parent 0563496 commit 0795387
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
26 changes: 26 additions & 0 deletions resources/lib/youtube_plugin/kodion/compatibility/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import xbmcplugin
import xbmcvfs

from infotagger.listitem import set_info_tag

except ImportError:
import BaseHTTPServer
from contextlib import contextmanager as _contextmanager
Expand Down Expand Up @@ -91,12 +93,36 @@ def _file_closer(*args, **kwargs):
xbmcvfs.File = _file_closer
xbmcvfs.translatePath = xbmc.translatePath

def set_info_tag(listitem, infolabels, tag_type, *_args, **_kwargs):
listitem.setInfo(tag_type, infolabels)
return ListItemInfoTag(listitem, tag_type)


class ListItemInfoTag(object):
__slots__ = ('__li__',)

def __init__(self, listitem, *_args, **_kwargs):
self.__li__ = listitem

def add_stream_info(self, *args, **kwargs):
return self.__li__.addStreamInfo(*args, **kwargs)

def set_resume_point(self,
infoproperties,
resume_key='ResumeTime',
total_key='TotalTime'):
if resume_key in infoproperties:
infoproperties[resume_key] = str(infoproperties[resume_key])
if total_key in infoproperties:
infoproperties[total_key] = str(infoproperties[total_key])


__all__ = (
'BaseHTTPServer',
'parse_qs',
'parse_qsl',
'quote',
'set_info_tag',
'unescape',
'unquote',
'urlencode',
Expand Down
28 changes: 1 addition & 27 deletions resources/lib/youtube_plugin/kodion/ui/xbmc/xbmc_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,10 @@
from __future__ import absolute_import, division, unicode_literals

from . import info_labels
from ...compatibility import xbmcgui
from ...compatibility import set_info_tag, xbmcgui
from ...items import AudioItem, UriItem, VideoItem
from ...utils import current_system_version, datetime_parser

try:
from infotagger.listitem import set_info_tag
except ImportError:
def set_info_tag(listitem, infolabels, tag_type, *_args, **_kwargs):
listitem.setInfo(tag_type, infolabels)
return ListItemInfoTag(listitem, tag_type)


class ListItemInfoTag(object):
__slots__ = ('__li__',)

def __init__(self, listitem, *_args, **_kwargs):
self.__li__ = listitem

def add_stream_info(self, *args, **kwargs):
return self.__li__.addStreamInfo(*args, **kwargs)

def set_resume_point(self,
infoproperties,
resume_key='ResumeTime',
total_key='TotalTime'):
if resume_key in infoproperties:
infoproperties[resume_key] = str(infoproperties[resume_key])
if total_key in infoproperties:
infoproperties[total_key] = str(infoproperties[total_key])


def video_playback_item(context, video_item, show_fanart=None):
uri = video_item.get_uri()
Expand Down

0 comments on commit 0795387

Please sign in to comment.