/[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.3 by joko, Tue Mar 8 21:00:45 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();    if (my $check_cd = gd_command("chcd", undef, 1)) {
49        print "-" x 60, "\n";
50        print "CD already ripped:", "\n", $check_cd, "\n";
51        print "-" x 60, "\n";
52      }
53      
54      # TODO: parse $check_cd and propagate cddb-id to "lcddi", if desired
55      
56      # 2. get cd information
57      my $cdinfo_raw = gd_command("lcddi", undef, 1);
58      my $cdinfo = lcddi_parse_response($cdinfo_raw);
59      #print Dumper($cdinfo);
60      #return;
61    
62      if (!$cdinfo->{'cddb_id'}) {
63        print "ERROR: CDDB id is undefined.", "\n";
64        print "Check if your database table 'album' contains an entry like: '-      -               NULL    NULL    2005-03-08      NULL'", "\n";
65        return;
66      }
67    
68      # 3. insert album information to database and rip cd
69      gd_command("cspcd");
70      #return;
71      
72      my $album_args = [ $cdinfo->{'artist'}, $cdinfo->{'album'}, $cdinfo->{'cddb_id'} ];
73      #print Dumper($album_args);
74      gd_command("repar", $album_args);
75      #return;
76    
77      foreach my $track_args (@{$cdinfo->{'tracks'}}) {
78        #print join(" ", @$track_args), "\n";
79        gd_command("reccdt", $track_args);
80      }
81      
82      print "Sent rip command to GiantDisc...", "\n";
83      print "Check job-status with 'gdc.pl ripstatus'.", "\n";
84      
85      gd_disconnect();
86    }
87    
88    sub ripstatus {
89      gd_connect($hostname);
90    
91      while (1) {
92        my $status_rip = gd_command("grpst", undef, 1);
93        print "-" x 40, "\n";
94        print "Rip Status:", "\n";
95        print $status_rip, "\n";
96        
97        print "-" x 40, "\n";
98        my $status_compress = gd_command("gcpst", undef, 1);
99        print "Compress Status:", "\n";
100        print $status_compress, "\n";
101        print "\n";
102        
103        sleep 5;
104      }
105      
106      gd_disconnect();
107    }
108    
109  ###############################################################################  ###############################################################################

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

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