Feb-09-2024, 05:48 AM
(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
Thanks Gribouillis! I don't know how I missed that variable. I was looking for a good bit through my logs. This is the code I ended up using just in case anymore needs it. Thanks again for all your guy's help on this one! I couldn't of figured it out without you all.
import pyudev def get_drive_type(drive_name="sr0"): context = pyudev.Context() a = context.list_devices(sys_name=drive_name) dev = next(iter(a)) # print(dev) # print(dict(dev.properties)) disc_type = None if dev.properties.get("ID_CDROM_MEDIA_CD", False): disc_type = "CD" elif dev.properties.get("ID_CDROM_MEDIA_DVD", False): disc_type = "DVD" elif dev.properties.get("ID_CDROM_MEDIA_BD", False): disc_type = "BLUERAY" print(f"Drive contains a: {disc_type} in Drive: {drive_name}") return disc_type if __name__ == "__main__": get_drive_type()