You are not logged in.
Is there a scriptable/cli way to determine optical media/content (ie: cd data, cd audio, dvd data, dvd audio, etc) that doesn't involve the now deprecated hal? Not at all interested in a graphical solution, nor one that involves hal as I already know how to do that. I'm just wondering if there's another way, because I've probed around and can't seem to find anything.
I intend to use it to make my cd auto-ripper a bit smarter.
"I refuse to be part of a society that encourages the rampant abuse of its own language." ~ BM
Offline
Mr Green
Offline
You may look into the udevadm info command or udisks --show-info
See the manual for details.
Offline
You may look into the udevadm info command or udisks --show-info
See the manual for details.
It doesn't offer much(no real way to detect if its a video dvd), and it really isn't all that pretty(not as elegant as hal), but it will work for some things, and that helps a lot Thank you.
#!/usr/bin/python2
#isaudiocd.py
from subprocess import check_output, CalledProcessError
import sys
if not len(sys.argv) > 1:
print('You must supply a device argument to check - ie: /dev/sr0')
sys.exit(2)
try:
command = "udisks --show-info %s" % sys.argv[1]
output = check_output(command, shell=True).decode('utf-8').strip().split('\n')
audio_line = ''
for line in output:
if line.find('num audio tracks') > -1:
audio_line = line
break
if audio_line == '':
sys.exit(2)
answer = audio_line.split(':')[1].strip()
if answer == 1:
sys.exit(0)
else:
sys.exit(1)
except CalledProcessError:
sys.exit(2)
"I refuse to be part of a society that encourages the rampant abuse of its own language." ~ BM
Offline
You can also get the media type of an optical disc.
It's in the drive: part of the output of udisks --shows-info, the line beginning with media:.
For a live CD, I get :
media: optical_cd_r
For a DVD :
media: optical_dvd
But using only that command, I don't see a way to know the content of the DVD, data or video. Maybe the filesystem type, but I am not sure about that.
Offline
I haven't figured out the DVD one yet, as it's not the real priority of mine, but I have figured out a better way for dealing with the audio disks.
ACTION=="remove", GOTO="cdrom_end"
SUBSYSTEM!="block", GOTO="cdrom_end"
KERNEL!="sr[0-9]*|xvd*", GOTO="cdrom_end"
ENV{DEVTYPE}!="disk", GOTO="cdrom_end"
KERNEL=="sr[0-9]*", ENV{ID_CDROM}="1"
IMPORT{program}="/lib/udev/cdrom_id --export %k"
ACTION=="change", ENV{ID_CDROM_MEDIA_TRACK_COUNT_AUDIO}!="", RUN+="/bin/su - blackwaltz -c '/home/blackwaltz/bin/autorip.sh $env{DEVNAME}'"
LABEL="cdrom_end"
"I refuse to be part of a society that encourages the rampant abuse of its own language." ~ BM
Offline