Created
February 7, 2018 23:05
-
-
Save AJDurant/a91d520579f980d179f2d8578d1941fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $dir = "/music/records/"; | |
| $trackduration = array(); | |
| $db = pg_connect('<redacted>'); | |
| $result = pg_query($db, "SELECT trackid, recordid FROM rec_track WHERE duration is NULL AND digitised is TRUE"); | |
| while ($row = pg_fetch_assoc($result)) { | |
| print_r($row); | |
| $duration = exec('mp3info -p "%S" '.$dir.$row['recordid'].'/'.$row['trackid'].'.mp3'); | |
| print_r($duration); | |
| $update = pg_query($db, "UPDATE rec_track SET duration = '".$duration."' WHERE trackid = '".$row['trackid']."'"); | |
| if (!$update) { | |
| print "Update failed!!"; | |
| } | |
| else { | |
| print "Update successfull"; | |
| } | |
| $length = gmdate("H:i:s", $duration); | |
| print_r($length); | |
| print "\r\n"; | |
| $update = pg_query($db, "UPDATE rec_track SET length = '".$length."' WHERE trackid = '".$row['trackid']."'"); | |
| if (!$update) { | |
| print "Update failed!!"; | |
| } | |
| else { | |
| print "Update successfull"; | |
| } | |
| $trackduration[$row['trackid']] = array( | |
| 'original' => $row['length'], | |
| 'length' => $length, | |
| 'duration' => $duration); | |
| } | |
| print "\r\n"; | |
| print_r($trackduration); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment