Issue #58 on hold

Fix for versions of Windows that do not support ANSI terminal control characters

Anonymous created an issue

Recent versions of Windows no longer support ANSI terminal control characters, not even as an option (that is, ansi.sys no longer exists).

This means that the terminal output of the program is filled with garbage:

←[1m←[32mWFBach_1_bas.mp3←[0m   ←[32m[ 5.80 MB ]←[0m
-------------------------------------------------------------------------------
←[33mAdding image Wilhelm_Friedemann_Bach_sketch.jpg←[0m
←[1mTime: ←[0m06:17     MPEG1, Layer III        [ 128 kb/s @ 44100 Hz - Joint stereo ]
-------------------------------------------------------------------------------
ID3 v2.3:
←[1mtitle←[0m: (Silence)
←[1martist←[0m: Ciccone Youth
←[1malbum←[0m: The Whitey Album
←[1mrecording date←[0m: 1988
←[1mtrack←[0m: 2                ←[1mgenre←[0m: Alternative (id 20)
←[1mPublisher/label:←[0m Blast First
←[1mILLUSTRATION Image←[0m: [Size: 54470 bytes] [Type: image/pjpeg]
Description:

←[1mPRIV←[0m: [Data: 41 bytes]
Owner Id: WM/MediaClassSecondaryID
←[1mPRIV←[0m: [Data: 39 bytes]
Owner Id: WM/MediaClassPrimaryID
←[1mPRIV←[0m: [Data: 20 bytes]
Owner Id: WM/Provider
←[1mPRIV←[0m: [Data: 31 bytes]
Owner Id: WM/WMContentID
←[1mPRIV←[0m: [Data: 34 bytes]
Owner Id: WM/WMCollectionID
←[1mPRIV←[0m: [Data: 39 bytes]
Owner Id: WM/WMCollectionGroupID
←[1mPRIV←[0m: [Data: 138 bytes]
Owner Id: WM/UniqueFileIdentifier
←[33mWriting ID3 version v2.3←[0m
-------------------------------------------------------------------------------

I propose a very simple workaround using Jonathan Hartley's colorama module. Under non-Windows systems it does nothing. On Windows systems it wraps stdout and simulates ANSI terminal control strings using Windows API calls.

Applying the fix is minimally invasive:

def main(args, config):
    if args.list_plugins:
        _listPlugins(config)
        return 0

    # Fix ########
    colorama.init()
    # End #######
    args.plugin.start(args, config)

    # Process paths (files/directories)
    for p in args.paths:
        eyed3.utils.walk(args.plugin, p, excludes=args.excludes,
                         fs_encoding=args.fs_encoding)

    args.plugin.handleDone()

    # Fix ##########
    colorama.deinit()
    # End #########

    return 0

Comments (1)

  1. Log in to comment