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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Tue Mar 8 20:53:46 2005 UTC (19 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.1: +88 -29 lines
File MIME type: text/plain
preliminary working version

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 # Purposes:
15 # - Trigger "Rip CD" from remote
16 # - Poll for "Rip Status"
17
18 use strict;
19 use warnings;
20
21 use Data::Dumper;
22 use gdclient;
23
24 my $action = shift;
25
26 sub usage {
27 print "Usage: gdc.pl ripcd|ripstatus", "\n";
28 }
29
30 if (!$action) {
31 usage();
32 exit;
33 } elsif ($action eq 'ripcd') {
34 ripcd();
35 } elsif ($action eq 'ripstatus') {
36 ripstatus();
37 } else {
38 usage();
39 exit;
40 }
41
42
43 sub ripcd {
44 gd_connect("siggi");
45
46 # 1. check if cd is already in database (probably ripped?)
47 if (my $check_cd = gd_command("chcd", undef, 1)) {
48 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 ###############################################################################

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