summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rhimport.glade150
-rwxr-xr-xrhimport.pl56
2 files changed, 192 insertions, 14 deletions
diff --git a/rhimport.glade b/rhimport.glade
new file mode 100644
index 0000000..5743022
--- /dev/null
+++ b/rhimport.glade
@@ -0,0 +1,150 @@
+<?xml version="1.0"?>
+<glade-interface>
+ <!-- interface-requires gtk+ 2.16 -->
+ <!-- interface-naming-policy project-wide -->
+ <widget class="GtkWindow" id="appwin">
+ <property name="title" translatable="yes">rhimport</property>
+ <child>
+ <widget class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <widget class="GtkAlignment" id="alignment">
+ <property name="visible">True</property>
+ <property name="top_padding">5</property>
+ <property name="bottom_padding">5</property>
+ <property name="left_padding">5</property>
+ <property name="right_padding">5</property>
+ <child>
+ <widget class="GtkVBox" id="vbox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">4</property>
+ <child>
+ <widget class="GtkLabel" id="label_dropbox">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;b&gt;Dropbox&lt;/b&gt;</property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="co_dropbox">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label_playlist">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;b&gt;Playlist&lt;/b&gt;</property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkFileChooserWidget" id="filechooserwidget">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ </widget>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="cb_concat">
+ <property name="label" translatable="yes">Musikdateien zusammenf&#xFC;gen</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="xalign">0.46000000834465027</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkProgressBar" id="progressbar">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkLabel" id="l_status">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="b_cancel">
+ <property name="label">gtk-cancel</property>
+ <property name="width_request">120</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="b_ok">
+ <property name="label">gtk-ok</property>
+ <property name="width_request">120</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">6</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label_main">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;b&gt;rhimport - Radio Helsinki Importtool&lt;/b&gt;</property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
diff --git a/rhimport.pl b/rhimport.pl
index a8b1c0a..8f8a4ed 100755
--- a/rhimport.pl
+++ b/rhimport.pl
@@ -6,6 +6,8 @@ use strict;
use Getopt::Long;
use DBI;
+use Gtk2 -init;
+use Gtk2::GladeXML;
my $DBHOST = "airplay";
my $DBUSER = "rivendellro";
@@ -14,46 +16,72 @@ 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 || !$M3U) {
+if($HELP) {
print << "EOF";
usage: $0 --m3u <playlist file> --dont-concat
options:
- --m3u the playlist file to import
- --dont-concat dont concat the audio files, import as seperate files
+ --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;
}
-(-e "$M3U") or die "file '$M3U' not found";
-
-my $user = $ENV{'USER'};
-
+my $user = 'martinland';#$ENV{'USER'};
$user or die "Username not found in environment";
-print "Will import $M3U, with user $user\n";
-
-
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 $cur_start_time = "out of order";
-my $cart_cnt = 0;
+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();
- print "GROUP: $group, PATH: $path\n"
+
+if($LISTALLOWED) {
+ for my $href ( @allowed_dbs ) {
+ print "$href->{'PATH'}\n";
+ }
+ $dbh->disconnect();
+ exit 0;
+}
+
+## GUI mode
+
+if(!$M3U) {
+ my $gui = Gtk2::GladeXML->new('rhimport.glade');
+
+ Gtk2->main;
+ 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";
}
-$sth->finish();
$dbh->disconnect();
+exit 0;