Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support optional use of remote filename for output #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions bashpodder
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
# Make script crontab friendly:
cd $(dirname $0)

# Destination location filename can be extracted from the URL to match the
# filename they call it in the enclosure. Note: this feature is off by
# default because it requires Perl and its URL::URI package.
useremotefilename=0

# datadir is the directory you want podcasts saved to:
datadir=$(date +%Y-%m-%d)

Expand All @@ -28,8 +33,13 @@ while read podcast
echo $url >> temp.log
if ! grep -F "$url" podcast.log > /dev/null
then
destination=$datadir/$(echo "$url" | awk -F'/' {'print $NF'} | awk -F'=' {'print $NF'} | awk -F'?' {'print $1'})
wget -t 10 -U BashPodder -c -q -O $destination "$url" || rm $destination
if [ $useremotefilename = 1 ];
then
destination=$datadir/$(echo "$url" | perl -ne 'use URI::URL; chomp; $url = new URI::URL($_); @x = $url->path_components(); print $x[$#x];')
else
destination=$datadir/$(echo "$url" | awk -F'/' {'print $NF'} | awk -F'=' {'print $NF'} | awk -F'?' {'print $1'})
fi
wget -t 10 -U BashPodder -c -q -O $destination "$url" || rm $destination
fi
done
done < bp.conf
Expand Down