summaryrefslogtreecommitdiff
path: root/rhimport
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport')
-rwxr-xr-xrhimport82
1 files changed, 53 insertions, 29 deletions
diff --git a/rhimport b/rhimport
index 94b367e..82823f6 100755
--- a/rhimport
+++ b/rhimport
@@ -36,25 +36,25 @@ my $DBUSER = "rivendellro";
my $DBPW = "lldrivenro";
my $DB = "rivendell";
my $HELP = 0;
-my $M3U = "";
-my $DONTCONCAT = 0;
+my $FILE = "";
+my $POOL = 0;
my $DROPBOX = "";
my $LISTALLOWED = 0;
GetOptions ("help!" => \$HELP,
- "m3u=s" => \$M3U,
- "dont-concat!" => \$DONTCONCAT,
+ "file=s" => \$FILE,
+ "pool!" => \$POOL,
"dropbox=s" => \$DROPBOX,
"list-allowed!" => \$LISTALLOWED,
);
if($HELP) {
print << "EOF";
-usage: $0 --m3u <playlist file> --dont-concat
+usage: $0 --file <audio or playlist file> --pool --dropbox <path to dropbox> --list-allowed
options:
- --m3u the playlist file to import
- --dont-concat dont concat the audio files, import as seperate files
+ --file the media file or playlist to import
+ --pool pool mode, import media files referneced by playlist
--dropbox the path to the dropbox to use
--list-allowed list allowed dropboxes and exit
@@ -62,8 +62,6 @@ EOF
exit;
}
-my $CONCAT = 0;
-$CONCAT = 1 unless $DONTCONCAT;
my $user = $ENV{'USER'};
$user or die "Username not found in environment";
@@ -97,7 +95,7 @@ if($LISTALLOWED) {
my $guixml;
-if(!$M3U && !$DROPBOX) {
+if(!$FILE && !$DROPBOX) {
Gtk2->init;
$guixml = Gtk2::GladeXML->new('rhimport.glade');
@@ -116,11 +114,6 @@ if(!$M3U && !$DROPBOX) {
$co_dropbox->add_attribute($renderer, text => 0);
$co_dropbox->set_active(0);
- my $filter = Gtk2::FileFilter->new;
- $filter->add_pattern("*.m3u");
- my $filechooser = $guixml->get_widget('filechooser');
- $filechooser->set_filter($filter);
-
my $appwin = $guixml->get_widget('appwin');
$appwin or die "can't find Main Window";
$appwin->resize(800,600);
@@ -131,6 +124,30 @@ if(!$M3U && !$DROPBOX) {
exit 0;
}
+sub change_pool_gui()
+{
+ if(!$guixml) {
+ print STDERR "no GUI definition found!\n";
+ exit 0;
+ }
+
+ my $l_file_playlist = $guixml->get_widget('l_file_playlist');
+ my $filechooser = $guixml->get_widget('filechooser');
+
+ my $cb_pool = $guixml->get_widget('cb_pool');
+ if($cb_pool->get_active) {
+ $l_file_playlist->set_label("<b>Playlist</b>");
+ my $filter = Gtk2::FileFilter->new;
+ $filter->add_pattern("*.m3u");
+ $filechooser->set_filter($filter);
+ } else {
+ $l_file_playlist->set_label("<b>File</b>");
+ my $filter = Gtk2::FileFilter->new;
+ $filter->add_pattern("*");
+ $filechooser->set_filter($filter);
+ }
+}
+
sub start_import_gui()
{
if(!$guixml) {
@@ -141,8 +158,8 @@ sub start_import_gui()
my $l_status = $guixml->get_widget('l_status');
my $filechooser = $guixml->get_widget('filechooser');
- my $m3u = $filechooser->get_filename;
- if(!$m3u || -d $m3u) {
+ my $file = $filechooser->get_filename;
+ if(!$file || -d $file) {
$l_status->set_label("No Playlist selected!");
return 0;
}
@@ -151,28 +168,35 @@ sub start_import_gui()
my $co_dropbox = $guixml->get_widget('co_dropbox');
my $dropbox = $co_dropbox->get_active_text;
- my $cb_concat = $guixml->get_widget('cb_concat');
- my $concat = 1;
- $concat = 0 unless $cb_concat->get_active;
+ $l_status->set_label("importing from $file");
- $l_status->set_label("importing from $m3u");
-
- rhimport::start_import($m3u, $dropbox, $concat);
+ my $cb_pool = $guixml->get_widget('cb_pool');
+ my $ret;
+ if($cb_pool->get_active) {
+ $ret = rhimport::import_playlist($file, $dropbox);
+ } else {
+ $ret = rhimport::import_file($file, $dropbox);
+ }
- return 0;
+ return $ret;
}
###########################################
## command line mode
-(-e "$M3U") or die "file '$M3U' not found";
-if($CONCAT) {
- print "Will import $M3U (concatenated), with user $user\n\n";
+(-e "$FILE") or die "file '$FILE' not found";
+if($POOL) {
+ print "Will import from playlist $FILE, with user $user\n\n";
} else {
- print "Will import $M3U (seperate files), with user $user\n\n";
+ print "Will import $FILE, with user $user\n\n";
}
-my $ret = rhimport::start_import($M3U, $DROPBOX, $CONCAT);
+my $ret;
+if($POOL) {
+ $ret = rhimport::import_playlist($FILE, $DROPBOX);
+} else {
+ $ret = rhimport::import_file($FILE, $DROPBOX);
+}
# $dbh->disconnect();
exit $ret;