Skip to content

Commit ee51d12

Browse files
committed
Fix definition of dvdcss_error and processing of return
1 parent c2c8e19 commit ee51d12

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ up with the latest versions of other dependencies as well as crucial bug fixes.
2222
### Fixed
2323

2424
- Various CI and linting tooling mistakes and made it more efficient.
25+
- `DvdCss.error()` (which is now `DvdCss.error` property) is now defined correctly and
26+
now returns None or string values instead of a useless integer value.
2527

2628
### Changed
2729

pydvdcss/dvdcss.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,12 @@ def error(self) -> str | None:
381381
"""
382382
if self.handle is None:
383383
return None
384-
return self._library.dvdcss_error(self.handle).strip() or None
384+
385+
error = self._library.dvdcss_error(self.handle)
386+
if not error or error == b"no error":
387+
return None
388+
389+
return error.decode("utf8").strip() or None
385390

386391
@property
387392
def is_scrambled(self) -> bool:
@@ -417,21 +422,23 @@ def _load_library() -> CDLL:
417422
)
418423

419424
lib = CDLL(lib_name)
425+
dvdcss_t = c_void_p
426+
420427
lib.dvdcss_open.argtypes = [c_char_p]
421-
lib.dvdcss_open.restype = c_void_p
422-
lib.dvdcss_open_stream.argtypes = [c_void_p, DvdCssStreamCb]
423-
lib.dvdcss_open_stream.restype = c_void_p
424-
lib.dvdcss_close.argtypes = [c_void_p]
428+
lib.dvdcss_open.restype = dvdcss_t
429+
lib.dvdcss_open_stream.argtypes = [dvdcss_t, DvdCssStreamCb]
430+
lib.dvdcss_open_stream.restype = dvdcss_t
431+
lib.dvdcss_close.argtypes = [dvdcss_t]
425432
lib.dvdcss_close.restype = c_int
426-
lib.dvdcss_seek.argtypes = [c_void_p, c_int, c_int]
433+
lib.dvdcss_seek.argtypes = [dvdcss_t, c_int, c_int]
427434
lib.dvdcss_seek.restype = c_int
428-
lib.dvdcss_read.argtypes = [c_void_p, c_char_p, c_int, c_int]
435+
lib.dvdcss_read.argtypes = [dvdcss_t, c_char_p, c_int, c_int]
429436
lib.dvdcss_read.restype = c_int
430-
lib.dvdcss_readv.argtypes = [c_void_p, POINTER(Iovec), c_int, c_int]
437+
lib.dvdcss_readv.argtypes = [dvdcss_t, POINTER(Iovec), c_int, c_int]
431438
lib.dvdcss_readv.restype = c_int
432-
lib.dvdcss_error.argtypes = [c_void_p]
433-
lib.dvdcss_error.restype = c_int
434-
lib.dvdcss_is_scrambled.argtypes = [c_void_p]
439+
lib.dvdcss_error.argtypes = [dvdcss_t]
440+
lib.dvdcss_error.restype = c_char_p
441+
lib.dvdcss_is_scrambled.argtypes = [dvdcss_t]
435442
lib.dvdcss_is_scrambled.restype = c_int
436443

437444
return lib

0 commit comments

Comments
 (0)