Skip to main content

Python wrapper for VideoLAN's libdvdcss.

Project description

Banner


 

 

pydvdcss is a python wrapper for VideoLAN's libdvdcss

 

 

from pydvdcss.dvdcss import DvdCss

# ...

# choose device
dev = "/dev/sr0"

# use `with` to auto dispose once you leave the tree
# of course you can also just do `dvdcss = DvdCss()`
with DvdCss() as dvdcss:

  # open device
  dvdcss.open(dev)

  # check if dvd is scrambled
  if dvdcss.is_scrambled():
    print("The DVD is scrambled!")

  # read volume id from the ISO 9660 Volume Descriptor Set
  dvdcss.seek(16)       # seek to sector 16, the first 15 sectors are unused by ISO 9660
  dvdcss.read(1)        # read one sector amount of data
  data = dvdcss.buffer  # access the latest read data
  volume_label = data[40:72].strip().decode()
  print(f"{dev}: {volume_label}")
  # >> eg. `'/dev/sr0: THE_IT_CROWD_DISC_1'`

# make sure you dispose when your done if you didn't
# use `with`, otherwise stuff will get stuck in memory.
# usage of `with` on DvdCss automatically handles disposing.
# dvdcss.dispose()

 

 


 

 

libdvdcss is a simple library designed for accessing DVDs like a block device without having to bother about the decryption. pydvdcss exposes this library as a class taking care of the rest.

 

 

Pull requests welcome GPLv3 license PyPI version Python versions PyPI status Contributors GitHub issues Python version tests

Support me on ko-fi

 

 

Features

Portability

Anything that can run the supported python versions shown above is supported.

Simplicity

A DVD player can be built around the libdvdcss API using no more than 4 or 5 library calls.

Freedom

libdvdcss and this wrapper pydvdcss are released under the General Public License, ensuring it will stay free, and used only for free software products.

Just better

Unlike most similar projects, libdvdcss does not require the region of your drive to be set.

 

 

Installation

python -m pip install --user pydvdcss

or

git clone https://github.com/rlaPHOENiX/pydvdcss.git
cd pydvdcss
python -m pip install --user .

Note: with the second method you will need to handle updating yourself by re-cloning and installing it again.

 

 

To-do

  • Implement dvdcss_open
  • Implement dvdcss_close
  • Implement dvdcss_seek
  • Implement dvdcss_read
  • Implement dvdcss_error
  • Implement dvdcss_is_scrambled
  • Implement __enter__ and __exit__ for proper disposing
  • Add handlers for failed find_library calls
  • Add handlers for failed cdll calls
  • Add instructions for installing libdvdcss
  • Add and test support for Windows
  • Add and test support for Mac OS
  • Add and test support for Linux
  • Add function to set DVDCSS_VERBOSE
  • Add function to set DVDCSS_METHOD
  • Implement dvdcss_readv, not sure how this would be used or implemented

 

 

Functions

DvdCss.open(psz_target=[string])

Open a DVD device or directory and return a dvdcss instance.

Initialize the libdvdcss library and open the requested DVD device or directory. libdvdcss checks whether ioctls can be performed on the disc, and when possible, the disc key is retrieved.

open() returns a handle to be used for all subsequent libdvdcss calls. If an error occurred, NULL is returned.

  • psz_target: target name, e.g. "/dev/hdc" or "E:".

DvdCss.close()

Close the DVD and clean up the library.

Close the DVD device and free all the memory allocated by libdvdcss. On return, the dvdcss_t handle is invalidated and may not be used again.

DvdCss.seek(i_blocks=[int], i_flags=[int;NOFLAGS])

Seek in the disc and change the current key if requested.

This function seeks to the requested position, in logical blocks. Returns the new position in blocks, or a negative value in case an error happened.

Tips:

Use SEEK_MPEG flag when seeking throughout VOB data sectors. It isn't needed on the first sector.

Use SEEK_KEY flag the first time you enter a TITLE. You can always call it in VOB data sectors, however it will be unnecessary and cause slowdowns.

  • i_blocks: absolute block offset to seek to.
  • i_flags: NOFLAGS by default, or you can specify SEEK_KEY or SEEK_MPEG flags.

DvdCss.read(i_blocks=[int], i_flags=[int;NOFLAGS])

Read from the disc and decrypt data if requested.

This function reads i_blocks logical blocks from the DVD. Returns the amount of blocks read, or a negative value in case an error happened.

Tips:

Get the read contents from the buffer variable of DvdCss instance.

  • i_blocks: absolute block offset to seek to.
  • i_flags: NOFLAGS by default, or you can specify the READ_DECRYPT flag.

DvdCss.error()

Return a string containing the latest error that occurred in the given libdvdcss instance.

This function returns a constant string containing the latest error that occurred in libdvdcss. It can be used to format error messages at your convenience in your application.

Returns a null-terminated string containing the latest error message.

DvdCss.is_scrambled()

Check if the DVD is scrambled.

Returns True if it's scrambled.

 

 


 

 

PHOENiX

LICENSE (GPLv3)

CONTRIBUTORS

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydvdcss-1.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydvdcss-1.1.0-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file pydvdcss-1.1.0.tar.gz.

File metadata

  • Download URL: pydvdcss-1.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pydvdcss-1.1.0.tar.gz
Algorithm Hash digest
SHA256 783f3b5821fd6d0f1c90ea0a0f2f3650adea973f56fb66ce0142343b547496b2
MD5 0ae404a432a52ab91b9f22ce32ec1056
BLAKE2b-256 fb83afa6cefc2bb8f4dd4a0e726532ebbd687e2b0ebae1f179023d2047cf2d03

See more details on using hashes here.

File details

Details for the file pydvdcss-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pydvdcss-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pydvdcss-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb3cb17f9177c49de996119b4b1672cdecb02d55e75eec6d53cbcd8b420bb4c6
MD5 a841e1e8ef5569b3e1ca44ad11c129f2
BLAKE2b-256 2a51032054115477f1852aaceb1963e9a658203b17995abdf226d3361d66169c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page