
proc ::mpg::ts {ts} {
	set file [file rootname [$ts get file]]

	if {[file exists $file.mpg]} {
		# Already done.
		return
	}

	if {[$ts get definition] eq "HD"} {
		# Cannot extract a useful MP3 from a HD recording.
		::auto::log "  $file - High definition." 2
		return
	}

	if {[queue check $ts mpg]} {
		::auto::log "  $file - Already queued." 2
		return
	}

	if {[::auto::inuse $ts]} {
		::auto::log "  $file - In use." 2
		return
	}

	# Enqueue file
	queue insert $ts mpg
	::auto::log "  $file - Queued for mpg." 0
}

proc ::mpg::directory {dir} {
	::auto::direntries $dir ::mpg::ts
}

proc ::mpg::rundir {dir} {
	::auto::flagscan $dir mpg ::mpg::directory 0
}

proc ::mpg::run {} {
	::auto::flagscan $::auto::root mpg ::mpg::directory
}

::auto::register mpg 300

