diff --git a/setup.cfg b/setup.cfg index a399e6a..84fd2c7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = cleanvid -version = 1.5.1 +version = 1.5.2 author = Seth Grover author_email = mero.mero.guero@gmail.com description = cleanvid is a little script to mute profanity in video files. diff --git a/src/cleanvid/__init__.py b/src/cleanvid/__init__.py index 474164e..8ca3dd1 100644 --- a/src/cleanvid/__init__.py +++ b/src/cleanvid/__init__.py @@ -1,6 +1,6 @@ """cleanvid is a little script to mute profanity in video files.""" -__version__ = "1.5.1" +__version__ = "1.5.2" __author__ = "Seth Grover " __all__ = [] diff --git a/src/cleanvid/cleanvid.py b/src/cleanvid/cleanvid.py index 7ef7ae9..266f34f 100755 --- a/src/cleanvid/cleanvid.py +++ b/src/cleanvid/cleanvid.py @@ -5,6 +5,7 @@ import chardet import codecs import errno +import itertools import json import os import shutil @@ -33,13 +34,6 @@ PLEX_AUTO_SKIP_DEFAULT_CONFIG = '{"markers":{},"offsets":{},"tags":{},"allowed":{"users":[],"clients":[],"keys":[]},"blocked":{"users":[],"clients":[],"keys":[]},"clients":{},"mode":{}}' -# thanks https://docs.python.org/3/library/itertools.html#recipes -def pairwise(iterable): - a, b = tee(iterable) - next(b, None) - return zip(a, b) - - ######## GetFormatAndStreamInfo ############################################### def GetFormatAndStreamInfo(vidFileSpec): result = None @@ -341,7 +335,7 @@ def CreateCleanSubAndMuteList(self): # OR if the previous text contained profanity and lies within the pad ... # then include the subtitle in the new set prevNaughtySub = None - for sub, subPeek in pairwise(subs): + for sub, subPeek in itertools.pairwise(subs): newText = replacer.sub(lambda x: self.swearsMap[x.group()], sub.text) newTextPeek = ( replacer.sub(lambda x: self.swearsMap[x.group()], subPeek.text) if (subPeek is not None) else None @@ -428,7 +422,7 @@ def CreateCleanSubAndMuteList(self): plexDict["markers"][self.plexAutoSkipId] = [] plexDict["mode"][self.plexAutoSkipId] = "volume" - for timePair, timePairPeek in pairwise(newTimestampPairs): + for timePair, timePairPeek in itertools.pairwise(newTimestampPairs): lineStart = ( (timePair[0].hour * 60.0 * 60.0) + (timePair[0].minute * 60.0) @@ -465,9 +459,6 @@ def CreateCleanSubAndMuteList(self): + format(lineEnd, '.3f') + ":d=10ms" ) - self.muteTimeList.append( - "volume=enable='between(t," + format(lineStart, '.3f') + "," + format(lineEnd, '.3f') + ")':volume=0" - ) if self.edl: edlLines.append(f"{format(lineStart, '.1f')}\t{format(lineEnd, '.3f')}\t1") if plexDict: