Mac-iPod-GNUpod

 view release on metacpan or  search on metacpan

GNUpod.pm  view on Meta::CPAN

        type => 1,
        curid => $num
    );

    # Create child playlists
    for my $plname (@{$self->{plorder}}) {
        my %common = ( name => $plname, type => 0, curid => $num );
        if (my $spl = $self->get_spl($plname)) {
            (my $dat, $num) = Mac::iPod::GNUpod::iTunesDBwrite::r_mpl(
                %common, 
                splprefs => $spl->{pref},
                spldata => $spl->{data}
            );
            $data{playlist} .= $dat;
        }
        else {
            (my $dat, $num) = Mac::iPod::GNUpod::iTunesDBwrite::r_mpl(
                %common, 
                ids => [ $self->render_pl($plname) ]
            );
            $data{playlist} .= $dat;

GNUpod/iTunesDBread.pm  view on Meta::CPAN

        my $foo = get_string($seek+($ml-$xl), $xl); #string of the entry 
        #$foo is now UTF16 (Swapped), but we need an utf8
        $foo = Unicode::String::byteswap2($foo);
        $foo = Unicode::String::utf16($foo)->utf8;

        ##Special handling for SPLs
        if($mty == 51) { #Get data from spldata mhod
            $foo = undef;
            $spldata = read_spldata({start=>$seek, htm=>$htm});
        }
        elsif($mty == 50) { #Get prefs from splpref mhod
            $foo = undef;
            $splpref = read_splpref({start=>$seek, end=>$ml});
        }
        return({size=>$ml,string=>$foo,type=>$mty,spldata=>$spldata,splpref=>$splpref,matchrule=>$anym});

    }
    else {
        return({size => -1});
    }
}

GNUpod/iTunesDBwrite.pm  view on Meta::CPAN

    return $ret;
}

# Render a playlist
sub r_mpl { 
    # Expects a hash w/ the following keys:
    #   name => $ name of the pl
    #   type => $ type of the pl
    #   ids => [] list of songids of in pl
    #   curid => $ current id in db
    #   splprefs => {} holds spl prefs
    #   spldata => {} holds spl data
    my %dat = @_;
    my ($pl, $fc, $mhp) = ('', 0, 0);

    # Spls handled here
    if(ref($dat{splprefs}) eq "HASH") {
        my $spl = $dat{splprefs};
        $pl .= mk_splprefmhod({
              item => $spl->{limititem},
              sort => $spl->{limitsort},
              mos => $spl->{moselected},
              liveupdate => $spl->{liveupdate},
              value => $spl->{limitval},
              checkrule => $spl->{checkrule}
        });

        $pl .= mk_spldatamhod({anymatch => $spl->{matchany}, data => $dat{spldata}});

GNUpod/iTunesDBwrite.pm  view on Meta::CPAN

    $ret .= pack("h8", _itop($hr->{playlists}));          #playlists on iPod (including main!)
    $ret .= pack("h160", "00");                     #dummy space
    return $ret;
}

# Creates an header for a new playlist (child of mk_mhlp)
sub mk_mhyp {
    my($hr) = @_;

    # We need to create a listview-layout and an mhod with the name. iTunes
    # prefs for this PL & PL name (default PL has  device name as PL name)
    my $appnd = mk_mhod({stype=>"title", string=>$hr->{name}}).__dummy_listview();   

    ##Child mhods calc..
    ##We create 2 mhod's here.. mktunes may have created more mhods.. so we
    ##have to adjust the childs here
    my $cmh = 2+$hr->{mhods};

    my $ret .= "mhyp";
    $ret .= pack("h8", _itop(108)); #type
    $ret .= pack("h8", _itop($hr->{size}+108+(length($appnd))));          #size



( run in 2.781 seconds using v1.01-cache-2.11-cpan-0bb4e1dffa6 )