Commits

Palmer, 2E0EOL  committed 8a3dd9a Merge

Merge 0.2.0 into default

  • Participants
  • Parent commits bd7609f, 3d96296

Comments (0)

Files changed (15)

 4f4caf8d8c915f466cc98397b62dd551c34f4f9f dlpodget-0.0.0
 006a5b5eacd2959bda5c1a4b4e67b107bbcfbbc0 0.1.0
+596941eccf4d904e5701b21712cba11fdaa7c09e 0.2.0
+David Duncan Ross Palmer <palmer@overchat.org>
+Daybo Logic Podcast downloader
+Copyright (c) 2012, David Duncan Ross Palmer, Daybo Logic
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+
+    * Neither the name of the Daybo Logic nor the names of its contributors
+      may be used to endorse or promote products derived from this software
+      without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+0.2.0
+-----
+DDRP: Partial downloaded file recovery
+DDRP: Download progress and rate display
+
+0.1.0
+-----
+DDRP: Initial release.
+2012-12-10
+----------
+New release which supports BSEC and partial downloads
+
+2012-12-08
+----------
+Initial release
+Placeholder; one day we will write something good about this package.
+* Cached RSS XML files to avoid checking every run
+* GUI
+* Unit testing

File debian/changelog

+dlpodget (0.2.0) stable; urgency=low
+
+  * Initial release
+
+ -- David Duncan Ross Palmer <palmer@overchat.org>  Mon, 10 Dec 2012 22:18:20 +0000

File debian/compat

+7

File debian/control

+Source: dlpodget
+Section: net
+Priority: extra
+Maintainer: David Duncan Ross Palmer <palmer@overchat.org>
+Build-Depends: debhelper (>= 7)
+Standards-Version: 3.7.3
+Homepage: http://www.daybologic.co.uk/
+
+Package: dlpodget
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends},
+ libwww-perl,
+ libxml-feed-perl,
+ dl-libconfreader-perl,
+ liburi-perl
+Description: Podcast downloader and management system
+ Daybo Logic's podcast system keeps track of new podcasts posted on an RSS
+ feed and downloads whatever you do not yet have, checking file lengths
+ and caching XML.  It is user-configurable with a trivial config file.

File debian/copyright

+Upstream Author(s):
+
+    David Duncan Ross Palmer <palmer@overchat.org>
+
+Copyright:
+
+    Copyright (C) 2012 Daybo Logic, all rights reserved.
+
+License:
+
+    See COPYING

File debian/install

+dlpodget /opt/bin

File debian/rules

+#!/usr/bin/make -f
+
+export DH_VERBOSE=1
+
+%:
+	dh $@
 #!/usr/bin/perl -w
 
 package main;
-use LWP::Simple qw(get);
+use LWP::UserAgent;
 use XML::Feed;
 use Data::Dumper;
 use Daybo::ConfReader;
 use Getopt::Std;
+use URI::Escape;
 use strict;
 use warnings;
 use diagnostics;
 sub FileFromURI($)
 {
 	my $Url = shift;
+	return undef if ( !$Url );
 	my @uri_parts = split('/', $Url);
 	return $uri_parts[-1];
 }
 	my ( $Feeds, $Url, $Name ) = @_;
 	my $feed = XML::Feed->parse(URI->new($Url));
 	foreach my $entry ($feed->entries) {
-		my $filename = FileFromURI($entry->link);
 		my $enclosure = $entry->{'entry'}->{'enclosure'};
+		my $uriDecoded = uri_unescape($enclosure->{'url'});
+		my $filename = FileFromURI($uriDecoded);
 		push(@entries, {
 			filename => $filename,
-			uri      => $entry->link,
+			uri      => $uriDecoded,
 			title    => $entry->title,
 			type     => $enclosure->{'type'},
 			length   => $enclosure->{'length'}
-		});
+		}) if ( $filename );
 	}
 	return @entries;
 }
 
 sub DownloadStream($$$)
 {
-	my $data;
+	my ( $ua, $f, %get_params );
+	my $local_length = 0;
 	my ( $Feeds, $entry, $Name ) = @_;
 	my $local_podcast = $Feeds->{$Name}->{localpath} . '/' . $entry->{filename};
 	if ( -f $local_podcast ) {
-		printf(STDERR "%s already exists\n", $local_podcast);
-		return;
+		$local_length = (stat($local_podcast))[7];
+		if ( !$entry->{length} || $local_length == $entry->{length} ) {
+			printf(STDERR "%s already exists\n", $local_podcast);
+			return;
+		}
 	}
-	printf(STDERR "Downloading %s ... ", $entry->{uri});
-	$data = get($entry->{uri});
-	print(STDERR "done.\n");
-
-	if ( $Feeds->{_main}->{noop} ) {
-		printf(STDERR "\nSkipping write of %s (DRY-RUN).\n", $local_podcast);
-		return;
+	$ua = LWP::UserAgent->new( show_progress => 1 );
+	unless ( $Feeds->{_main}->{noop} ) {
+		if ( open($f, '>>:raw', $local_podcast) ) {
+			binmode($f);
+		} else {
+			printf(STDERR "Failed -- %s\n", $!);
+			return;
+		}
 	}
-
-	printf(STDERR "\nWriting %s ... ", $local_podcast);
-	if ( open(my $f, '>', $local_podcast) ) {
-		binmode($f);
-		print($f $data);
-		close($f);
-		print(STDERR "done.\n");
-	} else {
-		printf(STDERR "Failed -- %s\n", $!);
-	}
+	%get_params = (
+		'Range' => "bytes=$local_length-"
+	) if ( $local_length );
+	$ua->get(
+		$entry->{uri},
+		%get_params,
+		':content_cb' => sub {
+			my ( $chunk ) = @_;
+			print $f $chunk unless ( $Feeds->{_main}->{noop} );
+		}
+	);
+	close($f) if ( !$Feeds->{_main}->{noop} );
 }
 
 sub ProcessTags($$)
 localpath = $LOCALPFX/bsec
 rss       = http://feeds.feedburner.com/BradleyStokeEvangelicalChurchSermons?format=xml
 check     = 1
-download  = 0
+download  = 1
 enable    = 1
 
 [bbcaq]
 check     = 1
 download  = 1
 enable    = 1
+
+[bbctoday]
+localpath = $LOCALPFX/bbctoday
+rss       = http://downloads.bbc.co.uk/podcasts/radio4/today/rss.xml
+check     = 1
+download  = 1
+enable    = 1
+
+[bsdtalk]
+localpath = $LOCALPFX/bsdtalk
+rss       = http://feeds.feedburner.com/Bsdtalk
+check     = 1
+download  = 1
+enable    = 1