Re: [Bug-gnupod] mktunes.pl creates corrupt iTunesDB ?

2009-06-19 Thread Richard van den Berg
On Fri, June 19, 2009 10:27, H. Langos wrote:
 Good thing you mention tunes2pod. Please try to make your changes
 optional.
 Something like a --merge option to express that you are going to merge
 iTunesDB and GNUtunesDB.xml

I thought about this myself, but we would have to make this a parameter in
.gnupodrc instead because of the automatic tunes2pod run by the other
tools. The reason that I didn't implement it, is that there is no real
downside to do the merging. The attributes in iTunesDB always overwrite
those in GNUtunesDB.xml. If they are the same, no problem. If a file is in
iTunesDB and not in GNUtunesDB.xml, no problem either.

Let me know if you absolutely want it to be optional and I'll make it so.

Cheers,

Richard



___
Bug-gnupod mailing list
Bug-gnupod@nongnu.org
http://lists.nongnu.org/mailman/listinfo/bug-gnupod


Re: [Bug-gnupod] mktunes.pl creates corrupt iTunesDB ?

2009-06-19 Thread Richard van den Berg
On Fri, June 19, 2009 11:07, H. Langos wrote:
 Maybe the merge code should only be active if your memory saving feature
 is active?

That makes a lot of sense, and it easy to implement. :-) I'll post another
patch tonight.

Cheers,

Richard




___
Bug-gnupod mailing list
Bug-gnupod@nongnu.org
http://lists.nongnu.org/mailman/listinfo/bug-gnupod


[Bug-gnupod] gnupod moved from CVS to GIT...

2009-06-19 Thread H. Langos
...and the people rejoiced.

Now everybody can get a piece of gnupod by running 

 git clone git://git.savannah.gnu.org/gnupod.git

This creates a gnupod sub directory with the current
bleeding edge development version of gnupod.
One more 

 autoconf
 configure
 make install

and you've got it installed.

Please uninstall a previous version of gnupod if you installed 
it from your distribution's packet management system (in Ubuntu 
and Debian the packet is called gnupod-tools) as the paths for 
installing perl modules might differ and you may end up with two 
installed versions of some gnupod modules and executables.


An now some more details for the curious: 

In that gnupod directory will be a .git subdirectory 
with the complete gnupod history (every revision, every 
patch, every tag, everything.) so every lookup of past versions 
and diffs will happen locally. No need for connectivity, NO latency!

Instead of explaining it all wrong here's the synopsis of git-clone

   Clones a repository into a newly created directory, creates
   remote-tracking branches for each branch in the cloned 
   repository (visible using git branch -r), and creates and 
   checks out an initial branch equal to the cloned repository´s
   currently active branch.

   After the clone, a plain git fetch without arguments will 
   update all the remote-tracking branches, and a git pull without 
   arguments will in addition merge the remote master branch into 
   the current master branch, if any.

   This default configuration is achieved by creating references to 
   the remote branch heads under $GIT_DIR/refs/remotes/origin and by 
   initializing remote.origin.url and remote.origin.fetch 
   configuration variables.


For beginners a gui is always nice to get a feeling

 gitk

or 

 qgit


There's tons of good git tutoruials and migration guides for people
who are familiare with other version control systemss so I'll only
recommend reading the man pages git-tutorial and git-workflows:

http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html
http://www.kernel.org/pub/software/scm/git/docs/gitworkflows.html

cheers
-henrik


___
Bug-gnupod mailing list
Bug-gnupod@nongnu.org
http://lists.nongnu.org/mailman/listinfo/bug-gnupod


Re: [Bug-gnupod] mktunes.pl creates corrupt iTunesDB ?

2009-06-19 Thread Richard van den Berg

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}