-
Notifications
You must be signed in to change notification settings - Fork 8
Added logic for utilising mkvpropedit with pymkv2 #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #84 +/- ##
==========================================
- Coverage 67.25% 65.53% -1.73%
==========================================
Files 10 10
Lines 959 1062 +103
==========================================
+ Hits 645 696 +51
- Misses 314 366 +52 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thank you for the first PR. I’ll review it and get back to you later. |
|
I tried to understand the code coverage tests but I don't get it. I understand there are lines not hit during tests, I found the tests and read the GitHub workflows to be able to run the tests locally, but I don't know how to extend those tests to cover the added lines, sorry. |
|
@MasinAD To understand how to work with the tests, start by studying the Makefile file — it prepares the data and runs the tests. All the tests are divided according to the main actions you can perform with pymkv. |
|
I deliberately didn’t use the if ... in ... else None construction because it would be difficult for other people — and even for you yourself — to understand what’s going on there. |
|
I’d move the cmd-related logic out of update, following the approach used in the main code. |
I did that because I need a way to distinguish between initialization of the object and later modifications. Otherwise the |
I used the functions I'd really like to merge my contributions into the existing functions but I don't want to risk compatibility. I'd rename |
|
I tried adding this test from pathlib import Path
from pymkv import MKVFile
def test_set_flag_default_true(
get_base_path: Path,
get_path_test_file: Path,
) -> None:
mkv = MKVFile(str(get_path_test_file))
track = mkv.get_track(1)
track.default_track = True
assert track.default_track
def test_set_flag_default_false(
get_base_path: Path,
get_path_test_file: Path,
) -> None:
mkv = MKVFile(str(get_path_test_file))
track = mkv.get_track(1)
track.default_track = False
assert not track.default_trackBut pytest always complains about
I'd have added similar test for all the other flags but I refrained from it until I sorted this one out. To me it seems like Currently, that's a bit of a showstopper for me as I cannot easily test the When using the above code as a simple python script, it works without any issues: from pathlib import Path
from pymkv import MKVFile
def test_set_flag_default_true(
get_base_path: Path,
get_path_test_file: Path,
) -> None:
mkv = MKVFile(str(get_path_test_file))
track = mkv.get_track(1)
print( track.default_track )
track.default_track = True
assert track.default_track
test_path = Path.cwd() / "tests"
test_file = test_path / 'file.mkv'
test_set_flag_default_true( test_path, test_file )Any advice? |
I already used pymkv2 in a script to mux several files into one so it was a logical choice for me to also use it to edit properties of an existing MKV file. I was puzzled by the lack of the functionality so I hacked it together myself and want to contribute it back.
I tried to orientate myself at how things were already done but saw the necessity to refactor some small parts to make it work easier with mkvtoolnix' approach for
mkvpropedit. I have neither checked if I brokemkvmergeusage nor did I write any tests due to lack of knowledge on how to write tests (or if there are even tests for pymkv2).I'd gladly like to iterate on this pull request.
What does it do? Wherever possible I hooked into existing code to record changes made to an
MKVFileinstance and itsMKVTrackchildren. These changes are then compiled into anmkvpropeditcommand line inMKVTrack.propedit()and called fromMKVFile.update(), the latter being basically a copy ofMKVFile.mux().I restructured
MKVTrackto store the MKV flags in a_flagsdictionary and re-created object properties with the former names for backwards compatibility. If there's any breakage to be expected I'd guess the reasons lie there.The list of MKV properties
mkvpropeditis able to handle is much longer than whatever pymkv2 supported, and I only implemented code for those properties I needed and those pymkv2 already handled formkvmerge. Extending this beyond the current scope is easy, though.