/usr/bin/mktunes is in gnupod-tools 0.99.8-2.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | #!/usr/bin/perl
# Copyright (C) 2002-2007 Adrian Ulrich <pab at blinkenlights.ch>
# Part of the gnupod-tools collection
#
# URL: http://www.gnu.org/software/gnupod/
#
# GNUpod 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
# (at your option) any later version.
#
# GNUpod 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 this program. If not, see <http://www.gnu.org/licenses/>.#
#
# iTunes and iPod are trademarks of Apple
#
# This product is not supported/written/published by Apple!
use strict;
use GNUpod::XMLhelper;
use GNUpod::FooBar;
use GNUpod::Mktunes;
use GNUpod::Hash58;
use GNUpod::SysInfo;
use GNUpod::ArtworkDB;
use Getopt::Long;
$| = 1;
my $mktunes = undef;
my %opts = ();
print "mktunes 0.99.8 (C) Adrian Ulrich\n";
$opts{mount} = $ENV{IPOD_MOUNTPOINT};
GetOptions(\%opts, "version", "help|h", "ipod-name|n=s", "mount|m=s", "volume|v=i", "energy|e", "fwguid|g=s");
GNUpod::FooBar::GetConfig(\%opts, {'ipod-name'=>'s', mount=>'s', volume=>'i', energy=>'b', fwguid=>'s', model=>'s'}, "mktunes");
$opts{'ipod-name'} ||= "GNUpod 0.99.8";
usage() if $opts{help};
version() if $opts{version};
main();
#########################################################################
# main() :-)
sub main {
my $con = GNUpod::FooBar::connect(\%opts);
usage("$con->{status}\n") if $con->{status};
my $sysinfo = GNUpod::SysInfo::GetDeviceInformation(Connection=>$con, NoDeviceSearch=>(defined($opts{fwguid}) ? 1 : 0 ) );
my $fwguid = (defined($opts{fwguid}) ? $opts{fwguid} : $sysinfo->{FirewireGuid}); # Always prefer fwguid. may be 0 to disable search
print "> Loading ArtworkDB...";
my $AWDB = GNUpod::ArtworkDB->new(Connection=>$con, DropUnseen=>0);
$AWDB->LoadArtworkDb;
print "done\n";
$mktunes = GNUpod::Mktunes->new(Connection=>$con, iPodName=>$opts{'ipod-name'}, Artwork=>$AWDB);
print "> Parsing XML document...\n";
GNUpod::XMLhelper::doxml($con->{xml}) or usage("Could not read $con->{xml}, did you run gnupod_INIT ?");
print "\r> ".$mktunes->GetFileCount." files parsed, assembling iTunesDB...\n";
$mktunes->WriteItunesDB;
if($fwguid) {
my $k = GNUpod::Hash58::HashItunesDB(FirewireId=>$fwguid, iTunesDB=>$con->{itunesdb});
}
else {
print "> iPod-GUID not detected. You can force the GUID using --fwguid\n";
}
print "> Writing new iTunesShuffle DB\n";
$mktunes->WriteItunesSD;
print "> Updating Sync-Status\n";
GNUpod::FooBar::SetItunesDBAsInSync($con); # iTunesDB is in sync with GNUtunesDB.xml
GNUpod::FooBar::SetOnTheGoAsValid($con); # ..and we can now, again, trust OnTheGo data
GNUpod::FooBar::WipeShuffleStat($con); # Forces reshuffling of iPod-Shuffle
print "\nYou can now umount your iPod. [Files: ".$mktunes->GetFileCount."]\n";
print " - May the iPod be with you!\n\n";
}
#########################################################################
# Called by doxml if it finds a new <file tag
sub newfile {
my($item) = @_;
if($opts{energy}) {
# Crop title if requested. Note: Cropping it here affects regexps!
# But ... this had only a visible effect on 1st-gen ipods
# and didn't work well with iTunes anyway..
$item->{file}->{title} = Unicode::String::utf8($item->{file}->{title})->substr(0,18)->utf8;
}
#Volume adjust
if($opts{volume}) {
$item->{file}->{volume} += int($opts{volume});
if(abs($item->{file}->{volume}) > 100) {
print "\n** Warning: volume=\"$item->{file}->{volume}\" out of range: Volume set to ";
$item->{file}->{volume} = ($item->{file}->{volume}/abs($item->{file}->{volume})*100);
print "$item->{file}->{volume}% for id $item->{file}->{id}\n";
}
}
my $id = $mktunes->AddFile($item->{file});
print "\r> $id files parsed" if $id % 96 == 0;
}
#########################################################################
# Called by doxml if it a new <playlist.. has been found
sub newpl {
my($item, $name, $type) = @_;
if($type eq "pl") {
$mktunes->AddNormalPlaylistItem(Name=>$name, Item=>$item);
}
elsif($type eq "spl") {
$mktunes->AddSmartPlaylistItem(Name=>$name, Item=>$item);
}
else {
warn "$0: unknown playlist type '$type' skipped\n";
}
}
#########################################################################
# Usage information
sub usage {
my($rtxt) = @_;
die << "EOF";
$rtxt
Usage: mktunes [-h] [-m directory] [-v VALUE]
-h, --help display this help and exit
--version output version information and exit
-m, --mount=directory iPod mountpoint, default is \$IPOD_MOUNTPOINT
-n, --ipod-name=NAME iPod Name (For unlabeled iPods)
-v, --volume=VALUE Adjust volume +-VALUE% (example: -v -20)
(Works with Firmware 1.x and 2.x!)
-e, --energy Save energy (= Disable scrolling title)
-g, --fwguid=HEXVAL FirewireGuid / Serial of connected iPod:
Report bugs to <bug-gnupod\@nongnu.org>
EOF
}
#########################################################################
# Displays current version
sub version {
die << "EOF";
mktunes (gnupod) 0.99.8
Copyright (C) Adrian Ulrich 2002-2007
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
EOF
}
|