diff options
author | Christian Pointner <equinox@helsinki.at> | 2010-02-21 02:48:37 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2010-02-21 02:48:37 (GMT) |
commit | f3fc2edd61405ae40360258f9eb743342f05235a (patch) | |
tree | a5a57902c2bbd79a56650cfb3a7e393c4e99e46b /rhimport.pl | |
parent | ab461d0ca3c650a9c989ec3d0a53b21e32d93eae (diff) |
file name refactoring
Diffstat (limited to 'rhimport.pl')
-rwxr-xr-x | rhimport.pl | 164 |
1 files changed, 0 insertions, 164 deletions
diff --git a/rhimport.pl b/rhimport.pl deleted file mode 100755 index f477ee5..0000000 --- a/rhimport.pl +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/perl -w -# -# -# rhimport -# -# Copyright (C) 2009 Christian Pointner <equinox@helsinki.at> -# -# This file is part of rhimport. -# -# rhimport is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# rhimport is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with rhimport. If not, see <http://www.gnu.org/licenses/>. -# - -use strict; - -use rhimport_tools; - -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 $DROPBOX = ""; -my $LISTALLOWED = 0; - -GetOptions ("help!" => \$HELP, - "m3u=s" => \$M3U, - "dont-concat!" => \$DONTCONCAT, - "dropbox=s" => \$DROPBOX, - "list-allowed!" => \$LISTALLOWED, - ); - -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 - --list-allowed list allowed dropboxes and exit - -EOF - exit; -} - -my $CONCAT = 0; -$CONCAT = 1 unless $DONTCONCAT; -my $user = $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; -push @allowed_dbs, { 'GROUP' => "groupa", 'PATH' => "/programm/dropboxA/" }; -push @allowed_dbs, { 'GROUP' => "groupb", 'PATH' => "/programm/dropboxB/" }; -push @allowed_dbs, { 'GROUP' => "groupc", 'PATH' => "/programm/dropboxC/" }; -# 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 - -my $guixml; - -if(!$M3U && !$DROPBOX) { - Gtk2->init; - - $guixml = Gtk2::GladeXML->new('rhimport.glade'); - $guixml or die "can't load glade xml file"; - require gui_callbacks; - $guixml->signal_autoconnect_from_package('gui_callbacks'); - - my $model = Gtk2::ListStore->new('Glib::String'); - for my $href ( @allowed_dbs ) { - $model->set ($model->append, 0, $href->{'PATH'}); - } - my $co_dropbox = $guixml->get_widget('co_dropbox'); - $co_dropbox->set_model($model); - my $renderer = Gtk2::CellRendererText->new; - $co_dropbox->pack_start($renderer, 1); - $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->show; - - Gtk2->main; -# $dbh->disconnect(); - exit 0; -} - -sub start_import_gui() -{ - if(!$guixml) { - print STDERR "no GUI definition found!\n"; - exit 0; - } - - my $co_dropbox = $guixml->get_widget('co_dropbox'); - my $dropbox = $co_dropbox->get_active_text; - - my $filechooser = $guixml->get_widget('filechooser'); - my $m3u = $filechooser->get_filename; - - my $cb_concat = $guixml->get_widget('cb_concat'); - my $concat = 1; - $concat = 0 unless $cb_concat->get_active; - - rhimport::start_import($m3u, $dropbox, $concat); -} - -########################################### -## command line mode - -(-e "$M3U") or die "file '$M3U' not found"; -if($CONCAT) { - print "Will import $M3U (concatenated), with user $user\n\n"; -} else { - print "Will import $M3U (seperate files), with user $user\n\n"; -} - -my $ret = rhimport::start_import($M3U, $DROPBOX, $CONCAT); - -# $dbh->disconnect(); -exit $ret; |