Skip to content

Commit 5874073

Browse files
committed
Improve UX, some bug fixes
1 parent 458d392 commit 5874073

File tree

8 files changed

+519
-204
lines changed

8 files changed

+519
-204
lines changed

CHANGELOG.md

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,97 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## Unreleased
9+
10+
This version is all about improving the UX and upgrading it's tooling. Support for
11+
Python 3.8 has been dropped, but 3.12 is now supported. Unfortunately this means
12+
dropping support for Windows 7/8/8.1 as well. This was more or less necessary to keep
13+
up with the latest versions of other dependencies as well as crucial bug fixes.
14+
15+
### Fixed
16+
17+
- Various CI and linting tooling mistakes and made it more efficient.
18+
- Fixed unsetting of verbosity and cracking modes on Windows systems by requiring
19+
Python 3.9 or newer as the `os.unsetenv` function only existed on other operating
20+
systems before then.
21+
- Fixed value comparison used when unsetting cracking mode to "unset" string, not
22+
`-1` integer.
23+
24+
### Changed
25+
26+
- Various doc-strings were improved and made more clear in various ways.
27+
- Most PyDvdCss-inherited exceptions now try to call `DvdCss.error()` for you to
28+
include potentially useful error information when the errors happen. Though, Errors
29+
from the library are not always available.
30+
- The base exception `PyDvdCssException` was renamed to `PyDvdCssError`.
31+
- The exception `LibDvdCssNotFound` was renamed to `LibraryNotFoundError`.
32+
- `DvdCss.close()` now only returns True if a device was actually closed when called.
33+
- `DvdCss.set_verbosity()` has been renamed to `DvdCss.set_verbosity_level()`.
34+
- `DvdCss.error()` is now a property, via `@property` decorator.
35+
- `DvdCss.error` will now return None if no DVD device or directory was opened yet.
36+
- `DvdCss.error` may now return None if there is no error string to return, or if
37+
the error string is falsey (basically empty).
38+
- `DvdCss.error` now does whitespace stripping on both the left and right instead
39+
of just the right.
40+
- `DvdCss.is_scrambled()` is now a property, via `@property` decorator.
41+
- `DvdCss.is_scrambled` will now return False if no DVD device or directory was opened yet.
42+
- `DvdCss.open()` changed parameter names from `psz_target` to `target`.
43+
- `DvdCss.seek()` changed parameter names from `i_blocks` to `sector` and `i_flags` to
44+
`flag`.
45+
- `DvdCss.read()` changed parameter names from `i_blocks` to `sectors` and `i_flags` to
46+
`flag`.
47+
- `DvdCss.set_verbosity_level()` changed parameter names from `verbosity` to `level`.
48+
- `DvdCss.seek()` now uses a `SeekFlag` enum for the `flag` parameter instead of an
49+
integer value. However, you can still use an int if you prefer.
50+
- `DvdCss.read()` now uses a `ReadFlag` enum for the `flag` parameter instead of an
51+
integer value. However, you can still use an int if you prefer.
52+
- `DvdCss.set_verbosity_level()` now uses a `VerbosityLevel` enum for the `level` parameter
53+
and return value instead of an integer value. However, you can still pass an int if
54+
you prefer.
55+
- `DvdCss.set_cracking_mode()` now uses a `CrackingMode` enum for the `mode` parameter
56+
and return value instead of a string value. However, you can still pass a string if
57+
you prefer.
58+
- `DvdCss.open()` and `DvdCss.open_stream()` now raises an `AlreadyInUseError` exception
59+
instead of a `ValueError` when you try to open a 2nd disc in the same class instance.
60+
- `DvdCss.open()` and `DvdCss.open_stream()` now raises an `OpenFailureError` exception
61+
instead of returning -1 on failure to open and initialize the device or directory.
62+
- `DvdCss.seek()` and `DvdCss.read()` now raises a `NoDeviceError` exception when called
63+
if no DVD device or directory was opened yet.
64+
- `DvdCss.seek()` now raises a `SeekError` exception instead of returning negative
65+
numbers on seek failures.
66+
- `DvdCss.read()` now raises a `SeekError` exception instead of a negative integer when
67+
it fails to seek.
68+
- `DvdCss.read()` now raises a `ReadError` exception instead of an `IOError` on failure
69+
to read one or more sectors.
70+
- `DvdCss.close()` now raises a `CloseError` exception instead of a `ValueError` on
71+
failure to close an open device or directory.
72+
- `DvdCss.dispose()` is now deprecated and an alias of `DvdCss.close()` and no longer
73+
unsets the verbosity level or cracking mode environment variables. This is because
74+
this is set in your environment, not per-instance. Its not logical to reset it when
75+
it will affect every other instance running. Instead, pay close attention to your
76+
instances and handle resetting the level/mode yourself.
77+
- The list of possible library names were put into constants as `LIBRARY_NAMES`.
78+
79+
### Removed
80+
81+
- The `SECTOR_SIZE`, `BLOCK_BUFFER`, `NO_FLAGS`, `READ_DECRYPT`, `SEEK_MPEG`,
82+
`SEEK_KEY`, `flags_m`, and `flags_s` class variables were removed. The variables to
83+
do with flags/read/seek were refactored as SeekFlag and ReadFlag.
84+
885
## [1.4.0] - 2023-10-12
986

10-
## Added
87+
### Added
1188

1289
- Added function `open_stream()` that calls the `dvdcss_open_stream` function of the libdvdcss library.
1390
- Defined `dvdcss_stream_cb`, `pf_seek`, `pf_read`, `pf_readv`, and `dvdcss_open_stream`.
1491

15-
## Changed
92+
### Changed
1693

1794
- Various structural and organisational changes to the repository, CI/CD, and more.
1895
- Updated dependencies as far as I could while keeping support for actively supported versions of Python.
1996
- Moved all documentation dependencies from dev to main group as optionals installed through the `docs` extra.
2097

21-
## Removed
98+
### Removed
2299

23100
- Dropped support for Python 3.5, 3.6, and 3.7. This is to have support for the latest dependency versions.
24101
- Removed all uses of poetry-dynamic-versioning as it's simply unnecessary.

docs/index.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Release v\ |version|. (:ref:`Installation <installation>`)
2424
>>> dvd = DvdCss()
2525
>>> dvd.open("D:")
2626
-1333389968
27-
>>> dvd.is_scrambled()
27+
>>> dvd.is_scrambled
2828
True
2929
>>> dvd.seek(16)
3030
16
@@ -36,8 +36,6 @@ Release v\ |version|. (:ref:`Installation <installation>`)
3636
b'SPONGEBOB_SQUAREPANTS_D1\x00\x00...'
3737
>>> dvd.close()
3838
True
39-
>>> dvd.dispose()
40-
True
4139

4240
libdvdcss (via pydvdcss) is a simple library designed for accessing DVDs like a
4341
block device without having to bother about the decryption.

pydvdcss/constants.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
INSTALL_HELP = """
2+
- Linux: Check your distro's repositories.
3+
- Mac: Use brew (brew.sh), `brew install libdvdcss`.
4+
- Windows: Download a pre-compiled DLL at git.io/libdvdcss-dll and place it in
5+
next to pydvdcss, in your current working directory, or in C:/Windows/System32.
6+
""".strip()
7+
8+
LIBRARY_NAMES = ("dvdcss", "dvdcss2", "libdvdcss", "libdvdcss2", "libdvdcss-2")
9+
SECTOR_SIZE = 2048

0 commit comments

Comments
 (0)