AW: [mythtv] MythGame screenshots

Jochen Kühner jochen.kuehner at gmx.de
Fri Aug 5 04:23:24 EDT 2005


So here's Version 2 of my Example Script.

Extensions are now proved.
Could not Test anything at home, because my ati card's not working with my
current kernel!

So If anyone could test, if something happens

<?php
//   This is a Simple PHP Script to Generate Screenshots for the Rom's
//   in the New MythGame. It goes through all GamePlayers, Run's them with
//   all Roms and take a X Screenshot.
//
//  To Do:
//    * go through Subdirectorys
//    * Special Options for a Emulator (Example: If the Emu didn't use the
//                               whole SCreen, strip Image with ImageMagic)
//    * if %s Variable is set in GamePlayer then use it instead of adding
//      the romname to the back of the Player Name.
//    * Screenshots are currently named $romname.png
//              Example: Mario Kart.smc.png
//      I think that must be changed (or not ??))

//User defined Variables
$db_user = "root";
$db_pwd = "";
$scrot_path = "";
$pausetime = "5000000"; // (5000000 = 5 Seconds)

//This normaly had not to be changed
$db_name = "mythconverg";

//Here begins the Script

//Establish Database Connection
$conn_id = mysql_connect("localhost",$db_user,$db_pwd);
mysql_select_db($db_name,$conn_id);

//Read GamePlayers
$sql = "SELECT * FROM gameplayers;";
$result_gamep = mysql_query($sql);

//Do this for all GamePlayers
for ($j=0;$j<@mysql_num_rows($result_gamep);$j++)
{

    //Get Values
    $playername = mysql_result($result, $j, "playername");
    $workingpath = mysql_result($result, $j, "workingpath");
    $rompath = mysql_result($result, $j, "rompath");
    $commandline = mysql_result($result, $j, "commandline");
    $extensions = strtolower(mysql_result($result, $j, "extensions"));
    $screenshots = mysql_result($result, $j, "screenshots");

    //Is Screenshot Directory set??
    if ($screenshots != "")
    {
       //
       $directory = dir($rompath);
       while($file = $directory->read())
       {

          if ($file != "." && $file != "..")
          {
          
             //File Extension Exists in List or none defined
             $end = strtolower(substr($file,strlen($file)-3,3));

             $get_ext = strcspn($extensions, $end);

             if ($get_ext > 0 || $extensions == "")
             {
             
                //Emulator + Rom + & (Background Operator) + > /dev/null
(keine ausgabe)
                $command = trim($commandline)." ".$rompath.$file." & >
/dev/null";
                system($command);

                //Wait the Pausetime befor taking the Screenshot
                usleep($pausetime);
             
                //Take the SCreenshot
                $scrotcmd = $scrot_path + "scrot '".$file.".png' -e 'mv $f
".$screenshots."'";
                system($scrotcmd);
             
                //Kill the GamePlayer
                $killcmd = "killall -9 ".$commandline;
             
                //After this, wait half a Second, so that the emu is exited
                usleep(500000);

             }
          }
       }
    }
    else
    {
        echo "No Screenshot Directory set for Player: ".$playername.",
skipping\n";
    }
}
?>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: emulator_screenshots.php
Type: application/octet-stream
Size: 2931 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20050805/862ebc80/emulator_screenshots.obj


More information about the mythtv-dev mailing list