Feb-07-2024, 01:32 PM
(This post was last modified: Feb-07-2024, 01:32 PM by Gribouillis.)
(Feb-07-2024, 03:34 AM)Daring_T Wrote: I am not seeing a way to see the disc's type.I had some success on my linux computer with the command
Output:udevadm info -q property /dev/cdrom
When a DVD is inserted, the output contains a lineOutput:ID_CDROM_MEDIA_DVD=1
When a CD is inserted, or an audio CD, there is a lineOutput:ID_CDROM_MEDIA_CD=1
When there is nothing in the CD drive, there is no ID_CDROM_MEDIA...
line in the output. I don't have a blue ray disk to see what it does.EDIT: after some tests, I was able to get the information with pyudev
import pyudev def main(): context = pyudev.Context() a = context.list_devices(sys_name="sr0") dev = next(iter(a)) # print(dev) # print(dict(dev.properties)) if dev.properties.get("ID_CDROM_MEDIA_CD", False): print("CD drive contains a CD") elif dev.properties.get("ID_CDROM_MEDIA_DVD", False): print("CD drive contains a DVD") if __name__ == "__main__": main()
Output:λ python paillasse/pf/cdrom.py
CD drive contains a DVD
It seems that for blue ray, the property is ID_CDROM_MEDIA_BD
« We can solve any problem by introducing an extra level of indirection »