/[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.2 by joko, Tue Mar 8 20:53:46 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',  
26            'Open Your Eyes',  sub usage {
27            '',    print "Usage: gdc.pl ripcd|ripstatus", "\n";
28            '',  }
29            '',  
30            '',  if (!$action) {
31            '0',    usage();
32            '0',    exit;
33            '189',  } elsif ($action eq 'ripcd') {
34            '0',    ripcd();
35            '1e0c1f12',  } elsif ($action eq 'ripstatus') {
36            '1',    ripstatus();
37            '',  } else {
38            '0',    usage();
39            '0',    exit;
40            '',  }
41            '',  
42            'mp3 192'  
43          ];  sub ripcd {
44      gd_connect("siggi");
45      
46  gd_connect("siggi");    # 1. check if cd is already in database (probably ripped?)
47  gd_command("reccdt", @$payload);    if (my $check_cd = gd_command("chcd", undef, 1)) {
48  gd_disconnect();      print "-" x 60, "\n";
49        print "CD already ripped:", "\n", $check_cd, "\n";
50        print "-" x 60, "\n";
51      }
52      
53      # TODO: parse $check_cd and propagate cddb-id to "lcddi", if desired
54      
55      # 2. get cd information
56      my $cdinfo_raw = gd_command("lcddi", undef, 1);
57      my $cdinfo = lcddi_parse_response($cdinfo_raw);
58      #print Dumper($cdinfo);
59      #return;
60    
61      if (!$cdinfo->{'cddb_id'}) {
62        print "ERROR: CDDB id is undefined.", "\n";
63        print "Check if your database table 'album' contains an entry like: '-      -               NULL    NULL    2005-03-08      NULL'", "\n";
64        return;
65      }
66    
67      # 3. insert album information to database and rip cd
68      gd_command("cspcd");
69      #return;
70      
71      my $album_args = [ $cdinfo->{'artist'}, $cdinfo->{'album'}, $cdinfo->{'cddb_id'} ];
72      #print Dumper($album_args);
73      gd_command("repar", $album_args);
74      #return;
75    
76      foreach my $track_args (@{$cdinfo->{'tracks'}}) {
77        #print join(" ", @$track_args), "\n";
78        gd_command("reccdt", $track_args);
79      }
80      
81      print "Sent rip command to GiantDisc...", "\n";
82      print "Check job-status with 'gdc.pl ripstatus'.", "\n";
83      
84      gd_disconnect();
85    }
86    
87    sub ripstatus {
88      gd_connect("siggi");
89    
90      while (1) {
91        my $status_rip = gd_command("grpst", undef, 1);
92        print "-" x 40, "\n";
93        print "Rip Status:", "\n";
94        print $status_rip, "\n";
95        
96        print "-" x 40, "\n";
97        my $status_compress = gd_command("gcpst", undef, 1);
98        print "Compress Status:", "\n";
99        print $status_compress, "\n";
100        print "\n";
101        
102        sleep 5;
103      }
104      
105      gd_disconnect();
106    }
107    
108  ###############################################################################  ###############################################################################

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

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