Skip to content

misc

Classes:

BestSource

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

Bases: Indexer, vs_object

BestSource indexer

Classes:

Methods:

Attributes:

Source code
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
def __init__(self, *, force: bool = True, **kwargs: Any) -> None:
    kwargs.setdefault("cachemode", BestSource.CacheMode.ABSOLUTE)
    super().__init__(force=force, **kwargs)

    from logging import WARNING, getLogger

    try:
        from vspreview import is_preview
    except ImportError:
        def is_preview() -> bool:
            return False

    def handler_func_best_source(m_type: vs.MessageType, msg: str) -> None:
        if all([
            m_type == vs.MESSAGE_TYPE_INFORMATION,
            msg.startswith("VideoSource "),
            getLogger().level <= WARNING,
            is_preview()
        ]):
            print(msg, end="\r")

    self._log_handle = core.add_log_handler(handler_func_best_source)

force instance-attribute

force = force

indexer_kwargs instance-attribute

indexer_kwargs = kwargs

CacheMode

Bases: CustomIntEnum

Cache mode

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.

get_joined_names classmethod

get_joined_names(files: list[SPath]) -> str
Source code
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
58
59
60
61
62
@classmethod
def get_videos_hash(cls, files: list[SPath]) -> str:
    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 | Sequence[SPathLike]) -> list[SPath]
Source code
68
69
70
71
72
73
74
75
76
77
78
@classmethod
def normalize_filenames(cls, file: SPathLike | Sequence[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 | Sequence[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixT | None = None,
    transfer: TransferT | None = None,
    primaries: PrimariesT | None = None,
    chroma_location: ChromaLocationT | None = None,
    color_range: ColorRangeT | None = None,
    field_based: FieldBasedT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
@inject_self
def source(
    self, file: SPathLike | Sequence[SPathLike],
    bits: int | None = None, *,
    matrix: MatrixT | None = None,
    transfer: TransferT | None = None,
    primaries: PrimariesT | None = None,
    chroma_location: ChromaLocationT | None = None,
    color_range: ColorRangeT | None = None,
    field_based: FieldBasedT | None = None,
    **kwargs: Any
) -> vs.VideoNode:
    return self._source(
        [self.source_func(f.to_str(), **self.indexer_kwargs | kwargs) for f in self.normalize_filenames(file)],
        bits, matrix, transfer, primaries, chroma_location, color_range, field_based
    )

source_func classmethod

source_func(path: DataType | SPathLike, *args: Any, **kwargs: Any) -> VideoNode
Source code
64
65
66
@classmethod
def source_func(cls, path: DataType | SPathLike, *args: Any, **kwargs: Any) -> vs.VideoNode:
    return cls._source_func(str(path), *args, **kwargs)

CarefulSource

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

Bases: Indexer

CarefulSource indexer

Methods:

Attributes:

Source code
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
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
58
59
60
61
62
@classmethod
def get_videos_hash(cls, files: list[SPath]) -> str:
    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 | Sequence[SPathLike]) -> list[SPath]
Source code
68
69
70
71
72
73
74
75
76
77
78
@classmethod
def normalize_filenames(cls, file: SPathLike | Sequence[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 | Sequence[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixT | None = None,
    transfer: TransferT | None = None,
    primaries: PrimariesT | None = None,
    chroma_location: ChromaLocationT | None = None,
    color_range: ColorRangeT | None = None,
    field_based: FieldBasedT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
@inject_self
def source(
    self, file: SPathLike | Sequence[SPathLike],
    bits: int | None = None, *,
    matrix: MatrixT | None = None,
    transfer: TransferT | None = None,
    primaries: PrimariesT | None = None,
    chroma_location: ChromaLocationT | None = None,
    color_range: ColorRangeT | None = None,
    field_based: FieldBasedT | None = None,
    **kwargs: Any
) -> vs.VideoNode:
    return self._source(
        [self.source_func(f.to_str(), **self.indexer_kwargs | kwargs) for f in self.normalize_filenames(file)],
        bits, matrix, transfer, primaries, chroma_location, color_range, field_based
    )

source_func classmethod

source_func(path: DataType | SPathLike, *args: Any, **kwargs: Any) -> VideoNode
Source code
64
65
66
@classmethod
def source_func(cls, path: DataType | SPathLike, *args: Any, **kwargs: Any) -> vs.VideoNode:
    return cls._source_func(str(path), *args, **kwargs)

FFMS2

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

Bases: Indexer

FFmpegSource2 indexer

Methods:

Attributes:

Source code
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
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
58
59
60
61
62
@classmethod
def get_videos_hash(cls, files: list[SPath]) -> str:
    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 | Sequence[SPathLike]) -> list[SPath]
Source code
68
69
70
71
72
73
74
75
76
77
78
@classmethod
def normalize_filenames(cls, file: SPathLike | Sequence[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 | Sequence[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixT | None = None,
    transfer: TransferT | None = None,
    primaries: PrimariesT | None = None,
    chroma_location: ChromaLocationT | None = None,
    color_range: ColorRangeT | None = None,
    field_based: FieldBasedT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
@inject_self
def source(
    self, file: SPathLike | Sequence[SPathLike],
    bits: int | None = None, *,
    matrix: MatrixT | None = None,
    transfer: TransferT | None = None,
    primaries: PrimariesT | None = None,
    chroma_location: ChromaLocationT | None = None,
    color_range: ColorRangeT | None = None,
    field_based: FieldBasedT | None = None,
    **kwargs: Any
) -> vs.VideoNode:
    return self._source(
        [self.source_func(f.to_str(), **self.indexer_kwargs | kwargs) for f in self.normalize_filenames(file)],
        bits, matrix, transfer, primaries, chroma_location, color_range, field_based
    )

source_func classmethod

source_func(path: DataType | SPathLike, *args: Any, **kwargs: Any) -> VideoNode
Source code
64
65
66
@classmethod
def source_func(cls, path: DataType | SPathLike, *args: Any, **kwargs: Any) -> vs.VideoNode:
    return cls._source_func(str(path), *args, **kwargs)

IMWRI

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

Bases: Indexer

ImageMagick Writer-Reader indexer

Methods:

Attributes:

Source code
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
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
58
59
60
61
62
@classmethod
def get_videos_hash(cls, files: list[SPath]) -> str:
    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 | Sequence[SPathLike]) -> list[SPath]
Source code
68
69
70
71
72
73
74
75
76
77
78
@classmethod
def normalize_filenames(cls, file: SPathLike | Sequence[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 | Sequence[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixT | None = None,
    transfer: TransferT | None = None,
    primaries: PrimariesT | None = None,
    chroma_location: ChromaLocationT | None = None,
    color_range: ColorRangeT | None = None,
    field_based: FieldBasedT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
@inject_self
def source(
    self, file: SPathLike | Sequence[SPathLike],
    bits: int | None = None, *,
    matrix: MatrixT | None = None,
    transfer: TransferT | None = None,
    primaries: PrimariesT | None = None,
    chroma_location: ChromaLocationT | None = None,
    color_range: ColorRangeT | None = None,
    field_based: FieldBasedT | None = None,
    **kwargs: Any
) -> vs.VideoNode:
    return self._source(
        [self.source_func(f.to_str(), **self.indexer_kwargs | kwargs) for f in self.normalize_filenames(file)],
        bits, matrix, transfer, primaries, chroma_location, color_range, field_based
    )

source_func classmethod

source_func(path: DataType | SPathLike, *args: Any, **kwargs: Any) -> VideoNode
Source code
64
65
66
@classmethod
def source_func(cls, path: DataType | SPathLike, *args: Any, **kwargs: Any) -> vs.VideoNode:
    return cls._source_func(str(path), *args, **kwargs)

LSMAS

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

Bases: Indexer

L-SMASH-Works indexer

Methods:

Attributes:

Source code
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
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
58
59
60
61
62
@classmethod
def get_videos_hash(cls, files: list[SPath]) -> str:
    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 | Sequence[SPathLike]) -> list[SPath]
Source code
68
69
70
71
72
73
74
75
76
77
78
@classmethod
def normalize_filenames(cls, file: SPathLike | Sequence[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 | Sequence[SPathLike],
    bits: int | None = None,
    *,
    matrix: MatrixT | None = None,
    transfer: TransferT | None = None,
    primaries: PrimariesT | None = None,
    chroma_location: ChromaLocationT | None = None,
    color_range: ColorRangeT | None = None,
    field_based: FieldBasedT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
@inject_self
def source(
    self, file: SPathLike | Sequence[SPathLike],
    bits: int | None = None, *,
    matrix: MatrixT | None = None,
    transfer: TransferT | None = None,
    primaries: PrimariesT | None = None,
    chroma_location: ChromaLocationT | None = None,
    color_range: ColorRangeT | None = None,
    field_based: FieldBasedT | None = None,
    **kwargs: Any
) -> vs.VideoNode:
    return self._source(
        [self.source_func(f.to_str(), **self.indexer_kwargs | kwargs) for f in self.normalize_filenames(file)],
        bits, matrix, transfer, primaries, chroma_location, color_range, field_based
    )

source_func classmethod

source_func(path: DataType | SPathLike, *args: Any, **kwargs: Any) -> VideoNode
Source code
64
65
66
@classmethod
def source_func(cls, path: DataType | SPathLike, *args: Any, **kwargs: Any) -> vs.VideoNode:
    return cls._source_func(str(path), *args, **kwargs)