Move function
This commit is contained in:
parent
6076da724b
commit
4ee828dfe9
2 changed files with 21 additions and 21 deletions
|
@ -28,3 +28,23 @@ def update_kodi_library(video=True, music=True):
|
||||||
xbmc.executebuiltin('UpdateLibrary(video)')
|
xbmc.executebuiltin('UpdateLibrary(video)')
|
||||||
if music:
|
if music:
|
||||||
xbmc.executebuiltin('UpdateLibrary(music)')
|
xbmc.executebuiltin('UpdateLibrary(music)')
|
||||||
|
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
|
@ -29,26 +29,6 @@ UPDATED_AT_SAFETY = 60 * 5
|
||||||
LAST_VIEWED_AT_SAFETY = 60 * 5
|
LAST_VIEWED_AT_SAFETY = 60 * 5
|
||||||
|
|
||||||
|
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
class InitNewSection(object):
|
class InitNewSection(object):
|
||||||
"""
|
"""
|
||||||
Throw this into the queue used for ProcessMetadata to tell it which
|
Throw this into the queue used for ProcessMetadata to tell it which
|
||||||
|
@ -201,7 +181,7 @@ class FullSync(common.fullsync_mixin):
|
||||||
self.current = 0
|
self.current = 0
|
||||||
# Initialize only once to avoid loosing the last value before
|
# Initialize only once to avoid loosing the last value before
|
||||||
# we're breaking the for loop
|
# we're breaking the for loop
|
||||||
loop = tag_last(iterator)
|
loop = common.tag_last(iterator)
|
||||||
while True:
|
while True:
|
||||||
# Check Plex DB to see what we need to add/update
|
# Check Plex DB to see what we need to add/update
|
||||||
with PlexDB() as self.plexdb:
|
with PlexDB() as self.plexdb:
|
||||||
|
|
Loading…
Reference in a new issue