inc
This commit is contained in:
14
bin/ffx.py
14
bin/ffx.py
@@ -241,8 +241,13 @@ def convert(ctx,
|
|||||||
|
|
||||||
context = ctx.obj
|
context = ctx.obj
|
||||||
|
|
||||||
|
context['jellyfin'] = jellyfin
|
||||||
|
context['tmdb'] = tmdb
|
||||||
|
|
||||||
# click.echo(f"\nVideo encoder: {video_encoder}")
|
# click.echo(f"\nVideo encoder: {video_encoder}")
|
||||||
#
|
|
||||||
|
ffx = FfxController()
|
||||||
|
|
||||||
qualityTokens = quality.split(',')
|
qualityTokens = quality.split(',')
|
||||||
q_list = [q for q in qualityTokens if q.isnumeric()]
|
q_list = [q for q in qualityTokens if q.isnumeric()]
|
||||||
|
|
||||||
@@ -326,12 +331,19 @@ def convert(ctx,
|
|||||||
currentPattern = mediaFileProperties.getPattern()
|
currentPattern = mediaFileProperties.getPattern()
|
||||||
|
|
||||||
targetMediaDescriptor = currentPattern.getMediaDescriptor() if currentPattern is not None else None
|
targetMediaDescriptor = currentPattern.getMediaDescriptor() if currentPattern is not None else None
|
||||||
|
targetMediaDescriptor.setJellyfinOrder(context['jellyfin'])
|
||||||
|
|
||||||
click.echo(f"Pattern matching: {'No' if currentPattern is None else 'Yes'}")
|
click.echo(f"Pattern matching: {'No' if currentPattern is None else 'Yes'}")
|
||||||
|
|
||||||
if not currentPattern is None:
|
if not currentPattern is None:
|
||||||
|
|
||||||
click.echo(f"Input mapping tokens: {targetMediaDescriptor.getInputMappingTokens()}")
|
click.echo(f"Input mapping tokens: {targetMediaDescriptor.getInputMappingTokens()}")
|
||||||
|
|
||||||
|
mappingTokens = ffx.generateMappingTokensFromDescriptors(currentMediaDescriptor, targetMediaDescriptor)
|
||||||
|
|
||||||
|
click.echo(f"Mapping Tokens: {mappingTokens}")
|
||||||
|
|
||||||
|
|
||||||
# # Determine season and episode if present in current filename
|
# # Determine season and episode if present in current filename
|
||||||
# season_digits = 2
|
# season_digits = 2
|
||||||
# episode_digits = 2
|
# episode_digits = 2
|
||||||
|
|||||||
@@ -174,6 +174,8 @@ class FfxController():
|
|||||||
|
|
||||||
mediaDifferences = targetMediaDescriptor.compare(sourceMediaDescriptor)
|
mediaDifferences = targetMediaDescriptor.compare(sourceMediaDescriptor)
|
||||||
|
|
||||||
|
click.echo(f"media diff {mediaDifferences}")
|
||||||
|
|
||||||
if MediaDescriptor.TAGS_KEY in mediaDifferences.keys():
|
if MediaDescriptor.TAGS_KEY in mediaDifferences.keys():
|
||||||
|
|
||||||
sourceTags = sourceMediaDescriptor.getTags()
|
sourceTags = sourceMediaDescriptor.getTags()
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ class FileProperties():
|
|||||||
|
|
||||||
def __init__(self, context, sourcePath):
|
def __init__(self, context, sourcePath):
|
||||||
|
|
||||||
|
self.context = context
|
||||||
|
|
||||||
# Separate basedir, basename and extension for current source file
|
# Separate basedir, basename and extension for current source file
|
||||||
self.__sourcePath = sourcePath
|
self.__sourcePath = sourcePath
|
||||||
|
|
||||||
@@ -189,7 +191,7 @@ class FileProperties():
|
|||||||
|
|
||||||
|
|
||||||
def getMediaDescriptor(self):
|
def getMediaDescriptor(self):
|
||||||
return MediaDescriptor.fromFfprobe(self.getFormatData(), self.getStreamData())
|
return MediaDescriptor.fromFfprobe(self.getFormatData(), self.getStreamData(), context = self.context)
|
||||||
|
|
||||||
|
|
||||||
def getShowId(self) -> int:
|
def getShowId(self) -> int:
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ from ffx.helper import dictDiff, DIFF_ADDED_KEY, DIFF_CHANGED_KEY, DIFF_REMOVED_
|
|||||||
class MediaDescriptor():
|
class MediaDescriptor():
|
||||||
"""This class represents the structural content of a media file including streams and metadata"""
|
"""This class represents the structural content of a media file including streams and metadata"""
|
||||||
|
|
||||||
|
CONTEXT_KEY = 'context'
|
||||||
|
|
||||||
TAGS_KEY = 'tags'
|
TAGS_KEY = 'tags'
|
||||||
TRACKS_KEY = 'tracks'
|
TRACKS_KEY = 'tracks'
|
||||||
|
|
||||||
@@ -22,6 +24,7 @@ class MediaDescriptor():
|
|||||||
FFPROBE_DISPOSITION_KEY = 'disposition'
|
FFPROBE_DISPOSITION_KEY = 'disposition'
|
||||||
FFPROBE_TAGS_KEY = 'tags'
|
FFPROBE_TAGS_KEY = 'tags'
|
||||||
FFPROBE_CODEC_TYPE_KEY = 'codec_type'
|
FFPROBE_CODEC_TYPE_KEY = 'codec_type'
|
||||||
|
|
||||||
JELLYFIN_ORDER_FLAG_KEY = 'jellyfin_order'
|
JELLYFIN_ORDER_FLAG_KEY = 'jellyfin_order'
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
@@ -34,9 +37,6 @@ class MediaDescriptor():
|
|||||||
self.__mediaTags = {}
|
self.__mediaTags = {}
|
||||||
|
|
||||||
if MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY in kwargs.keys():
|
if MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY in kwargs.keys():
|
||||||
# if type(kwargs[MediaDescriptor.TRACK_DESCRIPTORS_KEY]) is not List[TrackDescriptor]: # Use List typehint for TrackDescriptor as well if it works
|
|
||||||
# raise TypeError(f"MediaDescriptor.__init__(): Argument {MediaDescriptor.TRACK_DESCRIPTORS_KEY} is required to be of type list containing only elements of type TrackDescriptor")
|
|
||||||
|
|
||||||
if type(kwargs[MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY]) is not list: # Use List typehint for TrackDescriptor as well if it works
|
if type(kwargs[MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY]) is not list: # Use List typehint for TrackDescriptor as well if it works
|
||||||
raise TypeError(f"MediaDescriptor.__init__(): Argument {MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY} is required to be of type list")
|
raise TypeError(f"MediaDescriptor.__init__(): Argument {MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY} is required to be of type list")
|
||||||
for d in kwargs[MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY]:
|
for d in kwargs[MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY]:
|
||||||
@@ -105,7 +105,7 @@ class MediaDescriptor():
|
|||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def fromFfprobe(cls, formatData, streamData):
|
def fromFfprobe(cls, formatData, streamData, context : dict = None):
|
||||||
|
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
|
|
||||||
@@ -114,6 +114,7 @@ class MediaDescriptor():
|
|||||||
|
|
||||||
kwargs[MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY] = []
|
kwargs[MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY] = []
|
||||||
|
|
||||||
|
#TODO: Evtl obsolet
|
||||||
subIndexCounters = {}
|
subIndexCounters = {}
|
||||||
|
|
||||||
for streamObj in streamData:
|
for streamObj in streamData:
|
||||||
@@ -165,6 +166,12 @@ class MediaDescriptor():
|
|||||||
subIndex += 1
|
subIndex += 1
|
||||||
return subtitleTracks
|
return subtitleTracks
|
||||||
|
|
||||||
|
def getJellyfin(self):
|
||||||
|
return self.__jellyfinOrder
|
||||||
|
|
||||||
|
def setJellyfinOrder(self, state):
|
||||||
|
self.__jellyfinOrder = state
|
||||||
|
|
||||||
def getClearTags(self):
|
def getClearTags(self):
|
||||||
return self.__clearTags
|
return self.__clearTags
|
||||||
|
|
||||||
@@ -226,25 +233,17 @@ class MediaDescriptor():
|
|||||||
return compareResult
|
return compareResult
|
||||||
|
|
||||||
|
|
||||||
def getInputMappingTokens(self):
|
def getInputMappingTokens(self, use_sub_index : bool = True):
|
||||||
|
|
||||||
reorderedTrackDescriptors = self.getReorderedTrackDescriptors()
|
reorderedTrackDescriptors = self.getReorderedTrackDescriptors()
|
||||||
inputMappingTokens = []
|
inputMappingTokens = []
|
||||||
|
|
||||||
#subIndexCounter = {}
|
|
||||||
for rtd in reorderedTrackDescriptors:
|
for rtd in reorderedTrackDescriptors:
|
||||||
trackType = rtd.getType()
|
trackType = rtd.getType()
|
||||||
#if not trackType in subIndexCounter.keys():
|
if use_sub_index:
|
||||||
# subIndexCounter[trackType] = 0
|
|
||||||
#inputMappingTokens += ['-map', f"0:{trackType.indicator()}:{subIndexCounter[trackType]}"]
|
|
||||||
inputMappingTokens += ['-map', f"0:{trackType.indicator()}:{rtd.getSubIndex()}"]
|
inputMappingTokens += ['-map', f"0:{trackType.indicator()}:{rtd.getSubIndex()}"]
|
||||||
#subIndexCounter[trackType] += 1
|
else:
|
||||||
|
inputMappingTokens += ['-map', f"0:{rtd.getIndex()}"]
|
||||||
|
|
||||||
return inputMappingTokens
|
return inputMappingTokens
|
||||||
|
|
||||||
# for rtd in reorderedTrackDescriptors:
|
|
||||||
# trackType = rtd.getType()
|
|
||||||
# #if not trackType in subIndexCounter.keys():
|
|
||||||
# # subIndexCounter[trackType] = 0
|
|
||||||
# #inputMappingTokens += ['-map', f"0:{trackType.indicator()}:{subIndexCounter[trackType]}"]
|
|
||||||
# inputMappingTokens += ['-map', f"0:{rtd.getIndex()}"]
|
|
||||||
# #subIndexCounter[trackType] += 1
|
|
||||||
# return inputMappingTokens
|
|
||||||
|
|||||||
Reference in New Issue
Block a user