# Buggy code
def create_title(plugin=None):
    if args.title and plugin:
        title = LazyFormatter.format(
            maybe_encode(args.title),
            title=lambda: plugin.get_title() or DEFAULT_STREAM_METADATA["title"],
            author=lambda: plugin.get_author() or DEFAULT_STREAM_METADATA["author"],
            category=lambda: plugin.get_category()
            or DEFAULT_STREAM_METADATA["category"],
            game=lambda: plugin.get_category() or DEFAULT_STREAM_METADATA["game"],
            url=plugin.url,
        )
    else:
        title = args.url
    return title


# Traceback (UnicodeDecodeError)
OS: macOS 10.14.2
Python: 2.7.14
Streamlink: 1.1.1
Requests(2.21.0), Socks(1.6.7), Websocket(0.47.0)
Found matching plugin twitch for URL twitch.tv/quickybaby
Plugin specific arguments:
--twitch-oauth-token=******** (oauth_token)
--twitch-disable-hosting=True (disable_hosting)
--twitch-disable-ads=True (disable_ads)
Getting live HLS streams for quickybaby
Attempting to authenticate using OAuth token
Successfully logged in as DELETE
[utils.l10n][debug] Language code: en_US
Available streams: audio_only, 160p (worst), 360p, 480p, 720p, 720p60, 1080p60 (best)
Opening stream: 1080p60 (hls)
Starting player: /Applications/mpv.app/Contents/MacOS/mpv
Traceback (most recent call last):
File "/usr/local/bin/streamlink", line 11, in <module>
load_entry_point('streamlink==1.1.1', 'console_scripts', 'streamlink')()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 1033, in main
handle_url()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 594, in handle_url
handle_stream(plugin, streams, stream_name)
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 437, in handle_stream
success = output_stream_passthrough(plugin, stream)
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 262, in output_stream_passthrough
output.open()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 24, in open
self._open()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 219, in _open
self._open_call()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 234, in _open_call
log.debug(u"Calling: {0}".format(fargs))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 141: ordinal not in range(128)

# Fixed code
def create_title(plugin=None):
    if args.title and plugin:
        title = LazyFormatter.format(
            maybe_decode(args.title, get_filesystem_encoding()),
            title=lambda: plugin.get_title() or DEFAULT_STREAM_METADATA["title"],
            author=lambda: plugin.get_author() or DEFAULT_STREAM_METADATA["author"],
            category=lambda: plugin.get_category()
            or DEFAULT_STREAM_METADATA["category"],
            game=lambda: plugin.get_category() or DEFAULT_STREAM_METADATA["game"],
            url=plugin.url,
        )
    else:
        title = args.url
    return title