On 6/19/09 11:07 AM, H. Langos wrote:
Maybe the merge code should only be active if your memory saving feature is
active?
Here is the new patch that does just that. I love git, it's super fast. :-)
Cheers,
Richard
diff --git a/doc/gnupodrc.example b/doc/gnupodrc.example
index e290224..27b6bc0 100644
--- a/doc/gnupodrc.example
+++ b/doc/gnupodrc.example
@@ -33,24 +33,38 @@
# NON GLOBAL OPTIONS ##
# *** mktunes.pl ***
+
## Specify the iPods name
# mktunes.ipod-name = Wurstli
+## Set --volume boost to +10 percent
+# mktunes.volume = +10
+
+## Enforce iPod serial number:
+# mktunes.fwguid = 000ba3100310abcf
+
+## Only keep some attributes to make the iTunesDB fit inside small RAM
+## The minimum attributes needed by the iPod are path and title
+## Valid attributes are:
+## title path album artist genre fdesc eq comment category composer group
+## desc podcastguid podcastrss chapterdata subtitle tvshow tvepisode
+## tvnetwork albumartist artistthe keywords sorttitle sortalbum
+## sortalbumartist sortcomposer sorttvshow
+# low_ram_attr = path title artist album
# *** on the go sync (V2 Firmware) ***
+
## Uncomment this to skip 'on-the-go' sync
# otgsync.nosync = 1
# *** tunes2pod.pl ***
+
## Uncomment to set '--force' switch to true (DANGEROUS)
# tunes2pod.force = 1
-
-# *** mktunes.pl ***
-## Set --volume boost to +10 percent
-# mktunes.volume = +10
-## Enforce iPod serial number:
-# mktunes.fwguid = 000ba3100310abcf
+## Setting the low_ram_attr option above causes tunes2pod.pl to sync
+## the attibutes in iTunesDB with those in GNUtunesDB.xml to make sure
+## attributes not present in iTunesDB will be lost
# *** gnupod_search.pl ***
diff --git a/src/ext/Mktunes.pm b/src/ext/Mktunes.pm
index c47d679..b503058 100644
--- a/src/ext/Mktunes.pm
+++ b/src/ext/Mktunes.pm
@@ -34,7 +34,7 @@ package GNUpod::Mktunes;
#
# Create and write the iTunesDB file
sub WriteItunesDB {
- my($self) = @_;
+ my($self,%args) = @_;
my $mhbd_size = 0;
my $mhsd_size = 0;
@@ -52,7 +52,7 @@ package GNUpod::Mktunes;
$mhsd_size = tell(ITUNES);
print ITUNES
GNUpod::iTunesDB::mk_mhlt({songs=$self-GetFileCount});
foreach my $item (@{$self-GetFiles}) {
- print ITUNES $self-AssembleMhit($item);
+ print ITUNES $self-AssembleMhit(object=$item,
keep=$args{keep});
print \r $i files assembled if ($i++ % 96 == 0);
}
$mhsd_size = tell(ITUNES)-$mhsd_size;
@@ -267,7 +267,9 @@ package GNUpod::Mktunes;
#
# Builds a single mhit with mhod childs
sub AssembleMhit {
- my($self, $object) = @_;
+ my($self, %args) = @_;
+ my $object = $args{object};
+ my $keep= $args{keep};
my $mhit= ''; # Buffer for the new mhit
my $mhod_chunks = ''; # Buffer for the childs (mhods)
my $mhod_count = 0; # Child counter
@@ -275,6 +277,7 @@ package GNUpod::Mktunes;
foreach my $key (sort keys(%$object)) {
my $value = $object-{$key};
next unless $value; # Do not write empty values
+ next if (scalar keys %$keep !$keep-{$key}); # Only
keep specific mhods
my $new_mhod = GNUpod::iTunesDB::mk_mhod({stype=$key,
string=$value});
next unless $new_mhod; # Something went wrong
$mhod_chunks .= $new_mhod;
diff --git a/src/ext/XMLhelper.pm b/src/ext/XMLhelper.pm
index 748ce22..bb7c88b 100755
--- a/src/ext/XMLhelper.pm
+++ b/src/ext/XMLhelper.pm
@@ -301,19 +301,23 @@ sub mkh {
}
-
#
-# Parses the XML File and do events
-sub doxml {
- my($xmlin, %opts) = @_;
- return undef unless (-r $xmlin);
- ### reset some stuff if we do a second run
+# Reset some stuff if we do a second run
+sub resetxml {
$cpn = undef; #Current PlaylistName
@idpub = ();
@plorder = ();
$xid = 1;
$XDAT = undef;
- ###
+}
+
+
+#
+# Parses the XML File and do events
+sub doxml {
+ my($xmlin, %opts) = @_;
+ return undef unless (-r $xmlin);
+ resetxml;
my $p;
my $ref = eval {
$p = new XML::Parser(ErrorContext = 0,
Handlers={Start=\eventer});
diff --git a/src/mktunes.pl b/src/mktunes.pl
index fab4ce3..a35ef62 100644
--- a/src/mktunes.pl
+++ b/src/mktunes.pl
@@ -41,7 +41,7 @@ print mktunes.pl ###__VERSION__### (C) Adrian Ulrich\n;
$opts{mount}