bug-gnupod
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Richard van den Berg
Subject: Re: [Bug-gnupod] mktunes.pl creates corrupt iTunesDB ?
Date: Tue, 16 Jun 2009 22:05:16 +0200
User-agent: Thunderbird 2.0.0.21 (Macintosh/20090302)

On 6/16/09 12:44 AM, H. Langos wrote:
My first idea now is to
strip the iTunesDB of the stuff that is optional.

Thanks again for the suggestion, that worked really well. I can now see all my 30415 songs! Whoohoo. :-)

These are the mhods that gnupod supports:

my %mhod_id = ( title=>1, path=>2, album=>3, artist=>4, genre=>5, fdesc=>6, eq=>7, comment=>8, category=>9, composer=>12, group=>13, desc=>14, podcastguid=>15, podcastrss=>16, chapterdata=>17, subtitle=>18, tvshow=>19, tvepisode=>20, tvnetwork=>21, albumartist=>22, artistthe=>23, keywords=>24, sorttitle=>27, sortalbum=>28, sortalbumartist=>29,
                sortcomposer=>30, sorttvshow=>31);

I've determined that all you really need is the path and title. This created a 25MB iTunesDB. That's only 57% of what I started with. I've settled for keeping these mhods:

path
artist
title
album
desc

This gave me an iTunesDB of 32MB (34MB with my title patch) which works just fine on my 64MB iPod Video.

Since different users will want to keep different attributes I went for a "keepattr" option in gnupodrc. A second patch is needed for tunes2pod which will read the missing attributes from GNUtunesDB.xml, otherwise they are gone forever after tunes2pod is run. I'll work on that later.

Cheers,

Richard
? .gnupod_version
? Makefile
? autom4te.cache
? config.log
? config.status
? configure
Index: doc/gnupodrc.example
===================================================================
RCS file: /sources/gnupod/gnupod/doc/gnupodrc.example,v
retrieving revision 1.7
diff -u -r1.7 gnupodrc.example
--- doc/gnupodrc.example        5 Jun 2009 12:55:56 -0000       1.7
+++ doc/gnupodrc.example        16 Jun 2009 20:01:51 -0000
@@ -51,6 +51,14 @@
 # mktunes.volume = +10
 ## Enforce iPod serial number:
 # mktunes.fwguid = 000ba3100310abcf
+## Only keep some attributes to make the iTunesDB size as small as possible
+## 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
+# keepattr = path title artist album
 
 # *** gnupod_search.pl ***
 
Index: src/mktunes.pl
===================================================================
RCS file: /sources/gnupod/gnupod/src/mktunes.pl,v
retrieving revision 1.86
diff -u -r1.86 mktunes.pl
--- src/mktunes.pl      8 Dec 2007 10:26:08 -0000       1.86
+++ src/mktunes.pl      16 Jun 2009 20:01:51 -0000
@@ -41,7 +41,7 @@
 
 $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");
+GNUpod::FooBar::GetConfig(\%opts, {'ipod-name'=>'s', mount=>'s', volume=>'i', 
energy=>'b', fwguid=>'s', model=>'s', keepattr=>'s'}, "mktunes");
 $opts{'ipod-name'} ||= "GNUpod ###__VERSION__###";
 
 
@@ -69,7 +69,7 @@
        GNUpod::XMLhelper::doxml($con->{xml}) or usage("Could not read 
$con->{xml}, did you run gnupod_INIT.pl ?");
        
        print "\r> ".$mktunes->GetFileCount." files parsed, assembling 
iTunesDB...\n";
-       $mktunes->WriteItunesDB;
+       $mktunes->WriteItunesDB(Keep=>$opts{'keepattr'});
        
        if($fwguid) {
                my $k = GNUpod::Hash58::HashItunesDB(FirewireId=>$fwguid, 
iTunesDB=>$con->{itunesdb});
Index: src/ext/Mktunes.pm
===================================================================
RCS file: /sources/gnupod/gnupod/src/ext/Mktunes.pm,v
retrieving revision 1.6
diff -u -r1.6 Mktunes.pm
--- src/ext/Mktunes.pm  6 Oct 2007 07:26:52 -0000       1.6
+++ src/ext/Mktunes.pm  16 Jun 2009 20:01:51 -0000
@@ -34,7 +34,7 @@
        
#########################################################################
        # 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 @@
                        $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(Item=>$item, 
Keep=>$args{Keep});
                        print "\r> $i files assembled " if ($i++ % 96 == 0);
                }
                        $mhsd_size = tell(ITUNES)-$mhsd_size;
@@ -267,7 +267,9 @@
        
#########################################################################
        # Builds a single mhit with mhod childs
        sub AssembleMhit {
-               my($self, $object) = @_;
+               my($self, %args) = @_;
+               my $object      = $args{Item};
+               my @keep        = split(/[ ,]+/, $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 @@
                foreach my $key (sort keys(%$object)) {
                        my $value = $object->{$key};
                        next unless $value; # Do not write empty values
+                       next unless ($#keep<0 || grep(/^$key$/,@keep)); # 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;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]