Skip to content

Instantly share code, notes, and snippets.

@EncodeTheCode
Last active May 1, 2023 04:06
Show Gist options
  • Save EncodeTheCode/483fcc6c135e616a4c3d9a10ea53ebb1 to your computer and use it in GitHub Desktop.
Save EncodeTheCode/483fcc6c135e616a4c3d9a10ea53ebb1 to your computer and use it in GitHub Desktop.
import pycdlib
# Open the CD/DVD drive
try:
cd = pycdlib.PyCdlib()
cd.open('/dev/cdrom')
except IOError:
print('No CD/DVD in tray.')
exit()
# Get the disc information
disc_info = cd.get_disc_info()
# Print the disc properties to the console and file
with open('disc_info.txt','w') as f:
for key, value in disc_info.items():
f.write(key+': '+str(value)+'\n')
print(key+':',value)
# Close the CD/DVD drive
cd.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment