#!/usr/bin/perl -w # # use strict; use Getopt::Long; use DBI; use Gtk2; use Gtk2::GladeXML; my $DBHOST = "airplay"; my $DBUSER = "rivendellro"; my $DBPW = "lldrivenro"; my $DB = "rivendell"; my $HELP = 0; my $M3U = ""; my $DONTCONCAT = 0; my $LISTALLOWED = 0; GetOptions ("help!" => \$HELP, "m3u=s" => \$M3U, "dont-concat!" => \$DONTCONCAT, "list-allowed!" => \$LISTALLOWED, ); if($HELP) { print << "EOF"; usage: $0 --m3u --dont-concat options: --m3u the playlist file to import --dont-concat dont concat the audio files, import as seperate files --list-allowed list allowed dropboxes and exit EOF exit; } my $user = 'martinland';#$ENV{'USER'}; $user or die "Username not found in environment"; # my $dbh = DBI->connect( "DBI:mysql:$DB:$DBHOST","$DBUSER","$DBPW") or die "Database Error: $DBI::errstr"; # my $sql = qq{select USER_PERMS.GROUP_NAME,DROPBOXES.PATH from USER_PERMS, DROPBOXES where USER_PERMS.USER_NAME='$user' and DROPBOXES.GROUP_NAME=USER_PERMS.GROUP_NAME;}; # my $sth = $dbh->prepare($sql); # $sth->execute(); my @allowed_dbs; # while(my ($group, $path) = $sth->fetchrow_array()) { # $path =~ s/\/\*$//; # my $perm = {}; # $perm->{'GROUP'} = $group; # $perm->{'PATH'} = $path; # push @allowed_dbs, $perm; # } # $sth->finish(); if($LISTALLOWED) { for my $href ( @allowed_dbs ) { print "$href->{'PATH'}\n"; } # $dbh->disconnect(); exit 0; } ## GUI mode if(!$M3U) { Gtk2->init; my $guixml = Gtk2::GladeXML->new('rhimport.glade'); $guixml or die "can't load glade xml file"; my $appwin = $guixml->get_widget('appwin'); $appwin or die "can't find Main Window"; $appwin->show; Gtk2->main; # $dbh->disconnect(); exit 0; } ## command line mode (-e "$M3U") or die "file '$M3U' not found"; if($DONTCONCAT) { print "Will import $M3U (seperate files), with user $user\n\n"; } else { print "Will import $M3U (concatenated), with user $user\n\n"; } # $dbh->disconnect(); exit 0;