Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dir = `ls -1 *.mkv`;
- $files = split("\n",$dir);
- foreach ($files as $file) {
- if (strlen($file) <= 0) {
- continue;
- }
- echo "Processing ".$file."...\n";
- $sample = `mkvinfo "$file"`;
- $tracks = preg_split("/\| \+ A track/",$sample);
- foreach ($tracks as $track) {
- $tag = "| + Track number: ";
- $meh = strpos($track,$tag);
- if ($meh <= 0) {
- continue;
- }
- $meh = $meh + strlen($tag);
- $meh2 = strpos($track,"\n",$meh);
- $trackno = substr($track,$meh,($meh2 - $meh));
- $tag = "| + Enabled: ";
- $meh = strpos($track,$tag);
- if ($meh <= 0) {
- continue;
- }
- $meh = $meh + strlen($tag);
- $meh2 = strpos($track,"\n",$meh);
- $enabled = substr($track,$meh,($meh2 - $meh));
- $tag = "| + Default flag: ";
- $meh = strpos($track,$tag);
- if ($meh <= 0) {
- continue;
- }
- $meh = $meh + strlen($tag);
- $meh2 = strpos($track,"\n",$meh);
- $def = substr($track,$meh,($meh2 - $meh));
- $tag = "| + Language: ";
- $meh = strpos($track,$tag);
- if ($meh <= 0) {
- continue;
- }
- $meh = $meh + strlen($tag);
- $meh2 = strpos($track,"\n",$meh);
- $lang = substr($track,$meh,($meh2 - $meh));
- // echo "Track Number: ".$trackno."\n";
- // echo "Enabled: ".$enabled."\n";
- // echo "Default: ".$def."\n";
- // echo "Language: ".$lang."\n";
- if ($enabled) {
- if ($lang == "eng" && !$def) {
- $cmd = 'mkvpropedit "'.$file.'" -e track:'.$trackno.' -s flag-default=1';
- exec($cmd);
- echo "Track ".$trackno." is ".$lang.". Set Default.\n";
- }
- if ($lang == "ger" && $def) {
- $cmd = 'mkvpropedit "'.$file.'" -e track:'.$trackno.' -s flag-default=0';
- exec($cmd);
- echo "Track ".$trackno." is ".$lang.". Set not default.\n";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement