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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Tue Mar 8 21:00:45 2005 UTC (19 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.2: +3 -2 lines
File MIME type: text/plain
minor fix: made $hostname configurable

1 joko 1.1 #!/usr/bin/perl
2    
3     ##################################################
4     #
5     # GiantDisc mp3 Jukebox Client
6     #
7     # 2005, Andreas Motl
8     #
9     ##################################################
10    
11    
12     # Client script talking to GiantDisc TCP port.
13     #
14 joko 1.2 # Purposes:
15     # - Trigger "Rip CD" from remote
16     # - Poll for "Rip Status"
17 joko 1.1
18     use strict;
19     use warnings;
20    
21 joko 1.2 use Data::Dumper;
22 joko 1.1 use gdclient;
23 joko 1.2
24     my $action = shift;
25 joko 1.3 my $hostname = 'siggi';
26 joko 1.2
27     sub usage {
28     print "Usage: gdc.pl ripcd|ripstatus", "\n";
29     }
30    
31     if (!$action) {
32     usage();
33     exit;
34     } elsif ($action eq 'ripcd') {
35     ripcd();
36     } elsif ($action eq 'ripstatus') {
37     ripstatus();
38     } else {
39     usage();
40     exit;
41     }
42    
43    
44     sub ripcd {
45 joko 1.3 gd_connect($hostname);
46 joko 1.2
47     # 1. check if cd is already in database (probably ripped?)
48     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 joko 1.3 gd_connect($hostname);
90 joko 1.2
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 joko 1.1
109     ###############################################################################

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