pymkv2 2.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pymkv2-2.0.1/LICENSE.txt +21 -0
- pymkv2-2.0.1/PKG-INFO +68 -0
- pymkv2-2.0.1/README.md +39 -0
- pymkv2-2.0.1/pymkv/BCP47.py +24 -0
- pymkv2-2.0.1/pymkv/ISO639_2.py +27 -0
- pymkv2-2.0.1/pymkv/MKVAttachment.py +96 -0
- pymkv2-2.0.1/pymkv/MKVFile.py +1003 -0
- pymkv2-2.0.1/pymkv/MKVTrack.py +384 -0
- pymkv2-2.0.1/pymkv/Timestamp.py +258 -0
- pymkv2-2.0.1/pymkv/TypeTrack.py +72 -0
- pymkv2-2.0.1/pymkv/Verifications.py +118 -0
- pymkv2-2.0.1/pymkv/__init__.py +29 -0
- pymkv2-2.0.1/pyproject.toml +157 -0
pymkv2-2.0.1/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Sheldon Woodward
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
pymkv2-2.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pymkv2
|
|
3
|
+
Version: 2.0.1
|
|
4
|
+
Summary: A Python wrapper for mkvmerge. It provides support for muxing, splitting, linking, chapters, tags, and attachments through the use of mkvmerge.
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: wrapper
|
|
7
|
+
Author: Sheldon Woodward
|
|
8
|
+
Author-email: me@sheldonw.com
|
|
9
|
+
Requires-Python: >=3.9,<4.0
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Multimedia :: Video :: Conversion
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Dist: bcp47 (==0.0.6)
|
|
24
|
+
Requires-Dist: bitmath (==1.3.3.1)
|
|
25
|
+
Requires-Dist: iso-639 (==0.4.5)
|
|
26
|
+
Project-URL: homepage, https://github.com/GitBib/pymkv2
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# pymkv2
|
|
30
|
+
[](https://pypi.python.org/pypi/pymkv2)
|
|
31
|
+
[](https://github.com/gitbib/pymkv/LICENSE.txt)
|
|
32
|
+
|
|
33
|
+
pymkv2 is a Python wrapper for mkvmerge and other tools in the MKVToolNix suite. It provides support for muxing,
|
|
34
|
+
splitting, linking, chapters, tags, and attachments through the use of mkvmerge.
|
|
35
|
+
|
|
36
|
+
## About pymkv2
|
|
37
|
+
it's a fork of the [project](https://github.com/sheldonkwoodward/pymkv). Pymkv2 is a Python 3 library for manipulating MKV files with mkvmerge. Constructing mkvmerge commands manually can
|
|
38
|
+
quickly become confusing and complex. To remedy this, I decided to write this library to make mkvmerge more
|
|
39
|
+
scriptable and easier to use. Please open new issues for any bugs you find, support is greatly appreciated!
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
mkvmerge must be installed on your computer, it is needed to process files when creating MKV objects. It is also
|
|
43
|
+
recommended to add it to your $PATH variable but a different path can be manually specified. mkvmerge can be found
|
|
44
|
+
and downloaded from [here](https://mkvtoolnix.download/downloads.html) or from most package managers.
|
|
45
|
+
|
|
46
|
+
You can also clone the repo and run the following command in the project root to install the source code as editable:
|
|
47
|
+
|
|
48
|
+
$ pip install -e .
|
|
49
|
+
|
|
50
|
+
## Documentation
|
|
51
|
+
The documentation for pymkv can be found [here](https://gitbib.github.io/pymkv2/) or in the project's docstrings.
|
|
52
|
+
|
|
53
|
+
### Tests
|
|
54
|
+
~~After completing documentation for the existing features, unit tests need to be written to "lock in" the existing
|
|
55
|
+
functionality. Generating mkvmerge commands can be complex and it is easy to subtly modify an existing feature when
|
|
56
|
+
adding a new one. Unit tests will ensure that features remain the same and help prevent bugs in the future.~~
|
|
57
|
+
|
|
58
|
+
### Cleanup
|
|
59
|
+
~~The existing code base could use some tidying, better commenting, debugging, and a general styling overhaul. Setting up
|
|
60
|
+
[pre-commit](https://pre-commit.com/) and the [Black code formatter](https://github.com/psf/black) will help keep the
|
|
61
|
+
code base more readable and maintainable.~~
|
|
62
|
+
|
|
63
|
+
### Features
|
|
64
|
+
~~Once these first three steps are complete, pymkv will be ready to start adding new features. The goal is for pymkv to
|
|
65
|
+
implement the functionality of mkvmerge and other MKVToolNix tools as closely as possible. New features and bugs will
|
|
66
|
+
be added to the [GitHub issues page](https://github.com/gitbib/pymkv/issues). As pymkv progresses through
|
|
67
|
+
the previous steps, this roadmap will be expanded to outline new features.~~
|
|
68
|
+
|
pymkv2-2.0.1/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# pymkv2
|
|
2
|
+
[](https://pypi.python.org/pypi/pymkv2)
|
|
3
|
+
[](https://github.com/gitbib/pymkv/LICENSE.txt)
|
|
4
|
+
|
|
5
|
+
pymkv2 is a Python wrapper for mkvmerge and other tools in the MKVToolNix suite. It provides support for muxing,
|
|
6
|
+
splitting, linking, chapters, tags, and attachments through the use of mkvmerge.
|
|
7
|
+
|
|
8
|
+
## About pymkv2
|
|
9
|
+
it's a fork of the [project](https://github.com/sheldonkwoodward/pymkv). Pymkv2 is a Python 3 library for manipulating MKV files with mkvmerge. Constructing mkvmerge commands manually can
|
|
10
|
+
quickly become confusing and complex. To remedy this, I decided to write this library to make mkvmerge more
|
|
11
|
+
scriptable and easier to use. Please open new issues for any bugs you find, support is greatly appreciated!
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
mkvmerge must be installed on your computer, it is needed to process files when creating MKV objects. It is also
|
|
15
|
+
recommended to add it to your $PATH variable but a different path can be manually specified. mkvmerge can be found
|
|
16
|
+
and downloaded from [here](https://mkvtoolnix.download/downloads.html) or from most package managers.
|
|
17
|
+
|
|
18
|
+
You can also clone the repo and run the following command in the project root to install the source code as editable:
|
|
19
|
+
|
|
20
|
+
$ pip install -e .
|
|
21
|
+
|
|
22
|
+
## Documentation
|
|
23
|
+
The documentation for pymkv can be found [here](https://gitbib.github.io/pymkv2/) or in the project's docstrings.
|
|
24
|
+
|
|
25
|
+
### Tests
|
|
26
|
+
~~After completing documentation for the existing features, unit tests need to be written to "lock in" the existing
|
|
27
|
+
functionality. Generating mkvmerge commands can be complex and it is easy to subtly modify an existing feature when
|
|
28
|
+
adding a new one. Unit tests will ensure that features remain the same and help prevent bugs in the future.~~
|
|
29
|
+
|
|
30
|
+
### Cleanup
|
|
31
|
+
~~The existing code base could use some tidying, better commenting, debugging, and a general styling overhaul. Setting up
|
|
32
|
+
[pre-commit](https://pre-commit.com/) and the [Black code formatter](https://github.com/psf/black) will help keep the
|
|
33
|
+
code base more readable and maintainable.~~
|
|
34
|
+
|
|
35
|
+
### Features
|
|
36
|
+
~~Once these first three steps are complete, pymkv will be ready to start adding new features. The goal is for pymkv to
|
|
37
|
+
implement the functionality of mkvmerge and other MKVToolNix tools as closely as possible. New features and bugs will
|
|
38
|
+
be added to the [GitHub issues page](https://github.com/gitbib/pymkv/issues). As pymkv progresses through
|
|
39
|
+
the previous steps, this roadmap will be expanded to outline new features.~~
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# sheldon woodward
|
|
2
|
+
# 10/21/20
|
|
3
|
+
|
|
4
|
+
"""BCP47 language region code"""
|
|
5
|
+
|
|
6
|
+
import bcp47
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def is_bcp47(language_ietf):
|
|
10
|
+
"""The `is_bcp47` function checks if a given language tag is a valid BCP47 language tag.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
language_ietf: The language tag to be checked.
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
bool: True if the language tag is a valid BCP47 language tag, False otherwise.
|
|
17
|
+
|
|
18
|
+
Raises:
|
|
19
|
+
None
|
|
20
|
+
"""
|
|
21
|
+
if language_ietf == "und":
|
|
22
|
+
return True
|
|
23
|
+
else:
|
|
24
|
+
return language_ietf in bcp47.languages.values()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# sheldon woodward
|
|
2
|
+
# 3/18/18
|
|
3
|
+
|
|
4
|
+
"""ISO639-2 Three Character Language Codes"""
|
|
5
|
+
|
|
6
|
+
from typing import Optional
|
|
7
|
+
|
|
8
|
+
from iso639 import languages
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def is_iso639_2(language) -> Optional[bool]:
|
|
12
|
+
"""The `is_iso639_2` function checks if a given language code is a valid ISO 639-2 language code.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
language: The language code to be checked.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
bool: True if the language code is a valid ISO 639-2 language code, False otherwise.
|
|
19
|
+
|
|
20
|
+
Raises:
|
|
21
|
+
None
|
|
22
|
+
"""
|
|
23
|
+
try:
|
|
24
|
+
languages.get(part2b=language)
|
|
25
|
+
return True
|
|
26
|
+
except KeyError:
|
|
27
|
+
return False
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
""":class:`~pymkv.MKVAttachment` classes are used to represent attachment files within an MKV or to be used in an
|
|
2
|
+
MKV.
|
|
3
|
+
|
|
4
|
+
Examples
|
|
5
|
+
--------
|
|
6
|
+
Below are some basic examples of how the :class:`~pymkv.MKVAttachment` objects can be used.
|
|
7
|
+
|
|
8
|
+
Create a new :class:`~pymkv.MKVAttachment` and add it to an :class:`~pymkv.MKVFile`.
|
|
9
|
+
|
|
10
|
+
>>> from pymkv import MKVAttachment
|
|
11
|
+
>>> attachment = MKVAttachment('path/to/attachment.jpg', name='NAME')
|
|
12
|
+
>>> attachment.description = 'DESCRIPTION'
|
|
13
|
+
|
|
14
|
+
Attachments can also be added directly to an :class:`~pymkv.MKVFile`.
|
|
15
|
+
|
|
16
|
+
>>> from pymkv import MKVFile
|
|
17
|
+
>>> mkv = MKVFile('path/to/file.mkv')
|
|
18
|
+
>>> mkv.add_attachment('path/to/other/attachment.png')
|
|
19
|
+
|
|
20
|
+
Now, the MKV can be muxed with both attachments.
|
|
21
|
+
|
|
22
|
+
>>> mkv.add_attachment(attachment)
|
|
23
|
+
>>> mkv.mux('path/to/output.mkv')
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
from mimetypes import guess_type
|
|
29
|
+
from pathlib import Path
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class MKVAttachment:
|
|
33
|
+
"""A class that represents an MKV attachment for an :class:`~pymkv.MKVFile` object.
|
|
34
|
+
|
|
35
|
+
Parameters
|
|
36
|
+
----------
|
|
37
|
+
file_path : str
|
|
38
|
+
The path to the attachment file.
|
|
39
|
+
name : str, optional
|
|
40
|
+
The name that will be given to the attachment when muxed into a file.
|
|
41
|
+
description : str, optional
|
|
42
|
+
The description that will be given to the attachment when muxed into a file.
|
|
43
|
+
attach_once : bool, optional
|
|
44
|
+
Determines if the attachment should be added to all split files or only the first. Default is False,
|
|
45
|
+
which will attach to all files.
|
|
46
|
+
|
|
47
|
+
Attributes
|
|
48
|
+
----------
|
|
49
|
+
mime_type : str
|
|
50
|
+
The attachment's MIME type. The type will be guessed when :attr:`~pymkv.MKVAttachment.file_path` is set.
|
|
51
|
+
name : str
|
|
52
|
+
The name that will be given to the attachment when muxed into a file.
|
|
53
|
+
description : str
|
|
54
|
+
The description that will be given to the attachment when muxed into a file.
|
|
55
|
+
attach_once : bool
|
|
56
|
+
Determines if the attachment should be added to all split files or only the first. Default is False,
|
|
57
|
+
which will attach to all files.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
def __init__(
|
|
61
|
+
self,
|
|
62
|
+
file_path: str,
|
|
63
|
+
name: str | None = None,
|
|
64
|
+
description: str | None = None,
|
|
65
|
+
attach_once: bool | None = False,
|
|
66
|
+
) -> None:
|
|
67
|
+
self.mime_type = None
|
|
68
|
+
self._file_path = None
|
|
69
|
+
self.file_path = file_path
|
|
70
|
+
self.name = name
|
|
71
|
+
self.description = description
|
|
72
|
+
self.attach_once = attach_once
|
|
73
|
+
|
|
74
|
+
def __repr__(self) -> str:
|
|
75
|
+
return repr(self.__dict__)
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
def file_path(self) -> str:
|
|
79
|
+
"""str: The path to the attachment file.
|
|
80
|
+
|
|
81
|
+
Raises
|
|
82
|
+
------
|
|
83
|
+
FileNotFoundError
|
|
84
|
+
Raised if `file_path` does not exist.
|
|
85
|
+
"""
|
|
86
|
+
return self._file_path
|
|
87
|
+
|
|
88
|
+
@file_path.setter
|
|
89
|
+
def file_path(self, file_path: str) -> None:
|
|
90
|
+
file_path = Path.expanduser(Path(file_path))
|
|
91
|
+
if not Path.is_file(file_path):
|
|
92
|
+
msg = f'"{file_path}" does not exist'
|
|
93
|
+
raise FileNotFoundError(msg)
|
|
94
|
+
self.mime_type = guess_type(file_path)[0]
|
|
95
|
+
self.name = None
|
|
96
|
+
self._file_path = file_path
|