dolodobendan wrote: 
> My head is still spinning, but I'll give it a whirl tomorrow.
> 
> But I still wonder: LMS changes/calculates the duration some seconds
> after the podcast starts. So it uses the calculated time from that point
> on and not the XML time. Why stop early?

Trawling through the code is not easy and I'm not sure what is to be
gained. The problem starts with a bad podcast feeds.

LMS is a complex piece of code - when a track is found and object is
created with the details - title, format, duration etc.  In some case
the information is updated if "better" info is obtained - I suspect that
duration is set when object is created and has not been updated except
when "restarted" which uses the code posted.

The code below is the XML parser used for podcasts (I think) - you can
see if notes the duration from "itunes:duration" tag but also it copies
the "length" from the enclosure tag.  It'll take more digging to see how
LMS uses these tags and decides what to do as I'm sure length gets
updated.


Code:
--------------------
    
                # Add iTunes-specific data if available
                # http://www.apple.com/itunes/podcasts/techspecs.html
                if ( $xml->{'xmlns:itunes'} ) {
  
                        $item{'duration'} = 
unescapeAndTrim($itemXML->{'itunes:duration'});
                        $item{'explicit'} = 
unescapeAndTrim($itemXML->{'itunes:explicit'});
  
                        # Use episode specific image if there is one.
                        if (ref $itemXML->{'itunes:image'} eq 'HASH') {
                                my $href = $itemXML->{'itunes:image'}->{'href'};
                                # We only want a non null scalar
                                $item{'image'} = $href if $href && ! ref $href;
                        }
  
                        # don't duplicate data
                        if ( $itemXML->{'itunes:subtitle'} && 
$itemXML->{'title'} && 
                                $itemXML->{'itunes:subtitle'} ne 
$itemXML->{'title'} ) {
                                $item{'subtitle'} = 
unescapeAndTrim($itemXML->{'itunes:subtitle'});
                        }
                        
                        if ( $itemXML->{'itunes:summary'} && 
$itemXML->{'description'} &&
                                $itemXML->{'itunes:summary'} ne 
$itemXML->{'description'} ) {
                                $item{'summary'} = 
unescapeAndTrim($itemXML->{'itunes:summary'});
                        }
                }
  
                my $enclosure = $itemXML->{'enclosure'};
  
                if (ref $enclosure eq 'ARRAY') {
                        $enclosure = $enclosure->[0];
                }
  
                if ($enclosure) {
                        $item{'enclosure'}->{'url'}    = 
trim($enclosure->{'url'});
                        $item{'enclosure'}->{'type'}   = 
trim($enclosure->{'type'});
                        $item{'enclosure'}->{'length'} = 
trim($enclosure->{'length'});
                }
  
  
  
--------------------


------------------------------------------------------------------------
bpa's Profile: http://forums.slimdevices.com/member.php?userid=1806
View this thread: http://forums.slimdevices.com/showthread.php?t=109017

_______________________________________________
Squeezecenter mailing list
Squeezecenter@lists.slimdevices.com
http://lists.slimdevices.com/mailman/listinfo/squeezecenter

Reply via email to