/[cvs]/nfo/perl/scripts/giantdisc/bin/gdc.pl
ViewVC logotype

Diff of /nfo/perl/scripts/giantdisc/bin/gdc.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Tue Mar 8 16:00:57 2005 UTC revision 1.5 by joko, Tue Mar 8 21:39:23 2005 UTC
# Line 11  Line 11 
11    
12  # Client script talking to GiantDisc TCP port.  # Client script talking to GiantDisc TCP port.
13  #  #
14  # Purpose: Trigger "Rip CD" from remote  # Purposes:
15    #   - Trigger "Rip CD" from remote
16    #   - Poll for "Rip Status"
17    
18  use strict;  use strict;
19  use warnings;  use warnings;
20    
21  use Data::Dumper;  use Data::Dumper;
22  use gdclient;  use gdclient;
23    
24  my $payload = [  my $action = shift;
25            'Guano Apes',  my $hostname = 'siggi';
26            'Open Your Eyes',  
27            '',  sub usage {
28            '',    print "Usage: gdc.pl ripcd|ripstatus", "\n";
29            '',  }
30            '',  
31            '0',  if (!$action) {
32            '0',    usage();
33            '189',    exit;
34            '0',  } elsif ($action eq 'ripcd') {
35            '1e0c1f12',    ripcd();
36            '1',  } elsif ($action eq 'ripstatus') {
37            '',    ripstatus();
38            '0',  } else {
39            '0',    usage();
40            '',    exit;
41            '',  }
42            'mp3 192'  
43          ];  
44    sub ripcd {
45      gd_connect($hostname);
46  gd_connect("siggi");    
47  gd_command("reccdt", @$payload);    # 1. check if cd is already in database (probably ripped?)
48  gd_disconnect();    print "-" x 60, "\n";
49      print "Check CD: ";
50      my $check_cd;
51      if ($check_cd = gd_command("chcd", undef, 1)) {
52        print "CD already ripped!";
53      }
54      print "\n";
55      print $check_cd, "\n";
56      print "-" x 60, "\n";
57      
58      # TODO: parse $check_cd and propagate cddb-id to "lcddi", if desired
59      
60      # 2. get cd information
61      my $cdinfo_raw = gd_command("lcddi", undef, 1);
62      my $cdinfo = lcddi_parse_response($cdinfo_raw);
63      #print Dumper($cdinfo);
64      #return;
65    
66      if (!$cdinfo->{'cddb_id'}) {
67        print "ERROR: CDDB id is undefined.", "\n";
68        print "Check if your database table 'album' contains an entry like: '-      -               NULL    NULL    2005-03-08      NULL'", "\n";
69        return;
70      }
71    
72      # 3. insert album information to database and rip cd
73      gd_command("cspcd");
74      #return;
75      
76      my $album_args = [ $cdinfo->{'artist'}, $cdinfo->{'album'}, $cdinfo->{'cddb_id'} ];
77      #print Dumper($album_args);
78      gd_command("repar", $album_args);
79      #return;
80    
81      foreach my $track_args (@{$cdinfo->{'tracks'}}) {
82        #print join(" ", @$track_args), "\n";
83        gd_command("reccdt", $track_args);
84      }
85      
86      print "Sent rip command to GiantDisc...", "\n";
87      print "Check job-status with 'gdc.pl ripstatus'.", "\n";
88      
89      gd_disconnect();
90    }
91    
92    sub ripstatus {
93      gd_connect($hostname);
94    
95      while (1) {
96        my $status_rip = gd_command("grpst", undef, 1);
97        print "-" x 40, "\n";
98        print "Rip Status:", "\n";
99        print $status_rip ? $status_rip : 'No ripping process running.', "\n";
100        
101        print "-" x 40, "\n";
102        my $status_compress = gd_command("gcpst", undef, 1);
103        print "Compress Status:", "\n";
104        print $status_compress ? $status_compress : 'No compress process running.', "\n";
105        print "\n";
106        
107        sleep 5;
108      }
109      
110      gd_disconnect();
111    }
112    
113  ###############################################################################  ###############################################################################

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.5

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed