Skip to content

misc

Classes:

BestSource

BestSource(
    *,
    force: bool = True,
    cachemode: int = ABSOLUTE,
    rff: int | None = True,
    **kwargs: Any
)

Bases: CacheIndexer

BestSource indexer.

Unlike the plugin's default behavior, the indexer cache file will be stored in .vsjet/vssource next to the script file.

When cachemode is 0, 1, or 2 (NEVER, CACHE_PATH, or CACHE_PATH_WRITE), the behavior falls back to the default cache handling defined by the BestSource plugin itself.

Classes:

Methods:

Attributes:

Source code in vssource/indexers/misc.py
65
66
67
68
def __init__(
    self, *, force: bool = True, cachemode: int = CacheMode.ABSOLUTE, rff: int | None = True, **kwargs: Any
) -> None:
    super().__init__(force=force, cachemode=cachemode, rff=rff, **kwargs)

force instance-attribute

force = force

indexer_kwargs instance-attribute

indexer_kwargs = kwargs

CacheMode

Bases: CustomIntEnum

Cache mode.

Methods:

Attributes:

  • ABSOLUTE

    Always try to read index but only write index to disk when it will make a noticeable difference

  • ABSOLUTE_WRITE

    Always try to read and write index to disk and store index files

  • CACHE_PATH

    Always try to read index but only write index to disk when it will make a noticeable difference

  • CACHE_PATH_WRITE

    Always try to read and write index to disk and store index files in a subtree of cachepath.

  • NEVER

    Never read or write index to disk.

ABSOLUTE class-attribute instance-attribute

ABSOLUTE = 3

Always try to read index but only write index to disk when it will make a noticeable difference on subsequent runs and store index files in the absolute path in cachepath with track number and index extension appended.

ABSOLUTE_WRITE class-attribute instance-attribute

ABSOLUTE_WRITE = 4

Always try to read and write index to disk and store index files in the absolute path in cachepath with track number and index extension appended.

CACHE_PATH class-attribute instance-attribute

CACHE_PATH = 1

Always try to read index but only write index to disk when it will make a noticeable difference on subsequent runs and store index files in a subtree of cachepath.

CACHE_PATH_WRITE class-attribute instance-attribute

CACHE_PATH_WRITE = 2

Always try to read and write index to disk and store index files in a subtree of cachepath.

NEVER class-attribute instance-attribute

NEVER = 0

Never read or write index to disk.

from_param classmethod

from_param(value: Any, func_except: FuncExcept | None = None) -> Self

Return the enum value from a parameter.

Parameters:

  • value
    (Any) –

    Value to instantiate the enum class.

  • func_except
    (FuncExcept | None, default: None ) –

    Exception function.

Returns:

  • Self

    Enum value.

Raises:

Source code in jetpytools/enums/base.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
@classmethod
def from_param(cls, value: Any, func_except: FuncExcept | None = None) -> Self:
    """
    Return the enum value from a parameter.

    Args:
        value: Value to instantiate the enum class.
        func_except: Exception function.

    Returns:
        Enum value.

    Raises:
        NotFoundEnumValue: Variable not found in the given enum.
    """
    func_except = func_except or cls.from_param

    try:
        return cls(value)
    except (ValueError, TypeError):
        pass

    if isinstance(func_except, tuple):
        func_name, var_name = func_except
    else:
        func_name, var_name = func_except, repr(cls)

    raise NotFoundEnumValueError(
        'The given value for "{var_name}" argument must be a valid {enum_name}, not "{value}"!\n'
        "Valid values are: [{readable_enum}].",
        func_name,
        var_name=var_name,
        enum_name=cls,
        value=value,
        readable_enum=(f"{name} ({value!r})" for name, value in cls.__members__.items()),
        reason=value,
    ) from None

value

value() -> int
Source code in jetpytools/enums/base.py
86
87
@enum_property
def value(self) -> int: ...

get_cache_path staticmethod

get_cache_path(file_name: SPathLike, ext: str | None = None) -> SPath
Source code in vssource/indexers/base.py
158
159
160
161
162
@staticmethod
def get_cache_path(file_name: SPathLike, ext: str | None = None) -> SPath:
    storage = _get_indexer_cache_storage()

    return storage.get_file(file_name, ext=ext)

get_joined_names classmethod

get_joined_names(files: list[SPath]) -> str
Source code in vssource/indexers/base.py
54
55
56
@classmethod
def get_joined_names(cls, files: list[SPath]) -> str:
    return "_".join([file.name for file in files])

get_videos_hash classmethod

get_videos_hash(files: list[SPath]) -> str
Source code in vssource/indexers/base.py
58
59
60
61
62
63
64
@classmethod
def get_videos_hash(cls, files: list[SPath]) -> str:
    from hashlib import md5

    length = sum(file.stat().st_size for file in files)
    to_hash = length.to_bytes(32, "little") + cls.get_joined_names(files).encode()
    return md5(to_hash).hexdigest()

normalize_filenames classmethod

normalize_filenames(file: SPathLike | Iterable[SPathLike]) -> list[SPath]
Source code in vssource/indexers/base.py
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def normalize_filenames(cls, file: SPathLike | Iterable[SPathLike]) -> list[SPath]:
    files = list[SPath]()

    for f in to_arr(file):
        if str(f).startswith("file:///"):
            f = str(f)[8::]

        files.append(SPath(f))

    return files

source

source(
    file: SPathLike | Iterable[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixLike | None = None,
    transfer: TransferLike | None = None,
    primaries: PrimariesLike | None = None,
    chroma_location: ChromaLocation | None = None,
    color_range: ColorRangeLike | None = None,
    field_based: FieldBasedLike | None = None,
    idx_props: bool = True,
    ref: VideoNode | None = None,
    name: str | None = None,
    **kwargs: Any
) -> VideoNode

Load one or more input files using the indexer and return a processed clip.

The returned clip is passed through initialize_clip to apply bit depth conversion and frame props initialization.

Source code in vssource/indexers/base.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
@inject_self
def source(
    self,
    file: SPathLike | Iterable[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixLike | None = None,
    transfer: TransferLike | None = None,
    primaries: PrimariesLike | None = None,
    chroma_location: ChromaLocation | None = None,
    color_range: ColorRangeLike | None = None,
    field_based: FieldBasedLike | None = None,
    idx_props: bool = True,
    ref: vs.VideoNode | None = None,
    name: str | None = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Load one or more input files using the indexer and return a processed clip.

    The returned clip is passed through [initialize_clip][vstools.initialize_clip] to apply bit depth conversion
    and frame props initialization.
    """

    nfiles = self.normalize_filenames(file)
    clip = self._source(
        [self.source_func(f.to_str(), **self.indexer_kwargs | kwargs) for f in nfiles],
        bits,
        matrix,
        transfer,
        primaries,
        chroma_location,
        color_range,
        field_based,
    )
    if idx_props:
        clip = clip.std.SetFrameProps(IdxFilePath=[f.to_str() for f in nfiles], Idx=self.__class__.__name__)

    if name:
        clip = clip.std.SetFrameProps(Name=name)

    if ref:
        clip = match_clip(clip, ref, length=True)

    return clip

source_func classmethod

source_func(path: SPathLike, **kwargs: Any) -> VideoNode
Source code in vssource/indexers/misc.py
70
71
72
73
74
75
@classmethod
def source_func(cls, path: SPathLike, **kwargs: Any) -> VideoNode:
    if kwargs["cachemode"] <= cls.CacheMode.CACHE_PATH_WRITE and cls._cache_arg_name not in kwargs:
        kwargs[cls._cache_arg_name] = None

    return super().source_func(path, **kwargs)

CarefulSource

CarefulSource(*, force: bool = True, **kwargs: Any)

Bases: Indexer

CarefulSource indexer

Methods:

Attributes:

Source code in vssource/indexers/base.py
44
45
46
47
48
def __init__(self, *, force: bool = True, **kwargs: Any) -> None:
    super().__init__()

    self.force = force
    self.indexer_kwargs = kwargs

force instance-attribute

force = force

indexer_kwargs instance-attribute

indexer_kwargs = kwargs

get_joined_names classmethod

get_joined_names(files: list[SPath]) -> str
Source code in vssource/indexers/base.py
54
55
56
@classmethod
def get_joined_names(cls, files: list[SPath]) -> str:
    return "_".join([file.name for file in files])

get_videos_hash classmethod

get_videos_hash(files: list[SPath]) -> str
Source code in vssource/indexers/base.py
58
59
60
61
62
63
64
@classmethod
def get_videos_hash(cls, files: list[SPath]) -> str:
    from hashlib import md5

    length = sum(file.stat().st_size for file in files)
    to_hash = length.to_bytes(32, "little") + cls.get_joined_names(files).encode()
    return md5(to_hash).hexdigest()

normalize_filenames classmethod

normalize_filenames(file: SPathLike | Iterable[SPathLike]) -> list[SPath]
Source code in vssource/indexers/base.py
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def normalize_filenames(cls, file: SPathLike | Iterable[SPathLike]) -> list[SPath]:
    files = list[SPath]()

    for f in to_arr(file):
        if str(f).startswith("file:///"):
            f = str(f)[8::]

        files.append(SPath(f))

    return files

source

source(
    file: SPathLike | Iterable[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixLike | None = None,
    transfer: TransferLike | None = None,
    primaries: PrimariesLike | None = None,
    chroma_location: ChromaLocation | None = None,
    color_range: ColorRangeLike | None = None,
    field_based: FieldBasedLike | None = None,
    idx_props: bool = True,
    ref: VideoNode | None = None,
    name: str | None = None,
    **kwargs: Any
) -> VideoNode

Load one or more input files using the indexer and return a processed clip.

The returned clip is passed through initialize_clip to apply bit depth conversion and frame props initialization.

Source code in vssource/indexers/base.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
@inject_self
def source(
    self,
    file: SPathLike | Iterable[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixLike | None = None,
    transfer: TransferLike | None = None,
    primaries: PrimariesLike | None = None,
    chroma_location: ChromaLocation | None = None,
    color_range: ColorRangeLike | None = None,
    field_based: FieldBasedLike | None = None,
    idx_props: bool = True,
    ref: vs.VideoNode | None = None,
    name: str | None = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Load one or more input files using the indexer and return a processed clip.

    The returned clip is passed through [initialize_clip][vstools.initialize_clip] to apply bit depth conversion
    and frame props initialization.
    """

    nfiles = self.normalize_filenames(file)
    clip = self._source(
        [self.source_func(f.to_str(), **self.indexer_kwargs | kwargs) for f in nfiles],
        bits,
        matrix,
        transfer,
        primaries,
        chroma_location,
        color_range,
        field_based,
    )
    if idx_props:
        clip = clip.std.SetFrameProps(IdxFilePath=[f.to_str() for f in nfiles], Idx=self.__class__.__name__)

    if name:
        clip = clip.std.SetFrameProps(Name=name)

    if ref:
        clip = match_clip(clip, ref, length=True)

    return clip

source_func classmethod

source_func(path: SPathLike, **kwargs: Any) -> VideoNode
Source code in vssource/indexers/base.py
66
67
68
69
@classmethod
def source_func(cls, path: SPathLike, **kwargs: Any) -> vs.VideoNode:
    log.debug("%s: indexing %r; arguments: %r", cls, path, kwargs)
    return cls._source_func(str(path), **kwargs)

FFMS2

FFMS2(*, force: bool = True, **kwargs: Any)

Bases: CacheIndexer

FFmpegSource2 indexer.

Unlike the plugin's default behavior, the indexer cache file will be stored in .vsjet/vssource next to the script file.

Methods:

Attributes:

Source code in vssource/indexers/base.py
44
45
46
47
48
def __init__(self, *, force: bool = True, **kwargs: Any) -> None:
    super().__init__()

    self.force = force
    self.indexer_kwargs = kwargs

force instance-attribute

force = force

indexer_kwargs instance-attribute

indexer_kwargs = kwargs

get_cache_path staticmethod

get_cache_path(file_name: SPathLike, ext: str | None = None) -> SPath
Source code in vssource/indexers/base.py
158
159
160
161
162
@staticmethod
def get_cache_path(file_name: SPathLike, ext: str | None = None) -> SPath:
    storage = _get_indexer_cache_storage()

    return storage.get_file(file_name, ext=ext)

get_joined_names classmethod

get_joined_names(files: list[SPath]) -> str
Source code in vssource/indexers/base.py
54
55
56
@classmethod
def get_joined_names(cls, files: list[SPath]) -> str:
    return "_".join([file.name for file in files])

get_videos_hash classmethod

get_videos_hash(files: list[SPath]) -> str
Source code in vssource/indexers/base.py
58
59
60
61
62
63
64
@classmethod
def get_videos_hash(cls, files: list[SPath]) -> str:
    from hashlib import md5

    length = sum(file.stat().st_size for file in files)
    to_hash = length.to_bytes(32, "little") + cls.get_joined_names(files).encode()
    return md5(to_hash).hexdigest()

normalize_filenames classmethod

normalize_filenames(file: SPathLike | Iterable[SPathLike]) -> list[SPath]
Source code in vssource/indexers/base.py
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def normalize_filenames(cls, file: SPathLike | Iterable[SPathLike]) -> list[SPath]:
    files = list[SPath]()

    for f in to_arr(file):
        if str(f).startswith("file:///"):
            f = str(f)[8::]

        files.append(SPath(f))

    return files

source

source(
    file: SPathLike | Iterable[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixLike | None = None,
    transfer: TransferLike | None = None,
    primaries: PrimariesLike | None = None,
    chroma_location: ChromaLocation | None = None,
    color_range: ColorRangeLike | None = None,
    field_based: FieldBasedLike | None = None,
    idx_props: bool = True,
    ref: VideoNode | None = None,
    name: str | None = None,
    **kwargs: Any
) -> VideoNode

Load one or more input files using the indexer and return a processed clip.

The returned clip is passed through initialize_clip to apply bit depth conversion and frame props initialization.

Source code in vssource/indexers/base.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
@inject_self
def source(
    self,
    file: SPathLike | Iterable[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixLike | None = None,
    transfer: TransferLike | None = None,
    primaries: PrimariesLike | None = None,
    chroma_location: ChromaLocation | None = None,
    color_range: ColorRangeLike | None = None,
    field_based: FieldBasedLike | None = None,
    idx_props: bool = True,
    ref: vs.VideoNode | None = None,
    name: str | None = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Load one or more input files using the indexer and return a processed clip.

    The returned clip is passed through [initialize_clip][vstools.initialize_clip] to apply bit depth conversion
    and frame props initialization.
    """

    nfiles = self.normalize_filenames(file)
    clip = self._source(
        [self.source_func(f.to_str(), **self.indexer_kwargs | kwargs) for f in nfiles],
        bits,
        matrix,
        transfer,
        primaries,
        chroma_location,
        color_range,
        field_based,
    )
    if idx_props:
        clip = clip.std.SetFrameProps(IdxFilePath=[f.to_str() for f in nfiles], Idx=self.__class__.__name__)

    if name:
        clip = clip.std.SetFrameProps(Name=name)

    if ref:
        clip = match_clip(clip, ref, length=True)

    return clip

source_func classmethod

source_func(path: SPathLike, **kwargs: Any) -> VideoNode
Source code in vssource/indexers/base.py
164
165
166
167
168
169
170
171
@classmethod
def source_func(cls, path: SPathLike, **kwargs: Any) -> vs.VideoNode:
    path = SPath(path)

    if cls._cache_arg_name not in kwargs:
        kwargs[cls._cache_arg_name] = cls.get_cache_path(path.name, cls._ext)

    return super().source_func(path, **kwargs)

IMWRI

IMWRI(*, force: bool = True, **kwargs: Any)

Bases: Indexer

ImageMagick Writer-Reader indexer

Methods:

Attributes:

Source code in vssource/indexers/base.py
44
45
46
47
48
def __init__(self, *, force: bool = True, **kwargs: Any) -> None:
    super().__init__()

    self.force = force
    self.indexer_kwargs = kwargs

force instance-attribute

force = force

indexer_kwargs instance-attribute

indexer_kwargs = kwargs

get_joined_names classmethod

get_joined_names(files: list[SPath]) -> str
Source code in vssource/indexers/base.py
54
55
56
@classmethod
def get_joined_names(cls, files: list[SPath]) -> str:
    return "_".join([file.name for file in files])

get_videos_hash classmethod

get_videos_hash(files: list[SPath]) -> str
Source code in vssource/indexers/base.py
58
59
60
61
62
63
64
@classmethod
def get_videos_hash(cls, files: list[SPath]) -> str:
    from hashlib import md5

    length = sum(file.stat().st_size for file in files)
    to_hash = length.to_bytes(32, "little") + cls.get_joined_names(files).encode()
    return md5(to_hash).hexdigest()

normalize_filenames classmethod

normalize_filenames(file: SPathLike | Iterable[SPathLike]) -> list[SPath]
Source code in vssource/indexers/base.py
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def normalize_filenames(cls, file: SPathLike | Iterable[SPathLike]) -> list[SPath]:
    files = list[SPath]()

    for f in to_arr(file):
        if str(f).startswith("file:///"):
            f = str(f)[8::]

        files.append(SPath(f))

    return files

source

source(
    file: SPathLike | Iterable[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixLike | None = None,
    transfer: TransferLike | None = None,
    primaries: PrimariesLike | None = None,
    chroma_location: ChromaLocation | None = None,
    color_range: ColorRangeLike | None = None,
    field_based: FieldBasedLike | None = None,
    idx_props: bool = True,
    ref: VideoNode | None = None,
    name: str | None = None,
    **kwargs: Any
) -> VideoNode

Load one or more input files using the indexer and return a processed clip.

The returned clip is passed through initialize_clip to apply bit depth conversion and frame props initialization.

Source code in vssource/indexers/base.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
@inject_self
def source(
    self,
    file: SPathLike | Iterable[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixLike | None = None,
    transfer: TransferLike | None = None,
    primaries: PrimariesLike | None = None,
    chroma_location: ChromaLocation | None = None,
    color_range: ColorRangeLike | None = None,
    field_based: FieldBasedLike | None = None,
    idx_props: bool = True,
    ref: vs.VideoNode | None = None,
    name: str | None = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Load one or more input files using the indexer and return a processed clip.

    The returned clip is passed through [initialize_clip][vstools.initialize_clip] to apply bit depth conversion
    and frame props initialization.
    """

    nfiles = self.normalize_filenames(file)
    clip = self._source(
        [self.source_func(f.to_str(), **self.indexer_kwargs | kwargs) for f in nfiles],
        bits,
        matrix,
        transfer,
        primaries,
        chroma_location,
        color_range,
        field_based,
    )
    if idx_props:
        clip = clip.std.SetFrameProps(IdxFilePath=[f.to_str() for f in nfiles], Idx=self.__class__.__name__)

    if name:
        clip = clip.std.SetFrameProps(Name=name)

    if ref:
        clip = match_clip(clip, ref, length=True)

    return clip

source_func classmethod

source_func(path: SPathLike, **kwargs: Any) -> VideoNode
Source code in vssource/indexers/base.py
66
67
68
69
@classmethod
def source_func(cls, path: SPathLike, **kwargs: Any) -> vs.VideoNode:
    log.debug("%s: indexing %r; arguments: %r", cls, path, kwargs)
    return cls._source_func(str(path), **kwargs)

LSMAS

LSMAS(*, force: bool = True, **kwargs: Any)

Bases: CacheIndexer

L-SMASH-Works indexer.

Unlike the plugin's default behavior, the indexer cache file will be stored in .vsjet/vssource next to the script file.

Methods:

Attributes:

Source code in vssource/indexers/base.py
44
45
46
47
48
def __init__(self, *, force: bool = True, **kwargs: Any) -> None:
    super().__init__()

    self.force = force
    self.indexer_kwargs = kwargs

force instance-attribute

force = force

indexer_kwargs instance-attribute

indexer_kwargs = kwargs

get_cache_path staticmethod

get_cache_path(file_name: SPathLike, ext: str | None = None) -> SPath
Source code in vssource/indexers/base.py
158
159
160
161
162
@staticmethod
def get_cache_path(file_name: SPathLike, ext: str | None = None) -> SPath:
    storage = _get_indexer_cache_storage()

    return storage.get_file(file_name, ext=ext)

get_joined_names classmethod

get_joined_names(files: list[SPath]) -> str
Source code in vssource/indexers/base.py
54
55
56
@classmethod
def get_joined_names(cls, files: list[SPath]) -> str:
    return "_".join([file.name for file in files])

get_videos_hash classmethod

get_videos_hash(files: list[SPath]) -> str
Source code in vssource/indexers/base.py
58
59
60
61
62
63
64
@classmethod
def get_videos_hash(cls, files: list[SPath]) -> str:
    from hashlib import md5

    length = sum(file.stat().st_size for file in files)
    to_hash = length.to_bytes(32, "little") + cls.get_joined_names(files).encode()
    return md5(to_hash).hexdigest()

normalize_filenames classmethod

normalize_filenames(file: SPathLike | Iterable[SPathLike]) -> list[SPath]
Source code in vssource/indexers/base.py
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def normalize_filenames(cls, file: SPathLike | Iterable[SPathLike]) -> list[SPath]:
    files = list[SPath]()

    for f in to_arr(file):
        if str(f).startswith("file:///"):
            f = str(f)[8::]

        files.append(SPath(f))

    return files

source

source(
    file: SPathLike | Iterable[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixLike | None = None,
    transfer: TransferLike | None = None,
    primaries: PrimariesLike | None = None,
    chroma_location: ChromaLocation | None = None,
    color_range: ColorRangeLike | None = None,
    field_based: FieldBasedLike | None = None,
    idx_props: bool = True,
    ref: VideoNode | None = None,
    name: str | None = None,
    **kwargs: Any
) -> VideoNode

Load one or more input files using the indexer and return a processed clip.

The returned clip is passed through initialize_clip to apply bit depth conversion and frame props initialization.

Source code in vssource/indexers/base.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
@inject_self
def source(
    self,
    file: SPathLike | Iterable[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixLike | None = None,
    transfer: TransferLike | None = None,
    primaries: PrimariesLike | None = None,
    chroma_location: ChromaLocation | None = None,
    color_range: ColorRangeLike | None = None,
    field_based: FieldBasedLike | None = None,
    idx_props: bool = True,
    ref: vs.VideoNode | None = None,
    name: str | None = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Load one or more input files using the indexer and return a processed clip.

    The returned clip is passed through [initialize_clip][vstools.initialize_clip] to apply bit depth conversion
    and frame props initialization.
    """

    nfiles = self.normalize_filenames(file)
    clip = self._source(
        [self.source_func(f.to_str(), **self.indexer_kwargs | kwargs) for f in nfiles],
        bits,
        matrix,
        transfer,
        primaries,
        chroma_location,
        color_range,
        field_based,
    )
    if idx_props:
        clip = clip.std.SetFrameProps(IdxFilePath=[f.to_str() for f in nfiles], Idx=self.__class__.__name__)

    if name:
        clip = clip.std.SetFrameProps(Name=name)

    if ref:
        clip = match_clip(clip, ref, length=True)

    return clip

source_func classmethod

source_func(path: SPathLike, **kwargs: Any) -> VideoNode
Source code in vssource/indexers/base.py
164
165
166
167
168
169
170
171
@classmethod
def source_func(cls, path: SPathLike, **kwargs: Any) -> vs.VideoNode:
    path = SPath(path)

    if cls._cache_arg_name not in kwargs:
        kwargs[cls._cache_arg_name] = cls.get_cache_path(path.name, cls._ext)

    return super().source_func(path, **kwargs)

ZipSource

ZipSource(*, force: bool = True, **kwargs: Any)

Bases: Indexer

vszip image reader indexer

Methods:

Attributes:

Source code in vssource/indexers/base.py
44
45
46
47
48
def __init__(self, *, force: bool = True, **kwargs: Any) -> None:
    super().__init__()

    self.force = force
    self.indexer_kwargs = kwargs

force instance-attribute

force = force

indexer_kwargs instance-attribute

indexer_kwargs = kwargs

get_joined_names classmethod

get_joined_names(files: list[SPath]) -> str
Source code in vssource/indexers/base.py
54
55
56
@classmethod
def get_joined_names(cls, files: list[SPath]) -> str:
    return "_".join([file.name for file in files])

get_videos_hash classmethod

get_videos_hash(files: list[SPath]) -> str
Source code in vssource/indexers/base.py
58
59
60
61
62
63
64
@classmethod
def get_videos_hash(cls, files: list[SPath]) -> str:
    from hashlib import md5

    length = sum(file.stat().st_size for file in files)
    to_hash = length.to_bytes(32, "little") + cls.get_joined_names(files).encode()
    return md5(to_hash).hexdigest()

normalize_filenames classmethod

normalize_filenames(file: SPathLike | Iterable[SPathLike]) -> list[SPath]
Source code in vssource/indexers/base.py
71
72
73
74
75
76
77
78
79
80
81
@classmethod
def normalize_filenames(cls, file: SPathLike | Iterable[SPathLike]) -> list[SPath]:
    files = list[SPath]()

    for f in to_arr(file):
        if str(f).startswith("file:///"):
            f = str(f)[8::]

        files.append(SPath(f))

    return files

source

source(
    file: SPathLike | Iterable[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixLike | None = None,
    transfer: TransferLike | None = None,
    primaries: PrimariesLike | None = None,
    chroma_location: ChromaLocation | None = None,
    color_range: ColorRangeLike | None = None,
    field_based: FieldBasedLike | None = None,
    idx_props: bool = True,
    ref: VideoNode | None = None,
    name: str | None = None,
    **kwargs: Any
) -> VideoNode

Load one or more input files using the indexer and return a processed clip.

The returned clip is passed through initialize_clip to apply bit depth conversion and frame props initialization.

Source code in vssource/indexers/base.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
@inject_self
def source(
    self,
    file: SPathLike | Iterable[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixLike | None = None,
    transfer: TransferLike | None = None,
    primaries: PrimariesLike | None = None,
    chroma_location: ChromaLocation | None = None,
    color_range: ColorRangeLike | None = None,
    field_based: FieldBasedLike | None = None,
    idx_props: bool = True,
    ref: vs.VideoNode | None = None,
    name: str | None = None,
    **kwargs: Any,
) -> vs.VideoNode:
    """
    Load one or more input files using the indexer and return a processed clip.

    The returned clip is passed through [initialize_clip][vstools.initialize_clip] to apply bit depth conversion
    and frame props initialization.
    """

    nfiles = self.normalize_filenames(file)
    clip = self._source(
        [self.source_func(f.to_str(), **self.indexer_kwargs | kwargs) for f in nfiles],
        bits,
        matrix,
        transfer,
        primaries,
        chroma_location,
        color_range,
        field_based,
    )
    if idx_props:
        clip = clip.std.SetFrameProps(IdxFilePath=[f.to_str() for f in nfiles], Idx=self.__class__.__name__)

    if name:
        clip = clip.std.SetFrameProps(Name=name)

    if ref:
        clip = match_clip(clip, ref, length=True)

    return clip

source_func classmethod

source_func(path: SPathLike, **kwargs: Any) -> VideoNode
Source code in vssource/indexers/base.py
66
67
68
69
@classmethod
def source_func(cls, path: SPathLike, **kwargs: Any) -> vs.VideoNode:
    log.debug("%s: indexing %r; arguments: %r", cls, path, kwargs)
    return cls._source_func(str(path), **kwargs)