Feb-11-2024, 07:39 AM
(This post was last modified: Feb-11-2024, 07:39 AM by Daring_T.
Edit Reason: I updated my script
)
(Feb-08-2024, 06:35 AM)Gribouillis Wrote:(Feb-08-2024, 05:56 AM)Daring_T Wrote: Also here is what a blue-ray looks like with running dict(dev.properties):The propertyID_CDROM_MEDIA_BD
tells you that there is a blueray disk
If anyone needs it, I have also added support for CD-ROMS as shown below.
def get_drive_type(drive_name="sr0"): '''Returns the type of Disc in Drive''' context = pyudev.Context() a = context.list_devices(sys_name=drive_name) dev = next(iter(a)) disc_type = None if dev.properties.get("ID_CDROM_MEDIA_CD", False): if dev.properties.get('ID_FS_USAGE', False): disc_type = "CDROM" else: disc_type = "CDAUDIO" elif dev.properties.get("ID_CDROM_MEDIA_DVD", False): disc_type = "DVD" elif dev.properties.get("ID_CDROM_MEDIA_BD", False): disc_type = "BLUERAY" return disc_type if __name__ == "__main__": disc_type = get_drive_type(drive_name="sr0") print(f"Drive: {drive_name} contains a: {disc_type}.")