2018-10-20 14:49:04 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import absolute_import, division, unicode_literals
|
|
|
|
import xbmc
|
|
|
|
|
2018-11-18 14:59:17 +01:00
|
|
|
from .. import app
|
2018-10-20 14:49:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
class libsync_mixin(object):
|
|
|
|
def isCanceled(self):
|
2018-11-18 14:59:17 +01:00
|
|
|
return (self._canceled or app.APP.stop_pkc or app.SYNC.stop_sync or
|
2018-11-25 17:03:19 +01:00
|
|
|
app.APP.suspend_threads or app.SYNC.suspend_sync)
|
2018-10-20 14:49:04 +02:00
|
|
|
|
|
|
|
|
2018-12-21 16:53:53 +01:00
|
|
|
class fullsync_mixin(object):
|
|
|
|
def isCanceled(self):
|
|
|
|
return (self._canceled or
|
|
|
|
app.APP.stop_pkc or
|
|
|
|
app.SYNC.stop_sync or
|
|
|
|
app.APP.suspend_threads)
|
|
|
|
|
|
|
|
|
2018-10-20 14:49:04 +02:00
|
|
|
def update_kodi_library(video=True, music=True):
|
|
|
|
"""
|
|
|
|
Updates the Kodi library and thus refreshes the Kodi views and widgets
|
|
|
|
"""
|
2018-11-25 20:36:54 +01:00
|
|
|
if video:
|
|
|
|
xbmc.executebuiltin('UpdateLibrary(video)')
|
|
|
|
if music:
|
|
|
|
xbmc.executebuiltin('UpdateLibrary(music)')
|
2018-12-25 18:26:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
def tag_last(iterable):
|
|
|
|
"""
|
|
|
|
Given some iterable, returns (last, item), where last is only True if you
|
|
|
|
are on the final iteration.
|
|
|
|
"""
|
|
|
|
iterator = iter(iterable)
|
|
|
|
gotone = False
|
|
|
|
try:
|
|
|
|
lookback = next(iterator)
|
|
|
|
gotone = True
|
|
|
|
while True:
|
|
|
|
cur = next(iterator)
|
|
|
|
yield False, lookback
|
|
|
|
lookback = cur
|
|
|
|
except StopIteration:
|
|
|
|
if gotone:
|
|
|
|
yield True, lookback
|
|
|
|
raise StopIteration()
|