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

Added an option to follow symlinks #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions whatmp3.1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ whatmp3 \- transcode audio files and create torrents
.SH SYNOPSIS
.B whatmp3
.RB [ \-v ]
.RB [ \-f ]
.RB [ \-h ]
.RB [ \-\-version ]
.RB [ \-n ]
Expand Down Expand Up @@ -75,6 +76,9 @@ prints version information to standard output, then exits.
.BR \-v \fR,\ \fB\-\-verbose
prints extra information to screen
.TP
.BR \-f \fR,\ \fB\-\-followlinks
visit directories pointed to by symlinks, on systems that support them
.TP
.BR \-n \fR,\ \fB\-\-notorrent
does not create a torrent even if a tracker announce url is provided
.TP
Expand Down
7 changes: 4 additions & 3 deletions whatmp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
def copy_other(opts, flacdir, outdir):
if opts.verbose:
print('COPYING other files')
for dirpath, dirs, files in os.walk(flacdir, topdown=False):
for dirpath, dirs, files in os.walk(flacdir, topdown=False, followlinks=opts.followlinks):
for name in files:
if opts.nolog and fnmatch(name.lower(), '*.log'):
continue
Expand Down Expand Up @@ -177,7 +177,7 @@ def replaygain(opts, codec, outdir):
print(encoders[enc_opts[codec]['enc']]['regain'] % outdir)
r = system(encoders[enc_opts[codec]['enc']]['regain'] % escape_quote(outdir))
if r: failure(r, "replaygain")
for dirpath, dirs, files in os.walk(outdir, topdown=False):
for dirpath, dirs, files in os.walk(outdir, topdown=False, followlinks=opts.followlinks):
for name in dirs:
r = system(encoders[enc_opts[codec]['enc']]['regain']
% os.path.join(dirpath, name))
Expand All @@ -192,6 +192,7 @@ def setup_parser():
p.add_argument('--version', action='version', version='%(prog)s ' + VERSION)
for a in [
[['-v', '--verbose'], False, 'increase verbosity'],
[['-f', '--followlinks'], False, 'visit directories pointed to by symlinks, on systems that support them'],
[['-n', '--notorrent'], False, 'do not create a torrent after conversion'],
[['-r', '--replaygain'], False, 'add ReplayGain to new files'],
[['-c', '--original'], False, 'create a torrent for the original FLAC'],
Expand Down Expand Up @@ -311,7 +312,7 @@ def main():
flacfiles = []
if not os.path.exists(opts.torrent_dir):
os.makedirs(opts.torrent_dir)
for dirpath, dirs, files in os.walk(flacdir, topdown=False):
for dirpath, dirs, files in os.walk(flacdir, topdown=False, followlinks=opts.followlinks):
for name in files:
if fnmatch(name.lower(), '*.flac'):
flacfiles.append(os.path.join(dirpath, name))
Expand Down