~ubuntu-branches/ubuntu/edgy/gnupod-tools/edgy

« back to all changes in this revision

Viewing changes to src/tunes2pod.pl

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2005-09-17 14:41:08 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050917144108-fxrlryh8zv6bhv50
Tags: 0.98-3ubuntu1
src/ext/FooBar.pm, change call from gnupod_otgsync to gnupod_otgsync.pl

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
###__PERLBIN__###
1
2
#  Copyright (C) 2002-2004 Adrian Ulrich <pab at blinkenlights.ch>
2
3
#  Part of the gnupod-tools collection
3
4
#
29
30
 
30
31
use vars qw(%opts);
31
32
$| = 1;
32
 
print "tunes2pod.pl Version 0.94rc1 (C) 2002-2004 Adrian Ulrich\n";
 
33
 
 
34
 
 
35
print "tunes2pod.pl Version ###__VERSION__### (C) Adrian Ulrich\n";
33
36
 
34
37
$opts{mount} = $ENV{IPOD_MOUNTPOINT};
35
38
 
36
 
GetOptions(\%opts, "force", "help|h", "mount|m=s");
 
39
GetOptions(\%opts, "version", "force", "help|h", "mount|m=s");
 
40
GNUpod::FooBar::GetConfig(\%opts, {mount=>'s', force=>'b'}, "tunes2pod");
37
41
 
38
42
 
39
43
usage() if $opts{help};
 
44
version() if $opts{version};
 
45
 
 
46
 
40
47
 
41
48
#Normal operation
42
49
converter();
64
71
#Check where the FILES and PLAYLIST part starts..
65
72
#..and how many files are in this iTunesDB
66
73
my $itinfo = GNUpod::iTunesDB::get_starts();
 
74
 
 
75
if(!defined($itinfo)) {
 
76
  warn "File '$con->{itunesdb}' is not an iTunesDB, wrong magic in header!\n";
 
77
  exit(1);
 
78
}
 
79
 
67
80
#This 2 will change while running..
68
81
my $pos = $itinfo->{position};
69
82
my $pdi = $itinfo->{pdi};
110
123
  $href->{name} = "NONAME" unless($href->{name}); #Don't create an empty pl
111
124
  if(ref($href->{splpref}) eq "HASH" && ref($href->{spldata}) eq "ARRAY") { #SPL Data present
112
125
    print ">> Smart-Playlist '$href->{name}' found\n";
113
 
    render_spl($href->{name},$href->{splpref}, $href->{spldata}, $href->{matchrule}, $href->{content});
 
126
    render_spl($href->{name},$href->{splpref}, $href->{spldata}, $href->{matchrule},
 
127
               $href->{content}, $href->{plid});
114
128
  }
115
129
  else { #Normal playlist  
116
130
    print ">> Playlist '$href->{name}' with ".int(@{$href->{content}})." songs\n";
117
 
    GNUpod::XMLhelper::addpl($href->{name});
 
131
    GNUpod::XMLhelper::addpl($href->{name}, {plid=>$href->{plid}});
118
132
    foreach(@{$href->{content}}) {
119
133
     my $plfh = ();
120
134
     $plfh->{add}->{id} = $_;
128
142
 
129
143
 
130
144
 
131
 
GNUpod::XMLhelper::writexml($con->{xml});
 
145
GNUpod::XMLhelper::writexml($con);
132
146
GNUpod::FooBar::setsync_itunesdb($con);
 
147
GNUpod::FooBar::setvalid_otgdata($con);
133
148
 
134
149
#The iTunes is now set to clean .. maybe we have to
135
150
#update the otg..
145
160
#######################################################
146
161
# create a spl
147
162
sub render_spl {
148
 
 my($name, $pref, $data, $mr, $content) = @_;
 
163
 my($name, $pref, $data, $mr, $content, $plid) = @_;
149
164
 my $of = undef;
150
165
 $of->{liveupdate} = $pref->{live};
151
166
 $of->{moselected} = $pref->{mos};
154
169
 $of->{limitval}  = $pref->{value};
155
170
 $of->{limititem} = $pref->{iitem};
156
171
 $of->{checkrule} = $pref->{checkrule};
 
172
 $of->{plid}       = $plid;
157
173
#create this playlist
158
174
GNUpod::XMLhelper::addspl($name, $of);
159
175
 
176
192
$rtxt
177
193
Usage: tunes2pod.pl [-h] [-m directory]
178
194
 
179
 
   -h, --help             : This ;)
180
 
   -m, --mount=directory  : iPod mountpoint, default is \$IPOD_MOUNTPOINT
181
 
       --force            : Disable 'sync' checking
 
195
   -h, --help              display this help and exit
 
196
       --version           output version information and exit
 
197
   -m, --mount=directory   iPod mountpoint, default is \$IPOD_MOUNTPOINT
 
198
       --force             Disable 'sync' checking
 
199
 
 
200
Report bugs to <bug-gnupod\@nongnu.org>
 
201
EOF
 
202
}
 
203
 
 
204
sub version {
 
205
die << "EOF";
 
206
tunes2pod.pl (gnupod) ###__VERSION__###
 
207
Copyright (C) Adrian Ulrich 2002-2004
 
208
 
 
209
This is free software; see the source for copying conditions.  There is NO
 
210
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
182
211
 
183
212
EOF
184
213
}